Ejemplo n.º 1
0
        //public bool IsActive => Tile != null;

        public void Change(TileSpot tileSpot, uint tileID)
        {
            DestroyTile();
            Spot   = tileSpot;
            TileID = tileID;
            Instantiate();
        }
Ejemplo n.º 2
0
 public TileTemplate(TileSpot tileSpot, uint tileID)
 {
     Provider = null;
     Spot     = tileSpot;
     TileID   = tileID;
     Provider = TileMap.TileSet[tileID];
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Creates the GameObjects for a tile at a specified position.
        /// </summary>
        /// <param name="position">Position in X and Y tile coordinates.</param>
        public void CreateGameObjectsForTile(Point position)
        {
            Point    actualPos = new Point(position.X * SceneManager._TILE_SIZE, position.Y * SceneManager._TILE_SIZE);
            TileSpot tileSpot  = GetTileSpotAtPoint(actualPos);

            tileSpot.CreateGameObjects(actualPos);
        }
Ejemplo n.º 4
0
        public void RemoveTile(Point tilePoint, uint tileID)
        {
            Point chunkPos = Snap(tilePoint, ChunkSize);

            for (int i = 0; i < Chunks.Count; i++)
            {
                TileChunk chunk = Chunks[i];
                if (chunk.Position == chunkPos)
                {
                    Point    chunkTilePos = chunk.ToLocalPoint(tilePoint);
                    TileSpot t            = chunk.TileTemplates[chunkTilePos.X][chunkTilePos.Y];
                    t.RemoveTile(tileID);
                }
            }
        }
Ejemplo n.º 5
0
        public void Initialize(TileMap tileMap, Point position)
        {
            Position = position;
            TileMap  = tileMap;

            TileTemplates = new TileSpot[tileMap.ChunkSize][];
            for (int x = 0; x < tileMap.ChunkSize; x++)
            {
                TileTemplates[x] = new TileSpot[tileMap.ChunkSize];
                for (int y = 0; y < tileMap.ChunkSize; y++)
                {
                    TileTemplates[x][y] = new TileSpot(this, new Point(x + position.X, y + position.Y));
                }
            }
        }
Ejemplo n.º 6
0
 /// <summary>
 /// Creates and initializes the level, giving it a specified size.
 /// </summary>
 /// <param name="size">Amount of tiles on the X and Y axis.</param>
 public void CreateLevel(Point size)
 {
     MapData = new TileSpot[size.X][];
     for (int x = 0; x < size.X; x++)
     {
         MapData[x] = new TileSpot[size.Y];
         for (int y = 0; y < size.Y; y++)
         {
             MapData[x][y] = new TileSpot(this);
         }
     }
     SetTilesCount(size.X, size.Y);
     SceneManager.WorldSize = new Point(TilesCount.X * SceneManager._TILE_SIZE, TilesCount.Y * SceneManager._TILE_SIZE);
     //NavigationManager.Initialize(new Rectangle(0, 0, SceneManager.WorldSize.X, SceneManager.WorldSize.Y));
     //LightingSystem.Initialize(new Rectangle(0, 0,LevelManager.WorldSize.X, LevelManager.WorldSize.Y), LevelManager._TILE_SIZE);
 }
Ejemplo n.º 7
0
        private void LoadData(LevelData data)
        {
            int totalTiles     = data.TilesCount.X * data.TilesCount.Y;
            int curTilesLoaded = 0;

            CreateLevel(data.TilesCount);
            MapData = new TileSpot[TilesCount.X][];
            for (int x = 0; x < data.MapData.Length; x++)
            {
                MapData[x] = new TileSpot[TilesCount.Y];
                for (int y = 0; y < data.MapData[x].Length; y++)
                {
                    MapData[x][y] = new TileSpot(this);
                    MapData[x][y].TileTemplates = data.MapData[x][y];
                    CreateGameObjectsForTile(new Point(x, y));
                    curTilesLoaded++;
                }
                LoadingScreen.SetProgress("Loading", (float)curTilesLoaded / totalTiles);
            }
            MarkerData        = data.MarkerData;
            MarkerGraphicData = data.MarkerGraphicData;
        }