Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class BoardController : MonoBehaviour {
- public int[][] value;
- public GameObject[][] Cells;
- public GameObject init;
- public bool[][] ck;
- public GameObject parents;
- void SetPosition(int x,int y){
- Cells [x] [y].transform.position = new Vector3 (5.0f * x, 0.0f, (-5.0f) * y);
- }
- void Awake(){
- //Random.seed = 5;
- value = new int[5][];
- ck = new bool[5][];
- for (int i = 0; i < 5; i ++) {
- value[i] = new int[5];
- ck[i] = new bool[5];
- for (int j = 0; j < 5; j ++){
- value [i] [j] = 0;
- ck[i][j] = false;
- }
- }
- Cells = new GameObject[4][];
- for (int i = 0; i < 4; i ++) {
- Cells[i] = new GameObject[4];
- for (int j = 0 ; j < 4 ; j ++ ){
- Cells[i][j] = Instantiate(init);
- Cells[i][j].SetActive(false);
- Cells [i] [j].transform.position = new Vector3 (5.0000000000000f * i, 0.00000000000000f, (-5.000000000000000000f) * j);
- Cells[i][j].transform.parent = parents.transform;
- }
- }
- int k1 = (int)Random.Range (0, 16);
- Debug.Log (k1);
- int k2;
- do {
- k2 = (int)Random.Range (0, 16);
- } while(k1 == k2);
- Debug.Log (k2);
- int ix = (int)(k1 % 4);
- int iy = (int)(k1 / 4);
- Cells [ix] [iy].SetActive (true);
- //SetPosition (ix, iy);
- ix = (int)(k2 % 4);
- iy = (int)(k2 / 4);
- Cells [ix] [iy].SetActive (true);
- //SetPosition (ix, iy);
- //Cells [ix] [iy].transform.position += new Vector3 (2, 0, -2);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement