Ejemplo n.º 1
0
        public void CreateFhAnchor()
        {
            FootholdAnchor fhAnchor = new FootholdAnchor(Board, X, Y, Board.SelectedLayerIndex, false);

            Board.BoardItems.FHAnchors.Add(fhAnchor);
            Board.UndoRedoMan.AddUndoBatch(new List <UndoRedoAction> {
                UndoRedoManager.ItemAdded(fhAnchor)
            });
            if (connectedLines.Count == 0)
            {
                Board.BoardItems.FootholdLines.Add(new FootholdLine(Board, fhAnchor));
            }
            else
            {
                connectedLines[0].ConnectSecondDot(fhAnchor);
                Board.BoardItems.FootholdLines.Add(new FootholdLine(Board, fhAnchor));
            }
        }
Ejemplo n.º 2
0
        public virtual void OnItemPlaced(List<UndoRedoAction> undoPipe)
        {
            lock (Board.ParentControl)
            {
                List<BoardItem> items = boundItems.Keys.ToList();
                foreach (BoardItem item in items)
                    item.OnItemPlaced(undoPipe);

                if (undoPipe != null)
                {
                    undoPipe.Add(UndoRedoManager.ItemAdded(this));
                }
                if (parent != null)
                {
                    if (!(parent is Mouse) && undoPipe != null)
                    {
                        undoPipe.Add(UndoRedoManager.ItemsLinked(parent, this, (Microsoft.Xna.Framework.Point)parent.boundItems[this]));
                    }
                }
            }
        }
Ejemplo n.º 3
0
 public void PlaceObject()
 {
     if (state == MouseState.StaticObjectAdding || state == MouseState.RandomTiles)
     {
         Board.UndoRedoMan.AddUndoBatch(new List <UndoRedoAction>()
         {
             UndoRedoManager.ItemAdded(currAddedObj)
         });
         //Board.BoardItems.Add(currAddedObj.CreateInstance(Board.Layers[Board.SelectedLayerIndex], Board, x, y, 50, false, false));
         currAddedObj.BeforeAdding = false;
         ReleaseItem(currAddedObj);
         if (currAddedObj is LayeredItem)
         {
             int highestZ = 0;
             foreach (LayeredItem item in Board.BoardItems.TileObjs)
             {
                 if (item.Z > highestZ)
                 {
                     highestZ = item.Z;
                 }
             }
             currAddedObj.Z = highestZ;
             Board.BoardItems.Sort();
         }
         if (state == MouseState.StaticObjectAdding)
         {
             currAddedObj = currAddedInfo.CreateInstance(Board.SelectedLayer, Board, X + currAddedInfo.Origin.X - currAddedInfo.Image.Width / 2, Y + currAddedInfo.Origin.Y - currAddedInfo.Image.Height / 2, 50, false, true);
         }
         else
         {
             currAddedObj = tileRandomList[NextInt32(tileRandomList.Length)].CreateInstance(Board.SelectedLayer, Board, X + currAddedInfo.Origin.X - currAddedInfo.Image.Width / 2, Y + currAddedInfo.Origin.Y - currAddedInfo.Image.Height / 2, 50, false, true);
         }
         Board.BoardItems.Add(currAddedObj, false);
         BindItem(currAddedObj, new Microsoft.Xna.Framework.Point(currAddedInfo.Origin.X - currAddedInfo.Image.Width / 2, currAddedInfo.Origin.Y - currAddedInfo.Image.Height / 2));
     }
     else if (state == MouseState.Chairs)
     {
         Board.UndoRedoMan.AddUndoBatch(new List <UndoRedoAction> {
             UndoRedoManager.ItemAdded(currAddedObj)
         });
         ReleaseItem(currAddedObj);
         currAddedObj = new Chair(Board, X, Y, true);
         Board.BoardItems.Add(currAddedObj, false);
         BindItem(currAddedObj, new Microsoft.Xna.Framework.Point());
     }
     else if (state == MouseState.Ropes)
     {
         int      count = BoundItems.Count;
         object[] keys  = new object[count];
         BoundItems.Keys.CopyTo(keys, 0);
         RopeAnchor anchor = (RopeAnchor)keys[0];
         ReleaseItem(anchor);
         if (count == 1)
         {
             Board.UndoRedoMan.AddUndoBatch(new List <UndoRedoAction> {
                 UndoRedoManager.RopeAdded(anchor.ParentRope)
             });
             CreateRope();
         }
     }
     else if (state == MouseState.Tooltip)
     {
         int      count = BoundItems.Count;
         object[] keys  = new object[count];
         BoundItems.Keys.CopyTo(keys, 0);
         ToolTipDot dot = (ToolTipDot)keys[0];
         ReleaseItem(dot);
         if (count == 1)
         {
             Board.UndoRedoMan.AddUndoBatch(new List <UndoRedoAction> {
                 UndoRedoManager.ItemAdded(dot.ParentTooltip)
             });
             CreateTooltip();
         }
     }
 }