Пример #1
0
        private void addObject(object sender, EventArgs e)
        {
            // Calculate the pressed X and Y coords
            int x = (int)Math.Floor((Cursor.Position.X - this.Location.X) / (this.Size.Width / 40.00));
            int y = (int)Math.Floor((Cursor.Position.Y - this.Location.Y) / (this.Size.Height / 20.00));

            if (doesCoordsAlreadyContainObject(x, y))
            {

                //Checks if player exists to prevent an Object not found error (3 lines down)
                if (this.world.player != null)
                {
                    if (new Model.Point(x, y).Equals(this.world.player.positions.current_position) && this.items.getMode() != "SelectTool")
                    {
                        deleteSpecificObject(x, y);
                    }
                    else
                    {
                        if (this.items.getMode() == "SelectTool")
                        {
                            this.MouseDownLeftTimer.Stop();
                            this.items.setValueAfterSelectClick(getObjectFromCoords(x, y));
                        }
                        else
                        {
                            if (this.items.getMode() != "Geen")
                            {
                                deleteSpecificObject(x, y);
                            }

                        }
                    }
                }
                else
                {
                    if (this.items.getMode() == "SelectTool")
                    {
                        this.MouseDownLeftTimer.Stop();
                        this.items.setValueAfterSelectClick(getObjectFromCoords(x,y));
                    }
                    else
                    {
                        if (this.items.getMode() != "Geen")
                        {
                            deleteSpecificObject(x, y);
                        }
                    }
                }

            }

            // Make sure something is selected
            if (this.items.isSelected())
            {
                if (this.items.getMode() == "FieldObject")
                {
                    Obstacle fieldObject = this.items.getActive<Obstacle>().clone();
                    fieldObject.x = (int)(x);
                    fieldObject.y = (int)(y);
                    this.world.obstacles.Add(fieldObject);
                }
                if (this.items.getMode() == "PURun")
                {
                    Powerups powerUp = this.items.getActive<Powerups>().clone();
                    powerUp.x = (int)(x);
                    powerUp.y = (int)(y);
                    this.world.powerups.Add(powerUp);
                }
                if (this.items.getMode() == "PUScore")
                {
                    Powerups powerUp = this.items.getActive<Powerups>().clone();
                    powerUp.x = (int)(x);
                    powerUp.y = (int)(y);
                    this.world.powerups.Add(powerUp);
                }

                if (this.items.getMode() == "PUEMP")
                {
                    Powerups powerUp = this.items.getActive<Powerups>().clone();
                    powerUp.x = (int)(x);
                    powerUp.y = (int)(y);
                    this.world.powerups.Add(powerUp);
                }

                if (this.items.getMode() == "WorldGround")
                {
                    Obstacle fieldObject = this.items.getActive<Obstacle>().clone();
                    fieldObject.x = (int)(x);
                    fieldObject.y = (int)(y);
                    this.world.obstacles.Add(fieldObject);
                }

                if (this.items.getMode() == "HBouncer")
                {
                    Npc npc = this.items.getActive<Npc>().clone();
                    npc.positions.current_position = new Model.Point((int)(x), (int)(y));
                    npc.speed = new Model.Point(1, 1);
                    this.world.npcs.Add(npc);
                }

                if (this.items.getMode() == "VBouncer")
                {
                    Npc npc = this.items.getActive<Npc>().clone();
                    npc.positions.current_position = new Model.Point((int)(x), (int)(y));
                    npc.speed = new Model.Point(1, 1);
                    this.world.npcs.Add(npc);
                }

                if (this.items.getMode() == "Enemy")
                {
                    Npc npc = this.items.getActive<Npc>().clone();
                    npc.positions.current_position = new Model.Point((int)(x), (int)(y));
                    npc.speed = new Model.Point(1, 1);
                    this.world.npcs.Add(npc);
                }

                if (this.items.getMode() == "SSB" && this.bomberCount == 0)
                {
                    Npc npc = this.items.getActive<Npc>().clone();
                    npc.positions.current_position = new Model.Point((int)(x), (int)(y));
                    npc.speed = new Model.Point(1, 1);
                    this.world.npcs.Add(npc);
                    this.bomberCount = 1;
                }else if (this.items.getMode() == "SSB" && this.bomberCount > 0)
                {
                    this.MouseDownLeftTimer.Stop();
                    DialogResult dialogResult = MessageBox.Show("This level already contains a suicide bomber.", "Overwrite?", MessageBoxButtons.YesNo);
                    if (dialogResult == DialogResult.Yes)
                    {
                        Npc tempnpc = new Npc();
                        foreach (Npc ssber in this.world.npcs)
                        {
                            if (ssber.type == Npc.Type.SuicideBomber)
                            {
                                tempnpc = ssber;
                            }
                        }
                        this.world.npcs.Remove(tempnpc);
                        Npc npc = this.items.getActive<Npc>().clone();
                        npc.positions.current_position = new Model.Point((int)(x), (int)(y));
                        npc.speed = new Model.Point(1, 1);
                        this.world.npcs.Add(npc);
                    }
                }

                if (this.items.getMode() == "EndGame" && this.finishCount == 0)
                {
                    Finish finish = this.items.getActive<Finish>().clone();
                    finish.x = (int)(x);
                    finish.y = (int)(y);
                    this.world.finish = finish;
                    this.finishCount = 1;
                }
                else if (this.items.getMode() == "EndGame" && this.finishCount > 0)
                {
                    this.MouseDownLeftTimer.Stop();
                    DialogResult dialogResult = MessageBox.Show("This level already contains an finish, do you want to overwrite it?", "Overwrite finish?", MessageBoxButtons.YesNo);
                    if (dialogResult == DialogResult.Yes)
                    {
                        Finish finish = this.items.getActive<Finish>().clone();
                        finish.x = (int)(x);
                        finish.y = (int)(y);
                        this.world.finish = finish;
                    }

                }

                if (this.items.getMode() == "Player" && this.playerCount == 0)
                {
                    this.world.player = this.items.getActive<Model.Player>().clone();
                    this.world.player.positions.current_position = new Model.Point(x, y);
                    this.world.player.movement.walk = new Model.Point(2, 2);
                    this.world.player.movement.run = new Model.Point(5, 5);
                    this.world.player.speed = new Model.Point(3, 3);
                    this.world.player.sizeBreedte = (int)cellSizeX;
                    this.world.player.sizeHoogte = (int)cellSizeY;
                    this.playerCount = 1;
                }
                else if (this.items.getMode() == "Player" && this.playerCount > 0)
                {
                    this.MouseDownLeftTimer.Stop();
                    DialogResult dialogResult = MessageBox.Show("This level already contains an player, do you want to overwrite?", "Overwrite player?", MessageBoxButtons.YesNo);
                    if (dialogResult == DialogResult.Yes)
                    {
                        this.world.player = this.items.getActive<Model.Player>().clone();
                        this.world.player.positions.current_position = new Model.Point((int)(x), (int)(y));
                        this.world.player.movement.walk = new Model.Point(2, 2);
                        this.world.player.movement.run = new Model.Point(5, 5);
                        this.world.player.speed = new Model.Point(3, 3);
                        this.world.player.sizeBreedte = (int)cellSizeX;
                        this.world.player.sizeHoogte = (int)cellSizeY;
                    }
                }
            }
            this.Invalidate();
        }
Пример #2
0
        private void playExplosion(object sender, EventArgs e)
        {
            this.isExploding = true;
            this.world.player.isVisible = false;
            isSSBVisible = false;

            if (explosionState < this.SSBExplosionSpriteList.Count - 1)
            {
                this.explosionState++;
                if (explosionState == 6)
                {
                    this.world.player.isVisible = false;
                    Npc SSBer = new Npc();
                    foreach (Npc npcs in this.world.npcs)
                    {
                        if (npcs.type == Npc.Type.SuicideBomber)
                        {
                            SSBer = npcs;
                        }
                    }
                    this.world.npcs.Remove(SSBer);
                }
            }
            else
            {
                this.isExploding = false;
                this.world.getScore().score = 0;
                this.SSBExplosion.Stop();
            }
            this.Invalidate();
        }