示例#1
0
 private void EditorFrameMove()
 {
     Point p = new Point(GameEngine.Framework.MousePos.X, GameEngine.Framework.MousePos.Y);
     if (this.curArrowMode == ArrowKeyModes.Scroll)
     {
         if (GameEngine.Framework.KeyDown(GameKey.Left))
         {
             this.screenPos.X -= TileSize.Width;
         }
         else if (GameEngine.Framework.KeyDown(GameKey.Right))
         {
             this.screenPos.X += TileSize.Width;
         }
         else if (GameEngine.Framework.KeyDown(GameKey.Up))
         {
             this.screenPos.Y -= TileSize.Width;
         }
         else if (GameEngine.Framework.KeyDown(GameKey.Down))
         {
             this.screenPos.Y += TileSize.Width;
         }
     }
     else if (this.curArrowMode == ArrowKeyModes.Translate)
     {
         if (GameEngine.Framework.KeyPressed(GameKey.Left))
         {
             this.tileMap.Translate(-1, 0);
         }
         else if (GameEngine.Framework.KeyPressed(GameKey.Right))
         {
             this.tileMap.Translate(1, 0);
         }
         else if (GameEngine.Framework.KeyPressed(GameKey.Up))
         {
             this.tileMap.Translate(0, -1);
         }
         else if (GameEngine.Framework.KeyPressed(GameKey.Down))
         {
             this.tileMap.Translate(0, 1);
         }
     }
     else if (this.curArrowMode == ArrowKeyModes.Tile)
     {
         if (GameEngine.Framework.KeyPressed(GameKey.Left))
         {
             this.curTexture.X--;
             if (this.curTexture.X < 0)
             {
                 this.curTexture.X = 0;
             }
         }
         else if (GameEngine.Framework.KeyPressed(GameKey.Right))
         {
             this.curTexture.X++;
         }
         else if (GameEngine.Framework.KeyPressed(GameKey.Up))
         {
             this.curTexture.Y--;
             if (this.curTexture.Y < 0)
             {
                 this.curTexture.Y = 0;
             }
         }
         else if (GameEngine.Framework.KeyPressed(GameKey.Down))
         {
             this.curTexture.Y++;
             if (this.curTexture.Y < 0)
             {
                 this.curTexture.Y = 0;
             }
         }
     }
     if (!this.allowScrollingOutOfBounds)
     {
         this.SetScreenPos();
     }
     if (this.curEditMode == EditModes.Tiles)
     {
         if ((p.X < 0) || (p.Y < 0))
         {
             this.editorPoint = new Point(0, 0);
         }
         else if ((p.X > 320) || (p.Y > 240))
         {
             this.editorPoint = new Point(0, 0);
         }
         else
         {
             p.X += (int) this.screenPos.X;
             p.Y += (int) this.screenPos.Y;
             this.editorPoint = this.tileMap.GetTileFromPoint(this.editLayer, p);
         }
         if (!GameEngine.Framework.KeyDown("LeftShift"))
         {
             if (((this.editorPoint.X > 0) || (this.editorPoint.Y > 0)) && GameEngine.Framework.MousePressed(0))
             {
                 if ((this.copyRectangleSource.Width > 0) && (this.copyRectangleSource.Height > 0))
                 {
                     for (int i = 0; i <= this.copyRectangleSource.Width; i++)
                     {
                         for (int j = 0; j <= this.copyRectangleSource.Height; j++)
                         {
                             try
                             {
                                 this.curTexture = this.tileMap.GetTile(this.editLayer, this.copyRectangleSource.X + i, this.copyRectangleSource.Y + j);
                                 this.tileMap.SetTile(this.editLayer, this.editorPoint.X + i, this.editorPoint.Y + j, this.curTexture);
                             }
                             catch
                             {
                             }
                         }
                     }
                 }
                 else
                 {
                     this.tileMap.SetTile(this.editLayer, this.editorPoint.X, this.editorPoint.Y, this.curTexture);
                 }
             }
             if (GameEngine.Framework.MousePressed(1))
             {
                 this.curTexture = this.tileMap.GetTile(this.editLayer, this.editorPoint.X, this.editorPoint.Y);
                 this.copyRectangleSource.Width = 0;
                 this.copyRectangleSource.Height = 0;
             }
         }
         else
         {
             if (GameEngine.Framework.MousePressed(1) && !this.copyingRegion)
             {
                 this.copyRectangleSource.X = this.editorPoint.X;
                 this.copyRectangleSource.Y = this.editorPoint.Y;
                 this.copyingRegion = true;
             }
             else if (!GameEngine.Framework.MousePressed(1) && this.copyingRegion)
             {
                 this.copyingRegion = false;
                 this.copyRectangleSource.Width = this.editorPoint.X - this.copyRectangleSource.X;
                 this.copyRectangleSource.Height = this.editorPoint.Y - this.copyRectangleSource.Y;
             }
             if ((GameEngine.Framework.MousePressed(0) && (this.selectionStart.X == 0)) && (this.selectionStart.Y == 0))
             {
                 this.copyRectangleSource.Width = 0;
                 this.copyRectangleSource.Height = 0;
                 this.selectionStart.X = this.editorPoint.X;
                 this.selectionStart.Y = this.editorPoint.Y;
             }
             else if (!GameEngine.Framework.MousePressed(0) && ((this.selectionStart.X != 0) || (this.selectionStart.Y != 0)))
             {
                 this.FillBox(this.selectionStart, this.editorPoint);
                 this.selectionStart.X = 0;
                 this.selectionStart.Y = 0;
             }
         }
     }
     else
     {
         p.X += (int) this.screenPos.X;
         p.Y += (int) this.screenPos.Y;
         if ((GameEngine.Framework.MousePressed(0) && (this.draggingObject == null)) && GameEngine.Framework.KeyDown("LeftAlt"))
         {
             this.draggingObject = this.GetObjectFromPoint(p);
             if (this.draggingObject is Door)
             {
                 GameEngine.Framework.SetEditorDoorInfo((Door) this.draggingObject);
                 this.draggingObject = null;
             }
             if (this.draggingObject is TreasureChest)
             {
                 GameEngine.Framework.SetEditorTreasureInfo((TreasureChest) this.draggingObject);
             }
             if (this.draggingObject is GameObject)
             {
                 GameEngine.Framework.SetEditorObjectInfo((GameObject) this.draggingObject);
                 this.editObject = this.draggingObject;
             }
             if (this.draggingObject is FallingBlock)
             {
                 GameEngine.Framework.SetEditorObjectInfo((FallingBlock) this.draggingObject);
                 this.editObject = this.draggingObject;
             }
             this.draggingObject = null;
         }
         else if (GameEngine.Framework.MousePressed(0) && (this.draggingObject == null))
         {
             this.draggingObject = this.GetObjectFromPoint(p);
             if (this.draggingObject != null)
             {
                 this.dragOffset.X = p.X - ((int) this.draggingObject.Location.X);
                 this.dragOffset.Y = p.Y - ((int) this.draggingObject.Location.Y);
             }
         }
         if (GameEngine.Framework.MousePressed(1) && (this.draggingObject == null))
         {
             this.draggingObject = this.GetObjectFromPoint(p);
             if (this.draggingObject is Door)
             {
                 this.objects.Remove(this.draggingObject);
                 this.doors.Remove((Door) this.draggingObject);
             }
             else if (this.draggingObject is TreasureChest)
             {
                 this.objects.Remove(this.draggingObject);
             }
             else if (this.draggingObject is GameObject)
             {
                 this.deletedObjects.Add((GameObject) this.GetObjectFromPoint(p));
             }
             else
             {
                 this.objects.Remove(this.draggingObject);
             }
             this.draggingObject = null;
         }
         if (this.draggingObject != null)
         {
             if ((this.draggingObject is GameObject) || (this.draggingObject.Type == ObjectType.FallingBlock))
             {
                 this.draggingObject.Location = this.ClosestGridPoint((PointF) p, (PointF) this.dragOffset);
             }
             else
             {
                 this.draggingObject.Location = new PointF((float) (p.X - this.dragOffset.X), (float) (p.Y - this.dragOffset.Y));
             }
             if (!GameEngine.Framework.MousePressed(0))
             {
                 this.draggingObject = null;
             }
         }
     }
 }
