예제 #1
0
파일: MapleInfo.cs 프로젝트: xnum/hasuite
        public override BoardItem CreateInstance(Layer layer, Board board, int x, int y, int z, bool flip, bool beforeAdding)
        {
            TileInstance instance = new TileInstance(this, layer, board, x, y, z, beforeAdding);

            ParseOffsets(instance, board, layer, x, y);
            return(instance);
        }
예제 #2
0
        public void DoSnap()
        {
            TileSnapGroup tilegroup       = (TileSnapGroup)TileSnap.tileCats[baseInfo.u];
            double        closestDistance = 201d;
            TileInstance  closestTile     = null;
            TileSnapInfo  closestInfo     = null;

            foreach (BoardItem item in Board.BoardItems)
            {
                if (item is TileInstance)
                {
                    if (item.Selected || item.Equals(this))
                    {
                        continue;
                    }
                    TileInstance tile = (TileInstance)item;
                    int          dx = tile.X - this.X, dy = tile.Y - this.Y;
                    if (dx > MultiBoard.FirstSnapVerification || dy > MultiBoard.FirstSnapVerification || Math.Sqrt(Math.Pow(dx, 2) + Math.Pow(dy, 2)) > MultiBoard.FirstSnapVerification) //first verification to save time
                    {
                        continue;
                    }
                    foreach (TileSnapInfo snapInfo in tilegroup.tileList)
                    {
                        if (snapInfo.tileCat != tile.baseInfo.u)
                        {
                            continue;
                        }
                        double distance = Math.Sqrt(Math.Pow(this.X - tile.X + snapInfo.snapx, 2) + Math.Pow(this.Y - tile.Y + snapInfo.snapy, 2));
                        if (distance > UserSettings.SnapDistance)
                        {
                            continue;
                        }
                        if (distance < closestDistance)
                        {
                            closestDistance = distance;
                            closestTile     = tile;
                            closestInfo     = snapInfo;
                        }
                    }
                }
            }
            if (closestTile != null)
            {
                Point parentOffs = (Point)this.Parent.BoundItems[this];
                Point snapOffs   = new Point(this.Parent.X + parentOffs.X - (closestTile.X - closestInfo.snapx), this.Parent.Y + parentOffs.Y - (closestTile.Y - closestInfo.snapy));
                foreach (BoardItem item in Board.SelectedItems)
                {
                    if (item.tempParent != null || item.Parent == null)
                    {
                        continue;
                    }
                    parentOffs = (Point)item.Parent.BoundItems[item];
                    item.SnapMove(item.Parent.X + parentOffs.X - snapOffs.X, item.Parent.Y + parentOffs.Y - snapOffs.Y);
                }
                this.SnapMove(closestTile.X - closestInfo.snapx, closestTile.Y - closestInfo.snapy);
            }
        }
예제 #3
0
파일: MapleInfo.cs 프로젝트: xnum/hasuite
        public void ParseOffsets(TileInstance instance, Board board, Layer layer, int x, int y)
        {
            List <FootholdAnchor> anchors = new List <FootholdAnchor>();

            foreach (XNA.Point foothold in footholdOffsets)
            {
                FootholdAnchor anchor = new FootholdAnchor(board, x + foothold.X, y + foothold.Y, layer.LayerNumber, false);
                anchors.Add(anchor);
                board.BoardItems.FHAnchors.Add(anchor);
                instance.BindItem(anchor, foothold);
            }
            for (int i = 0; i < anchors.Count - 1; i++)
            {
                FootholdLine fh = new FootholdLine(board, anchors[i], anchors[i + 1]);
                board.BoardItems.FootholdLines.Add(fh);
            }
        }
예제 #4
0
 public void ReplaceTS(string newTS)
 {
     lock (board.ParentControl)
     {
         foreach (LayeredItem item in items)
         {
             if (item is TileInstance)
             {
                 TileInstance tile     = (TileInstance)item;
                 TileInfo     tileBase = (TileInfo)tile.BaseInfo;
                 TileInfo     tileInfo = TileInfo.GetWithDefaultNo(newTS, tileBase.u, tileBase.no, "0");
                 tile.SetBaseInfo(tileInfo);
             }
         }
     }
     this.tS = newTS;
 }
예제 #5
0
 public BoardItem CreateInstance(Layer layer, Board board, int x, int y, int z, bool flip, bool beforeAdding, bool parseOffsets)
 {
     TileInstance instance = new TileInstance(this, layer, board, x, y, z, beforeAdding);
     if (parseOffsets) ParseOffsets(instance, board, layer, x, y);
     return instance;
 }
예제 #6
0
 public void ParseOffsets(TileInstance instance, Board board, Layer layer, int x, int y)
 {
     List<FootholdAnchor> anchors = new List<FootholdAnchor>();
     foreach (XNA.Point foothold in footholdOffsets)
     {
         FootholdAnchor anchor = new FootholdAnchor(board, x + foothold.X, y + foothold.Y, layer.LayerNumber, false);
         anchors.Add(anchor);
         board.BoardItems.FHAnchors.Add(anchor);
         instance.BindItem(anchor, foothold);
     }
     for (int i = 0; i < anchors.Count - 1; i++)
     {
         FootholdLine fh = new FootholdLine(board, anchors[i], anchors[i + 1]);
         board.BoardItems.FootholdLines.Add(fh);
     }
 }