Exemplo n.º 1
0
 public GameInstruction(InstructionType type, GameObject go, GameDirection direction, float value)
 {
     this.type = type;
     this.go = go;
     this.direction = direction;
     this.value = value;
 }
Exemplo n.º 2
0
        private void level_MouseDown(object sender, MouseEventArgs e)
        {
            List<GameObject> gos = world.AllElements;
            bool found = false;
            for (int i = gos.Count - 1; i >= 0; i--)
            {
                GameObject go = gos[i];
                if (go.Hit(e.Y - world.Viewport.Y, e.X - world.Viewport.X))
                {
                    focus = go;

                    moving = true;
                    mouseX = e.X - go.Left;
                    mouseY = e.Y - go.Top;
                    found = true;
                    break;
                }
            }

            if (found)
            {
                // check if current selected object is already in list
                if (Array.IndexOf<object>(properties.SelectedObjects, focus) == -1)
                {
                    // not in list & STRG-Key press
                    if (pressedKeys.Contains(Keys.ControlKey))
                    {
                        if (properties.SelectedObjects.Length == 1 && properties.SelectedObject is LevelSettings)
                        {
                            properties.SelectedObjects = new object[] { focus };
                        }
                        else
                        {
                            object[] selected = properties.SelectedObjects;
                            Array.Resize<object>(ref selected, selected.Length + 1);
                            selected[selected.Length - 1] = focus;

                            properties.SelectedObjects = selected;
                        }

                    }
                    else // no STRG Key - remove selection of other objects, add only one selection to current
                    {
                        properties.SelectedObjects = new object[] { focus };
                    }
                }
                // object selected (in array) & STRG -> remove selection
                else if (pressedKeys.Contains(Keys.ControlKey))
                {
                    List<object> selected = new List<object>(properties.SelectedObjects);
                    selected.Remove(focus);
                    properties.SelectedObjects = selected.ToArray();
                }
            }
            else if (!pressedKeys.Contains(Keys.ControlKey))
            {
                focus = null;
                properties.SelectedObjects = new object[] { };
            }

            startRectangle = new GamePoint(e.X - world.Viewport.X, e.Y - world.Viewport.Y);
        }
Exemplo n.º 3
0
        public Editor()
        {
            InitializeComponent();
            SetStyle(ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint |
            ControlStyles.OptimizedDoubleBuffer, true);

            // extern inits
            drawHandler = GetDraw.DrawHandler(level, this.Update);
            AnimateImage.Refresh = false;
            EditorUI.drawHandler = drawHandler;
            EditorUI.level = level;
            EditorUI.properties = properties;
            TmpFileHandler.BackupFilename = Environment.CurrentDirectory + "\\backup.lrl";

            World defaultWorld = new World();
            tmpHandler = new TmpFileHandler(openFile, saveFile, defaultWorld.Serialize, 5);
            defaultWorld = null;

            defaultContextMenuItems = objectContext.Items.Count;
            curRectangle = Rectangle.Empty;

            focus = null;
            moving = false;
            mouseX = 0;
            mouseY = 0;
            pressedKeys = new List<Keys>();

            #region Images loading
            floorToolStripMenuItem.Image = Image.FromFile(Files.floor_middle);
            floorToolStripButton.Image = Image.FromFile(Files.floor_middle);

            designElementToolStripMenuItem.Image = Image.FromFile(Files.tree);
            treeToolStripMenuItem.Image = Image.FromFile(Files.tree);
            treeToolStripButton.Image = Image.FromFile(Files.tree);

            brickToolStripMenuItem.Image = Image.FromFile(Files.brick_blue);
            brickToolStripButton.Image = Image.FromFile(Files.brick_blue);

            boxToolStripMenuItem.Image = Image.FromFile(Files.box1);
            boxToolStripButton.Image = Image.FromFile(Files.box1); ;

            pipeToolStripMenuItem.Image = Image.FromFile(Files.pipe_green_up);
            pipeToolStripButton.Image = Image.FromFile(Files.pipe_green_up); ;

            pointStarToolStripMenuItem.Image = Image.FromFile(Files.star);
            starToolStripButton.Image = Image.FromFile(Files.star); ;

            platformToolStripMenuItem.Image = Image.FromFile(Files.brick_blue);
            bricksToolStripMenuItem.Image = Image.FromFile(Files.brick_blue);
            bricksToolStripButton.Image = Image.FromFile(Files.brick_blue); ;

            enemyToolStripMenuItem.Image = Image.FromFile(AnimateImage.FirstImageStr(Files.turtle_green));
            turtleToolStripMenuItem.Image = Image.FromFile(AnimateImage.FirstImageStr(Files.turtle_green));
            turtleToolStripButton.Image = Image.FromFile(AnimateImage.FirstImageStr(Files.turtle_green));

            spikaToolStripMenuItem.Image = Image.FromFile(Files.spika_green);
            spikaToolStripButton.Image = Image.FromFile(Files.spika_green); ;

            gumbaToolStripMenuItem.Image = Image.FromFile(AnimateImage.FirstImageStr(Files.gumba_brown));
            gumbaToolStripButton.Image = Image.FromFile(AnimateImage.FirstImageStr(Files.gumba_brown));

            levelEndToolStripMenuItem.Image = Image.FromFile(Files.levelend_house);
            houseToolStripMenuItem.Image = Image.FromFile(Files.levelend_house);
            houseToolStripButton.Image = Image.FromFile(Files.levelend_house); ;

            gameLevelbeginToolStripMenuItem.Image = Image.FromFile(Files.icon_png);
            gameWindowToolStripMenuItem.Image = Image.FromFile(Files.icon_png);

            startGameCurrentToolStripMenuItem.Image = Image.FromFile(Files.icon_png);
            startGameCurrentToolStripButton.Image = Image.FromFile(Files.icon_png);
            #endregion
        }