示例#2
0
 public void ReplaceObject(ObjectType type, ColorSwaps colorSwap, Direction direction, string itemDrops, int delay)
 {
     if (this.editObject is GameObject)
     {
         PointF location = this.editObject.Location;
         this.objects.Remove(this.editObject);
         this.gameObjects.Remove((GameObject) this.editObject);
         BaseObject obj2 = this.AddObject(type, colorSwap, direction, itemDrops, delay);
         obj2.Location = location;
         this.editObject = obj2;
     }
 }
示例#3
0
 private HelpPageComponent CreatePageComponent(int yPosition, string title, string paragraph, BaseObject o)
 {
     HelpPageComponent component = new HelpPageComponent {
         sectionGraphic = o
     };
     component.sectionGraphic.X = 32f;
     component.sectionGraphic.Y = (yPosition + component.sectionGraphic.GetCollisionRectangle().Height) + 16f;
     component.sectionTitle = new GameText(title);
     component.sectionTitle.TextColor = Color.Red;
     component.sectionTitle.Shadow = false;
     component.sectionTitle.X = 16f;
     component.sectionTitle.Y = yPosition;
     component.sectionParagraph = new GameTextParagraph(paragraph, 0x26 - title.Length);
     component.sectionParagraph.TextColor = Color.White;
     component.sectionParagraph.Location = new Point(((int) component.sectionTitle.X) + (8 * title.Length), yPosition);
     return component;
 }