コード例 #1
0
ファイル: Map.cs プロジェクト: phantomeis/wzmapeditor
        public Point GetLifeDesignPosition(MapLife life)
        {
            int    x = life.Object.GetInt("x");
            int    cy = life.Object.GetInt("cy");
            double minDis = 0;
            int    fhid = 0, y = 0;

            foreach (MapLayer l in layers)
            {
                foreach (MapFootholds f in l.footholdGroups.Values)
                {
                    foreach (MapFoothold fh in f.footholds.Values)
                    {
                        int x1 = fh.Object.GetInt("x1");
                        int y1 = fh.Object.GetInt("y1");
                        int x2 = fh.Object.GetInt("x2");
                        int y2 = fh.Object.GetInt("y2");
                        if ((x >= x1 && x <= x2) || (x >= x2 && x <= x1))
                        {
                            double nY  = (double)(y1 - y2) / (x1 - x2) * (x - x1) + y1;
                            double dis = Math.Abs(nY - cy);
                            if ((fhid == 0 || dis < minDis) && dis <= 10)
                            {
                                minDis = dis;
                                fhid   = fh.ID;
                                y      = (int)nY;
                            }
                        }
                    }
                }
            }
            return(new Point(y, fhid));
        }
コード例 #2
0
ファイル: Map.cs プロジェクト: phantomeis/wzmapeditor
 public void Delete(MapItem item)
 {
     if (item is MapLife)
     {
         MapLife l = (MapLife)item;
         if (lifes.Contains(l))
         {
             lifes.Remove(l);
             map.GetChild("life").childs.Remove(l.Object.Name);
             Map.Pad(map.GetChild("life"), lifes.ToArray());
         }
     }
     else if (item is MapReactor)
     {
         MapReactor r = (MapReactor)item;
         if (reactors.Contains(r))
         {
             reactors.Remove(r);
             map.GetChild("reactor").childs.Remove(r.Object.Name);
             Map.Pad(map.GetChild("reactor"), reactors.ToArray());
         }
     }
     else if (item is MapLR)
     {
         MapLR l = (MapLR)item;
         if (lrs.Contains(l))
         {
             lrs.Remove(l);
             map.GetChild("ladderRope").childs.Remove(l.Object.Name);
             Map.Pad(map.GetChild("ladderRope"), lrs.ToArray(), 1);
         }
     }
     else if (item is MapSeat)
     {
         MapSeat s = (MapSeat)item;
         if (seats.Contains(s))
         {
             seats.Remove(s);
             map.GetChild("seat").childs.Remove(s.Object.Name);
             Map.Pad(map.GetChild("seat"), seats.ToArray());
         }
     }
     else if (item is MapPortal)
     {
         MapPortal p = (MapPortal)item;
         if (portals.Contains(p))
         {
             portals.Remove(p);
             map.GetChild("portal").childs.Remove(p.Object.Name);
             Map.Pad(map.GetChild("portal"), portals.ToArray());
             // TODO SORT
         }
     }
     else if (item is MapToolTip)
     {
         MapToolTip t = (MapToolTip)item;
         if (tooltips.Contains(t))
         {
             tooltips.Remove(t);
             map.GetChild("ToolTip").childs.Remove(t.Object.Name);
             t.Image.parent.childs.Remove(t.Object.Name);
             Map.Pad(map.GetChild("ToolTip"), t.Image.parent, tooltips.ToArray());
         }
     }
     else if (item is MapToolTipCorner)
     {
         Delete(((MapToolTipCorner)item).ToolTip);
     }
     else if (item is MapClock)
     {
         if (clock != null)
         {
             map.childs.Remove("clock");
             clock = null;
         }
     }
     else
     {
         layers[(int)MapEditor.Instance.Layer.Value].Delete(item);
     }
 }
