예제 #1
0
        public static WorldFormat BuildEmptyWorld(string worldId)
        {
            WorldZoneFormat zone = WorldContent.BuildEmptyZone();

            WorldFormat world = new WorldFormat {
                id          = worldId.ToUpper(),
                account     = "",
                mode        = (byte)HardcoreMode.SoftCore,
                title       = "Unnamed World",
                description = "",
                lives       = 30,
                version     = 0,
                music       = 0,
                zones       = new List <WorldZoneFormat>()
                {
                    zone
                },
                //start = new StartNodeFormat {
                //	character = 0,
                //	zoneId = 0,
                //	x = 0,
                //	y = 0,
                //},
            };

            return(world);
        }
예제 #2
0
        // byte[]:  { Base, Top, Top Layer, Cover, Cover Layer, Object }
        // example: { Dirt, Grass, s4, MountainBrown, s2, NodeCasual }
        public byte[] GetWorldTileData(WorldZoneFormat zone, byte gridX, byte gridY)
        {
            var tiles = zone.tiles;

            if (gridY >= tiles.Length)
            {
                return(new byte[] { 0, 0, 0, 0, 0, 0, 0 });
            }
            if (gridX >= tiles[gridY].Length)
            {
                return(new byte[] { 0, 0, 0, 0, 0, 0, 0 });
            }
            return(tiles[gridY][gridX]);
        }
예제 #3
0
        public bool DeleteTile(WorldZoneFormat zone, byte gridX, byte gridY)
        {
            var tiles = zone.tiles;

            if (gridY > tiles.Length)
            {
                return(false);
            }
            if (gridX > tiles[gridY].Length)
            {
                return(false);
            }
            tiles[gridY][gridX] = new byte[] { 0, 0, 0, 0, 0, 0, 0 };
            return(true);
        }
예제 #4
0
        public bool SetTileObject(WorldZoneFormat zone, byte gridX, byte gridY, byte obj = 0)
        {
            var tiles = zone.tiles;

            if (gridY >= tiles.Length)
            {
                return(false);
            }
            if (gridX >= tiles[gridY].Length)
            {
                return(false);
            }
            tiles[gridY][gridX][5] = obj;
            return(true);
        }
예제 #5
0
        public bool SetTileBase(WorldZoneFormat zone, byte gridX, byte gridY, byte tBase = 0)
        {
            var tiles = zone.tiles;

            if (gridY >= tiles.Length)
            {
                return(false);
            }
            if (gridX >= tiles[gridY].Length)
            {
                return(false);
            }
            tiles[gridY][gridX][0] = tBase;
            return(true);
        }
예제 #6
0
        public bool SetTile(WorldZoneFormat zone, byte gridX, byte gridY, byte tBase = 0, byte top = 0, byte topLay = 0, byte cover = 0, byte coverLay = 0, byte obj = 0, byte nodeId = 0)
        {
            var tiles = zone.tiles;

            if (gridY >= tiles.Length)
            {
                return(false);
            }
            if (gridX >= tiles[gridY].Length)
            {
                return(false);
            }
            tiles[gridY][gridX] = new byte[] { tBase, top, topLay, cover, coverLay, obj, nodeId };
            return(true);
        }
예제 #7
0
        public static WorldZoneFormat BuildEmptyZone()
        {
            WorldZoneFormat zone = new WorldZoneFormat()
            {
                tiles = new byte[1][][],
                nodes = new Dictionary <string, string>(),
            };

            zone.tiles[0]    = new byte[1][];
            zone.tiles[0][0] = new byte[6] {
                20, 0, 0, 0, 0, 0
            };

            return(zone);
        }
예제 #8
0
        public bool SetTileCover(WorldZoneFormat zone, byte gridX, byte gridY, byte cover = 0, byte coverLay = 0)
        {
            var tiles = zone.tiles;

            if (gridY >= tiles.Length)
            {
                return(false);
            }
            if (gridX >= tiles[gridY].Length)
            {
                return(false);
            }
            tiles[gridY][gridX][3] = cover;
            tiles[gridY][gridX][4] = coverLay;
            return(true);
        }
예제 #9
0
        public bool SetTileTop(WorldZoneFormat zone, byte gridX, byte gridY, byte top = 0, byte topLay = 0)
        {
            var tiles = zone.tiles;

            if (gridY >= tiles.Length)
            {
                return(false);
            }
            if (gridX >= tiles[gridY].Length)
            {
                return(false);
            }
            tiles[gridY][gridX][1] = top;
            tiles[gridY][gridX][2] = topLay;
            return(true);
        }
예제 #10
0
        public byte SetZoneHeight(WorldZoneFormat zone, byte newHeight)
        {
            byte width  = this.GetWidthOfZone(zone);
            byte height = this.GetHeightOfZone(zone);

            if (newHeight < (byte)WorldmapEnum.MinHeight)
            {
                newHeight = (byte)WorldmapEnum.MinHeight;
            }
            else if (newHeight > (byte)WorldmapEnum.MaxHeight)
            {
                newHeight = (byte)WorldmapEnum.MaxHeight;
            }

            byte[][][] tiles = zone.tiles;
            Array.Resize <byte[][]>(ref tiles, newHeight);
            zone.tiles = tiles;

            // If New Height is lower:
            if (newHeight < height)
            {
                return(newHeight);
            }

            // Loop through Y Data
            for (byte y = height; y < newHeight; y++)
            {
                zone.tiles[y] = new byte[width][];

                // Loop through X Data
                for (byte x = 0; x < width; x++)
                {
                    zone.tiles[y][x] = new byte[] { 20, 0, 0, 0, 0, 0, 0 };
                }
            }

            return(newHeight);
        }
예제 #11
0
        public byte SetZoneWidth(WorldZoneFormat zone, byte newWidth)
        {
            byte width  = this.GetWidthOfZone(zone);
            byte height = this.GetHeightOfZone(zone);

            if (newWidth < (byte)WorldmapEnum.MinWidth)
            {
                newWidth = (byte)WorldmapEnum.MinWidth;
            }
            else if (newWidth > (byte)WorldmapEnum.MaxWidth)
            {
                newWidth = (byte)WorldmapEnum.MaxWidth;
            }

            // Loop through Y Data
            for (byte y = 0; y < height; y++)
            {
                var newYData = zone.tiles[y];
                Array.Resize <byte[]>(ref newYData, newWidth);
                zone.tiles[y] = newYData;

                // If New Width is lower:
                if (newWidth < width)
                {
                    continue;
                }

                // Loop through X Data
                for (byte x = width; x < newWidth; x++)
                {
                    zone.tiles[y][x] = new byte[] { 20, 0, 0, 0, 0, 0, 0 };
                }
            }

            return(newWidth);
        }
예제 #12
0
 public bool DeleteTileObject(WorldZoneFormat zone, byte gridX, byte gridY)
 {
     return(this.SetTileObject(zone, gridX, gridY));
 }
예제 #13
0
 public byte GetWidthOfZone(WorldZoneFormat zone)
 {
     return((zone.tiles.Length > 0) ? (byte)zone.tiles[0].Length : (byte)0);
 }
예제 #14
0
 public byte GetHeightOfZone(WorldZoneFormat zone)
 {
     return((zone.tiles.Length > 0) ? (byte)zone.tiles.Length : (byte)0);
 }