Exemplo n.º 1
0
        public void Load()
        {
            int    nG, nGX, nGY;
            ushort nGId, cGId;
            int    cGPriority, nGPriority;
            int    x, y;
            int    i;

            for (x = 0; x < tileData.Length; x++)
            {
                activeTiles[x] = new ActiveTile(tileData[x]);
            }

            for (y = 0; y < Config.CHUNK_SIZE; y++)
            {
                for (x = 0; x < Config.CHUNK_SIZE; x++)
                {
                    i          = (y * Config.CHUNK_SIZE) + x;
                    cGId       = tileData[i].GroundTileId;
                    cGPriority = Array.IndexOf(GroundIds.priorities, cGId);

                    foreach (KeyValuePair <byte, Vector2> entry in edgeOffsets)
                    {
                        nGX = x + (int)entry.Value.X;
                        nGY = y + (int)entry.Value.Y;
                        if (nGY >= 0 && nGX >= 0 && nGY < Config.CHUNK_SIZE && nGX < Config.CHUNK_SIZE)
                        {
                            nG         = (nGY * Config.CHUNK_SIZE) + nGX;
                            nGId       = tileData[nG].GroundTileId;
                            nGPriority = Array.IndexOf(GroundIds.priorities, nGId);
                            if (nGPriority < cGPriority)
                            {
                                activeTiles[nG].IncrementEdgeTransition(cGId, entry.Key);
                            }
                        }
                    }

                    foreach (KeyValuePair <byte, Vector2> entry in cornerOffsets)
                    {
                        nGX = x + (int)entry.Value.X;
                        nGY = y + (int)entry.Value.Y;
                        if (nGY >= 0 && nGX >= 0 && nGY < Config.CHUNK_SIZE && nGX < Config.CHUNK_SIZE)
                        {
                            nG         = (nGY * Config.CHUNK_SIZE) + nGX;
                            nGId       = tileData[nG].GroundTileId;
                            nGPriority = Array.IndexOf(GroundIds.priorities, nGId);
                            if (nGPriority < cGPriority)
                            {
                                activeTiles[nG].IncrementCornerTransition(cGId, entry.Key);
                            }
                        }
                    }
                }
            }

            foreach (ActiveTile tile in activeTiles)
            {
                tile.PrepTransitionData();
            }
        }
Exemplo n.º 2
0
        public void PrintTileData(int tileX, int tileY)
        {
            ActiveTile tile = worldData.GetActiveTile((tileY * worldData.GetWidth()) + tileX);

            tile.PrintDebugInfo();
        }
Exemplo n.º 3
0
        /// <summary>
        /// Place the given object At the given location
        /// </summary>
        /// <param name="objId">Id of the object to place</param>
        /// <param name="tileX">Global x tile position of the object to remove</param>
        /// <param name="tileY">Global y tile position of the object to remove</param>
        public void PlaceObjectAt(ushort objId, int tileX, int tileY)
        {
            ActiveTile tile = worldData.GetActiveTile(tileX, tileY);

            tile.PlaceObject(objId);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Removes the object at the given location
        /// </summary>
        /// <param name="tileX">Global x tile position of the object to remove</param>
        /// <param name="tileY">Global y tile position of the object to remove</param>
        public void RemoveObjectAt(int tileX, int tileY)
        {
            ActiveTile tile = worldData.GetActiveTile(tileX, tileY);

            tile.ClearObject();
        }