示例#1
0
        private void numericJump_KeyPress(object sender, KeyPressEventArgs e)
        {
            byte jumpNum = (byte)numericJump.Value;

            if (e.KeyChar == (char)13 && jumpNum < world.NumMaps)
            {
                warpDest = null;
                mapNum   = (byte)numericJump.Value;
                updateFields();
            }
        }
示例#2
0
        private void buttonJump_Click(object sender, EventArgs e)
        {
            byte jumpNum = (byte)numericJump.Value;

            if (jumpNum < world.NumMaps)
            {
                warpDest = null;
                mapNum   = jumpNum;
                updateFields();
            }
        }
示例#3
0
        public void InsertMap(byte mapNum)
        {
            if (numMaps < MAX_MAPS)
            {
                // update chests
                for (int c = 0; c < MAX_CHESTS; c++)
                {
                    Chest chest = chests[c];
                    if (chest.Map >= mapNum && chest.Map != 255)
                    {
                        // if chest is on a higher map, shift the map #
                        chest.Map++;
                    }
                }

                // update map connections and warps
                for (int m = 0; m < numMaps; m++)
                {
                    Map map = maps[m];
                    if (map.MapUp >= mapNum && map.MapUp != 255)
                    {
                        map.MapUp++;
                    }
                    if (map.MapDown >= mapNum && map.MapDown != 255)
                    {
                        map.MapDown++;
                    }
                    if (map.MapLeft >= mapNum && map.MapLeft != 255)
                    {
                        map.MapLeft++;
                    }
                    if (map.MapRight >= mapNum && map.MapRight != 255)
                    {
                        map.MapRight++;
                    }
                    for (int w = 0; w < map.NumWarps; w++)
                    {
                        Warp warp = map.GetWarp(w);
                        if (warp.Map >= mapNum && warp.Map != 255)
                        {
                            warp.Map++;
                        }
                    }
                }

                // insert new map and inc counter
                Map newMap = new Map();
                maps.Insert(mapNum, newMap);
                numMaps++;
            }
        }
示例#4
0
        private void editWarpToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Warp     warp     = map.GetWarp(editPos.X, editPos.Y);
            FormWarp formWarp = new FormWarp(warp);

            if (formWarp.ShowDialog() == DialogResult.OK)
            {
                changeFlag  = true;
                warp.Offset = formWarp.Offset;
                warp.Map    = formWarp.MapNum;
                warp.X      = formWarp.X;
                warp.Y      = formWarp.Y;
                picMap.Refresh();
            }
        }
