Exemplo n.º 1
0
        /// <summary>
        /// Initializes all components of the tilemap, and prepares the list of tiles.
        /// </summary>
        public void InitTileMap()
        {
            mesh          = new Mesh();
            mesh_filter   = GetComponent <MeshFilter>();
            mesh_renderer = GetComponent <MeshRenderer>();
            mesh_collider = GetComponent <MeshCollider>();
            TileList      = new TileContents[size_x * size_z];

            for (int i = 0; i < size_x * size_z; i++)
            {
                TileList[i]             = new TileContents();
                TileList[i].OnTopOfTile = new List <GameObject>();
                TileList[i].isEmpty     = true;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Create a new GridNode map
        /// </summary>
        public GridNodeMap()
        {
            this.gridSizeX = GlobalGameData.gridSizeX;
            this.gridSizeY = GlobalGameData.gridSizeY;

            nodeSize = GlobalGameData.tileSize * GlobalGameData.drawRatio;
            nodeArray = new TileContents[gridSizeX, gridSizeY];

            for (int y = 0; y < gridSizeY; ++y)
            {
                for (int x = 0; x < gridSizeX; ++x)
                {
                    Vector2 tilePos = new Vector2();
                    tilePos.X = nodeSize / 2 + nodeSize * x;
                    tilePos.Y = nodeSize / 2 + nodeSize * y;

                    nodeArray[x, y] = new TileContents(tilePos);
                }
            }
        }