コード例 #3
0
ファイル: Map.cs プロジェクト: phantomeis/wzmapeditor
 public void Add(MapItem item)
 {
     if (item is MapLife)
     {
         MapLife  l  = (MapLife)item;
         int      id = 0;
         IMGEntry le = map.GetChild("life");
         if (le == null)
         {
             le      = new IMGEntry();
             le.Name = "life";
             Map.Instance.map.Add(le);
         }
         while (le.childs.Contains(id.ToString()))
         {
             id++;
         }
         l.ID          = id;
         l.Object.Name = l.ID.ToString();
         lifes.Add(l);
         lifes.Sort(Map.CompareItems);
         le.Add(l.Object);
     }
     else if (item is MapReactor)
     {
         MapReactor r  = (MapReactor)item;
         int        id = 0;
         IMGEntry   re = map.GetChild("reactor");
         if (re == null)
         {
             re      = new IMGEntry();
             re.Name = "reactor";
             Map.Instance.map.Add(re);
         }
         while (re.childs.Contains(id.ToString()))
         {
             id++;
         }
         r.ID          = id;
         r.Object.Name = r.ID.ToString();
         reactors.Add(r);
         reactors.Sort(Map.CompareItems);
         re.Add(r.Object);
     }
     else if (item is MapLR)
     {
         MapLR    l    = (MapLR)item;
         int      id   = 1;
         IMGEntry lrse = map.GetChild("ladderRope");
         if (lrse == null)
         {
             lrse      = new IMGEntry();
             lrse.Name = "ladderRope";
             Map.Instance.map.Add(lrse);
         }
         while (lrse.childs.Contains(id.ToString()))
         {
             id++;
         }
         l.ID          = id;
         l.Object.Name = l.ID.ToString();
         lrs.Add(l);
         lrs.Sort(Map.CompareItems);
         lrse.Add(l.Object);
     }
     else if (item is MapSeat)
     {
         MapSeat  s     = (MapSeat)item;
         int      id    = 0;
         IMGEntry seate = map.GetChild("seat");
         if (seate == null)
         {
             seate      = new IMGEntry();
             seate.Name = "seat";
             Map.Instance.map.Add(seate);
         }
         while (seate.childs.Contains(id.ToString()))
         {
             id++;
         }
         s.ID          = id;
         s.Object.Name = s.ID.ToString();
         seats.Add(s);
         seats.Sort(Map.CompareItems);
         seate.Add(s.Object);
     }
     else if (item is MapPortal)
     {
         MapPortal p        = (MapPortal)item;
         int       id       = 0;
         IMGEntry  portalse = map.GetChild("portal");
         if (portalse == null)
         {
             portalse      = new IMGEntry();
             portalse.Name = "portal";
             Map.Instance.map.Add(portalse);
         }
         while (portalse.childs.Contains(id.ToString()))
         {
             id++;
         }
         p.ID          = id;
         p.Object.Name = p.ID.ToString();
         p.Image       = MapEditor.file.Directory.GetIMG("MapHelper.img").GetChild("portal/game/pv/0");
         portals.Add(p);
         portals.Sort(Map.CompareItems);
         portalse.Add(p.Object);
     }
     else if (item is MapToolTip)
     {
         MapToolTip t        = (MapToolTip)item;
         int        id       = 0;
         IMGEntry   ToolTips = map.GetChild("ToolTip");
         if (ToolTips == null)
         {
             ToolTips      = new IMGEntry();
             ToolTips.Name = "ToolTip";
             Map.Instance.map.Add(ToolTips);
         }
         while (ToolTips.childs.Contains(id.ToString()))
         {
             id++;
         }
         t.ID          = id;
         t.Object.Name = t.ID.ToString();
         tooltips.Add(t);
         tooltips.Sort(Map.CompareItems);
         ToolTips.Add(t.Object);
     }
     else if (item is MapClock)
     {
         if (clock == null)
         {
             clock             = item as MapClock;
             clock.Object.Name = "clock";
             clock.Image       = MapEditor.file.Directory.GetIMG("Obj/etc.img").GetChild("clock/fontTime");
             map.Add(clock.Object);
         }
     }
     else
     {
         layers[(int)MapEditor.Instance.Layer.Value].Add(item);
     }
 }
コード例 #4
0
ファイル: Map.cs プロジェクト: smolson4/wzmapeditor
 public Point GetLifeDesignPosition(MapLife life)
 {
     int x = life.Object.GetInt("x");
     int cy = life.Object.GetInt("cy");
     double minDis = 0;
     int fhid = 0, y = 0;
     foreach (MapLayer l in layers)
     {
         foreach (MapFootholds f in l.footholdGroups.Values)
         {
             foreach (MapFoothold fh in f.footholds.Values)
             {
                 int x1 = fh.Object.GetInt("x1");
                 int y1 = fh.Object.GetInt("y1");
                 int x2 = fh.Object.GetInt("x2");
                 int y2 = fh.Object.GetInt("y2");
                 if ((x >= x1 && x <= x2) || (x >= x2 && x <= x1))
                 {
                     double nY = (double)(y1 - y2) / (x1 - x2) * (x - x1) + y1;
                     double dis = Math.Abs(nY - cy);
                     if ((fhid == 0 || dis < minDis) && dis <= 10)
                     {
                         minDis = dis;
                         fhid = fh.ID;
                         y = (int)nY;
                     }
                 }
             }
         }
     }
     return new Point(y, fhid);
 }