示例#1
0
    // each tiles num
    // each tile red or blue
    //
    private void InitGrid(int row, int column)
    {
        int   min        = 1;
        int   max        = 45;
        int   tileSize   = 2;
        float tileHeight = 0f;

        gridList = new List <Grid> ();

        for (int j = 0; j < column; j++)
        {
            for (int i = 0; i < row; i++)
            {
                int        num    = Random.Range(min, max + 1);
                TileIntent intent = (TileIntent)Random.Range(0, Enum.GetValues(typeof(TileIntent)).Length);
                Vector3    pos    = new Vector3(i * tileSize, tileHeight, j * tileSize);

                Debug.Log("Installing Tiles... ");
                Debug.Log(num + ":::" + intent + ":::" + pos);
                Debug.Log("Finished Instailling Tiles... ");
                GameObject tr = Instantiate(tilePrefab, pos, Quaternion.identity) as GameObject;

                gridList.Add(new Grid(tr.transform, num, intent));
            }
        }
    }
示例#2
0
        public Grid(Transform tr, int num, TileIntent tileIntent)
        {
            this.tr = tr;
            tr.gameObject.AddComponent <Tile>();
            tr.GetComponent <Tile>().Init(this, num);
            this.num = num;
            this.pos = tr.position;

            TurnIntent(tileIntent);
        }
示例#3
0
        private void TurnIntent(TileIntent tileIntent)
        {
            this.tileIntent = tileIntent;
            switch (tileIntent)
            {
            case TileIntent.PLUS:
                this.tr.GetComponent <MeshRenderer> ().material.color = Color.red;
                break;

            case TileIntent.MINUS:
                this.tr.GetComponent <MeshRenderer> ().material.color = Color.blue;
                break;
            }
        }