Exemplo n.º 4
0
 private void addElement(GameObject go)
 {
     addElement(go, false);
 }
Exemplo n.º 5
0
        private void addElement(GameObject go, bool alwaysAddToSelection)
        {
            go.Init(world, GameAI.NullAiEventHandlerMethod);
            world.Add(go);
            drawHandler.Update();

            // focus on it
            if (pressedKeys.Contains(Keys.ControlKey) || alwaysAddToSelection)
            {
                List<object> selected = new List<object>(properties.SelectedObjects);
                if (selected.Contains(world.Settings))
                    selected.Remove(world.Settings);

                selected.Add(go);
                properties.SelectedObjects = selected.ToArray();
            }
            else
            {
                properties.SelectedObjects = new object[] { go };
            }
        }
Exemplo n.º 6
0
 public static void ShowErrorBox(GameObject sender, string message)
 {
     string name = sender.Name == null || sender.Name.Length == 0 ? "" : " (" + sender.Name + ")";
     MessageBox.Show(message, "Editor error - " + sender.GetType().Name + name, MessageBoxButtons.OK, MessageBoxIcon.Information);
 }
Exemplo n.º 7
0
 public void SetLast(GameObject go)
 {
     if (go is Enemy)
     {
         enemies.Remove((Enemy)go);
         enemies.Insert(enemies.Count, (Enemy)go);
     }
     else if (go is StickyElement)
     {
         stickyelements.Remove((StickyElement)go);
         stickyelements.Insert(stickyelements.Count, (StickyElement)go);
     }
 }
Exemplo n.º 8
0
 public void SetFirst(GameObject go)
 {
     if (go is Enemy)
     {
         enemies.Remove((Enemy)go);
         enemies.Insert(0, (Enemy)go);
     }
     else if (go is StickyElement)
     {
         stickyelements.Remove((StickyElement)go).ToString();
         stickyelements.Insert(0, (StickyElement)go);
     }
 }
Exemplo n.º 9
0
 public void Remove(GameObject go)
 {
     if (go is MovingElement) // check first, because MovingElement inherits from StickyElement!
         movingelements.Remove((MovingElement)go);
     else if (go is StickyElement)
         stickyelements.Remove((StickyElement)go);
     else if (go is Enemy)
         enemies.Remove((Enemy)go);
 }
Exemplo n.º 10
0
        // static methods
        public static GameElement WhoIsIt(GameObject go)
        {
            Type go_type = go.GetType();

            if (typeof(MainGameObject).IsAssignableFrom(go_type))
                return GameElement.MGO;
            else if (typeof(Enemy).IsAssignableFrom(go_type))
                return GameElement.Enemy;
            else if (typeof(MovingElement).IsAssignableFrom(go_type))
                return GameElement.MovingElement;
            else
                return GameElement.Unknown;
        }
Exemplo n.º 11
0
 public abstract bool getCrashEvent(GameObject go, GameDirection cidirection);