示例#5
0
        private void followWarpToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Warp warp = map.GetWarp(editPos.X, editPos.Y);

            mapNum = warp.Map;
            if (mapNum != 255)
            {
                warpDest        = new Warp();
                warpDest.Offset = (byte)(((warp.Y / 8) * Map.MAP_WIDTH) + (warp.X / 8));
                updateFields();
            }
            else
            {
                MessageBox.Show("Warp to Boss #" + (warp.X / 8), "", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
示例#6
0
        public FormWarp(Warp warp)
        {
            InitializeComponent();

            numericMap.Minimum = 0;
            numericMap.Maximum = 255;
            numericX.Minimum   = 0;
            numericX.Maximum   = Map.MAP_WIDTH - 1;
            numericY.Minimum   = 0;
            numericY.Maximum   = Map.MAP_HEIGHT - 1;

            offset = warp.Offset;
            updatePosition();
            numericMap.Value = warp.Map;
            numericX.Value   = warp.X / 8;
            numericY.Value   = warp.Y / 8;
        }
示例#7
0
 private void addWarpToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (map.NumWarps < Map.MAX_WARPS)
     {
         Warp warp = new Warp();
         warp.Offset = Map.CalcOffset(editPos.X, editPos.Y);
         FormWarp formWarp = new FormWarp(warp);
         if (formWarp.ShowDialog() == DialogResult.OK)
         {
             changeFlag  = true;
             warp.Offset = formWarp.Offset;
             warp.Map    = formWarp.MapNum;
             warp.X      = formWarp.X;
             warp.Y      = formWarp.Y;
             map.AddWarp(warp);
             picMap.Refresh();
         }
     }
     else
     {
         MessageBox.Show("Maximum number of warps reached on this screen!", "", MessageBoxButtons.OK);
     }
 }
示例#8
0
        private void picMap_Paint(object sender, PaintEventArgs e)
        {
            // fill background
            e.Graphics.FillRectangle(Brushes.LightGray, new Rectangle(0, 0, picMap.Width, picMap.Height));

            // draw map
            Bitmap tileset = new Bitmap(picTileset.BackgroundImage);

            for (int y = 0; y < Map.MAP_HEIGHT; y++)
            {
                for (int x = 0; x < Map.MAP_WIDTH; x++)
                {
                    // draw standard edit view
                    int    tileNum   = (int)map.GetTile(x, y);
                    int    tileX     = tileNum % 16;
                    int    tileY     = tileNum / 16;
                    Bitmap tileImage = tileset.Clone(new Rectangle(tileX * 32, tileY * 32, 32, 32), tileset.PixelFormat);
                    e.Graphics.DrawImage(tileImage, x * 32, y * 32);
                }
            }

            // draw brush
            if (editPos.X != -1 && editPos.Y != -1)
            {
                int    x         = editPos.X;
                int    y         = editPos.Y;
                Bitmap tileImage = tileset.Clone(new Rectangle(brush.TileNum % 16 * 32, brush.TileNum / 16 * 32, 32, 32), tileset.PixelFormat);
                for (int bx = 0; bx < 32; bx++)
                {
                    for (int by = 0; by < 32; by++)
                    {
                        Color c = tileImage.GetPixel(bx, by);
                        tileImage.SetPixel(bx, by, Color.FromArgb(192, c));
                    }
                }
                e.Graphics.DrawImage(tileImage, x * 32, y * 32);
            }

            // draw warps
            for (int i = 0; i < map.NumWarps; i++)
            {
                Warp warp = map.GetWarp(i);
                int  x    = warp.Offset % Map.MAP_WIDTH;
                int  y    = warp.Offset / Map.MAP_WIDTH;
                e.Graphics.DrawRectangle(new Pen(Color.LimeGreen, 2), (x * 32) + 1, (y * 32) + 1, 30, 30);
            }

            if (warpDest != null)
            {
                int x = warpDest.Offset % Map.MAP_WIDTH;
                int y = warpDest.Offset / Map.MAP_WIDTH;
                e.Graphics.DrawRectangle(new Pen(Color.DarkViolet, 2), (x * 32) + 1, (y * 32) + 1, 30, 30);
            }

            // draw people
            for (int i = 0; i < map.NumPeople; i++)
            {
                Person person = map.GetPerson(i);
                int    x      = person.Offset % Map.MAP_WIDTH;
                int    y      = person.Offset / Map.MAP_WIDTH;
                e.Graphics.DrawRectangle(new Pen(Color.DarkCyan, 2), (x * 32) + 1, (y * 32) + 1, 30, 30);
            }

            // draw chests
            for (int i = 0; i < World.MAX_CHESTS; i++)
            {
                Chest chest = world.GetChest(i);
                if (chest.Map == mapNum)
                {
                    int x = chest.Offset % Map.MAP_WIDTH;
                    int y = chest.Offset / Map.MAP_WIDTH;
                    e.Graphics.DrawRectangle(new Pen(Color.Magenta, 2), (x * 32) + 1, (y * 32) + 1, 30, 30);
                }
            }
        }
示例#9
0
        public void ImportMapIDs(string csvName)
        {
            TextReader          textReader = new StreamReader(File.Open(csvName, FileMode.Open));
            List <List <byte> > dataset    = CsvReader.ParseByteArray(textReader);

            textReader.Close();

            if (dataset != null)
            {
                if (dataset.Count == numMaps)
                {
                    List <Map> newMaps = new List <Map>();

                    // sort by old map ID and reassign connecting & warp map IDs
                    dataset.Sort((x, y) => x[0].CompareTo(y[0]));
                    for (int m = 0; m < numMaps; m++)
                    {
                        if (maps[m].MapUp != 255)
                        {
                            maps[m].MapUp = dataset[maps[m].MapUp][1];
                        }
                        if (maps[m].MapDown != 255)
                        {
                            maps[m].MapDown = dataset[maps[m].MapDown][1];
                        }
                        if (maps[m].MapLeft != 255)
                        {
                            maps[m].MapLeft = dataset[maps[m].MapLeft][1];
                        }
                        if (maps[m].MapRight != 255)
                        {
                            maps[m].MapRight = dataset[maps[m].MapRight][1];
                        }
                        for (int w = 0; w < maps[m].NumWarps; w++)
                        {
                            Warp warp = maps[m].GetWarp(w);
                            if (warp.Map != 255)
                            {
                                warp.Map = dataset[warp.Map][1];
                            }
                        }
                    }
                    // reassign chest map IDs
                    for (int c = 0; c < MAX_CHESTS; c++)
                    {
                        if (chests[c].Map != 255)
                        {
                            chests[c].Map = dataset[chests[c].Map][1];
                        }
                    }

                    // sort by new map ID and add to new List
                    dataset.Sort((x, y) => x[1].CompareTo(y[1]));
                    foreach (List <byte> record in dataset)
                    {
                        newMaps.Add(maps[record[0]]);
                    }

                    maps = newMaps;
                }
                else
                {
                    MessageBox.Show("Invalid number of MAP entries!", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                MessageBox.Show("Non-byte information contained in CSV file!", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
示例#10
0
        public void DeleteMap(byte mapNum)
        {
            if (numMaps > 1)
            {
                // make sure there are no connections or warps to this map
                for (int m = 0; m < numMaps; m++)
                {
                    Map map = maps[m];
                    if (map.MapUp == mapNum)
                    {
                        MessageBox.Show("Map #" + m + ".MapUp connects to this map!", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                    if (map.MapDown == mapNum)
                    {
                        MessageBox.Show("Map #" + m + ".MapDown connects to this map!", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                    if (map.MapLeft == mapNum)
                    {
                        MessageBox.Show("Map #" + m + ".MapLeft connects to this map!", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                    if (map.MapRight == mapNum)
                    {
                        MessageBox.Show("Map #" + m + ".MapRight connects to this map!", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                    for (int w = 0; w < map.NumWarps; w++)
                    {
                        Warp warp = map.GetWarp(w);
                        if (warp.Map == mapNum)
                        {
                            MessageBox.Show("Map #" + m + " has a Warp to this map!", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return;
                        }
                    }
                }

                // update chests
                for (int c = 0; c < MAX_CHESTS; c++)
                {
                    Chest chest = chests[c];
                    if (chest.Map == mapNum)
                    {
                        // if chest is on deleted map, clear chest entry
                        chest.Clear();
                    }
                    if (chest.Map >= mapNum && chest.Map != 255)
                    {
                        // if chest is on a higher map, shift the map #
                        chest.Map--;
                    }
                }

                // delete map from the list
                maps.RemoveAt(mapNum);

                // dec map counter
                numMaps--;

                // update map connections and warps
                for (int m = 0; m < numMaps; m++)
                {
                    Map map = maps[m];
                    if (map.MapUp > mapNum && map.MapUp != 255)
                    {
                        map.MapUp--;
                    }
                    if (map.MapDown > mapNum && map.MapDown != 255)
                    {
                        map.MapDown--;
                    }
                    if (map.MapLeft > mapNum && map.MapLeft != 255)
                    {
                        map.MapLeft--;
                    }
                    if (map.MapRight > mapNum && map.MapRight != 255)
                    {
                        map.MapRight--;
                    }
                    for (int w = 0; w < map.NumWarps; w++)
                    {
                        Warp warp = map.GetWarp(w);
                        if (warp.Map > mapNum && warp.Map != 255)
                        {
                            warp.Map--;
                        }
                    }
                }
            }
        }
示例#11
0
        public bool Validate()
        {
            // validate maps
            for (int m = 0; m < numMaps; m++)
            {
                // check map connections
                if (maps[m].MapUp != 255)
                {
                    if (maps[m].MapUp >= numMaps)
                    {
                        MessageBox.Show("Map #" + m + ".MapUp connects to invalid map", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return(false);
                    }
                    if (maps[maps[m].MapUp].MapDown != m)
                    {
                        MessageBox.Show("Map #" + m + ".MapUp is a one way connection", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return(false);
                    }
                }
                if (maps[m].MapDown != 255)
                {
                    if (maps[m].MapDown >= numMaps)
                    {
                        MessageBox.Show("Map #" + m + ".MapDown connects to invalid map", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return(false);
                    }
                    if (maps[maps[m].MapDown].MapUp != m)
                    {
                        MessageBox.Show("Map #" + m + ".MapDown is a one way connection", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return(false);
                    }
                }
                if (maps[m].MapLeft != 255)
                {
                    if (maps[m].MapLeft >= numMaps)
                    {
                        MessageBox.Show("Map #" + m + ".MapLeft connects to invalid map", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return(false);
                    }
                    if (maps[maps[m].MapLeft].MapRight != m)
                    {
                        MessageBox.Show("Map #" + m + ".MapLeft is a one way connection", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return(false);
                    }
                }
                if (maps[m].MapRight != 255)
                {
                    if (maps[m].MapRight >= numMaps)
                    {
                        MessageBox.Show("Map #" + m + ".MapRight connects to invalid map", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return(false);
                    }
                    if (maps[maps[m].MapRight].MapLeft != m)
                    {
                        MessageBox.Show("Map #" + m + ".MapRight is a one way connection", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return(false);
                    }
                }

                // check warps
                for (int w = 0; w < maps[m].NumWarps; w++)
                {
                    Warp warp = maps[m].GetWarp(w);
                    if (warp.Map >= numMaps && warp.Map != 255)
                    {
                        MessageBox.Show("Map #" + m + " has a Warp with an invalid destination", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return(false);
                    }
                }
            }

            return(true);
        }