Beispiel #1
0
        private void MoveLand(int x, int y)
        {
            Land   l   = (Land)lbLands.SelectedItem;
            MapTag tag = new MapTag(l.Name, TagType.Land);
            // Remove old tag from tiles
            Coord xy = new Coord(l.X, l.Y);

            foreach (MapTag t in tiles[xy].Tags)
            {
                if (t.Equals(tag))
                {
                    tiles[xy].Tags.Remove(t);
                    break;
                }
            }
            // Add new tag to tiles
            xy = new Coord(x, y);
            tiles[xy].Tags.Add(tag);
            foreach (Land land in lands)
            {
                if (land.Equals(l))
                {
                    land.X = x;
                    land.Y = y;
                    land.C = tiles[xy].C;
                    break;
                }
            }
            UpdateLandList();
            map.Refresh();
        }
Beispiel #2
0
        public override bool Equals(object obj)
        {
            if (obj == null || GetType() != obj.GetType())
            {
                return(false);
            }
            MapTag o = (MapTag)obj;

            return(o.type.Equals(type) && o.tag.Equals(tag));
        }
Beispiel #3
0
 private void btnSaveRegion_Click(object sender, EventArgs e)
 {
     if (!tbRegionName.Text.Trim().Equals(""))
     {
         if (lbRegions.SelectedIndex == -1)
         {
             bool exists = false;
             foreach (Region r in regions)
             {
                 if (r.Name.Equals(tbRegionName.Text.Trim()))
                 {
                     exists = true;
                     break;
                 }
             }
             if (!exists)
             {
                 Region newRegion = new Region(-1, -1, tbRegionName.Text.Trim());
                 regions.Add(newRegion);
                 lbRegions.Items.Add(newRegion);
             }
         }
         else
         {
             Region editRegion = (Region)lbRegions.SelectedItem;
             foreach (Region r in regions)
             {
                 if (r.Equals(editRegion))
                 {
                     MapTag tag = new MapTag(r.Name, TagType.Region);
                     Coord  xy  = new Coord(r.X, r.Y);
                     if (tiles.ContainsKey(xy))
                     {
                         foreach (MapTag t in tiles[xy].Tags)
                         {
                             if (t.Equals(tag))
                             {
                                 t.Tag = tbRegionName.Text.Trim();
                                 break;
                             }
                         }
                     }
                     r.Name = tbRegionName.Text.Trim();
                     break;
                 }
             }
         }
         UpdateRegionList();
         map.Refresh();
     }
     btnSaveRegion.Enabled = false;
     tbRegionName.Enabled  = false;
     tbRegionName.Text     = "";
 }
Beispiel #4
0
 private void btnSaveLand_Click(object sender, EventArgs e)
 {
     if (!tbLandName.Text.Trim().Equals(""))
     {
         if (lbLands.SelectedIndex == -1)
         {
             bool exists = false;
             foreach (Land l in lands)
             {
                 if (l.Name.Equals(tbLandName.Text.Trim()))
                 {
                     exists = true;
                     break;
                 }
             }
             if (!exists)
             {
                 Land newLand = new Land(-1, -1, ' ', tbLandName.Text.Trim());
                 lands.Add(newLand);
                 lbLands.Items.Add(newLand);
             }
         }
         else
         {
             Land editLand = (Land)lbLands.SelectedItem;
             foreach (Land l in lands)
             {
                 if (l.Equals(editLand))
                 {
                     MapTag tag = new MapTag(l.Name, TagType.Land);
                     Coord  xy  = new Coord(l.X, l.Y);
                     if (tiles.ContainsKey(xy))
                     {
                         foreach (MapTag t in tiles[xy].Tags)
                         {
                             if (t.Equals(tag))
                             {
                                 t.Tag = tbLandName.Text.Trim();
                                 break;
                             }
                         }
                     }
                     l.Name = tbLandName.Text.Trim();
                     break;
                 }
             }
         }
         UpdateLandList();
         map.Refresh();
     }
     btnSaveLand.Enabled = false;
     tbLandName.Enabled  = false;
     tbLandName.Text     = "";
 }
Beispiel #5
0
 private void btnRemoveLand_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show(this, "Are you sure you wish to remove this Land?", "Remove Land", MessageBoxButtons.YesNo) == DialogResult.Yes)
     {
         Land l = (Land)lbLands.SelectedItem;
         lbLands.Items.Remove(l);
         lands.Remove(l);
         MapTag tag = new MapTag(l.Name, TagType.Land);
         Coord  xy  = new Coord(l.X, l.Y);
         tiles[xy].Tags.Remove(tag);
     }
     map.Refresh();
 }
Beispiel #6
0
        private void PlaceRegion(int x, int y)
        {
            Region l   = (Region)lbRegions.SelectedItem;
            MapTag tag = new MapTag(l.Name, TagType.Region);
            // Add new tag to tiles
            Coord xy = new Coord(x, y);

            tiles[xy].Tags.Add(tag);
            l.X = x;
            l.Y = y;
            UpdateRegionList();
            map.Refresh();
            state = State.MovingRegion;
        }
Beispiel #7
0
        private void PlaceLand(int x, int y)
        {
            Land   l   = (Land)lbLands.SelectedItem;
            MapTag tag = new MapTag(l.Name, TagType.Land);
            // Add new tag to tiles
            Coord xy = new Coord(x, y);

            tiles[xy].Tags.Add(tag);
            foreach (Land land in lands)
            {
                if (land.Equals(l))
                {
                    land.X = x;
                    land.Y = y;
                    land.C = tiles[xy].C;
                    break;
                }
            }
            UpdateLandList();
            map.Refresh();
            state = State.MovingLand;
        }
Beispiel #8
0
        private void MoveRegion(int x, int y)
        {
            Region l   = (Region)lbRegions.SelectedItem;
            MapTag tag = new MapTag(l.Name, TagType.Region);
            // Remove old tag from tiles
            Coord xy = new Coord(l.X, l.Y);

            foreach (MapTag t in tiles[xy].Tags)
            {
                if (t.Equals(tag))
                {
                    tiles[xy].Tags.Remove(t);
                    break;
                }
            }
            // Add new tag to tiles
            xy = new Coord(x, y);
            tiles[xy].Tags.Add(tag);
            l.X = x;
            l.Y = y;
            UpdateRegionList();
            map.Refresh();
        }
Beispiel #9
0
 public void AddTag(MapTag tag)
 {
     tags.Add(tag);
 }