public void Execute()
 {
     if (side.TopOrLeft is Fireball)
     {
         Fireball fb = (Fireball)side.TopOrLeft;
         fb.collisionEnemy = true;
         goomba.BeFlipped();
         Game.st.DefeatGoomba();
         ScoreAssignments sa = new ScoreAssignments();
         Game.UI.DisplayScore(sa.Goomba, goomba.Location);
     }
     else if (side.BottomOrRight is Fireball)
     {
         Fireball fb = (Fireball)side.BottomOrRight;
         fb.collisionEnemy = true;
         goomba.BeFlipped();
         Game.st.DefeatGoomba();
         ScoreAssignments sa = new ScoreAssignments();
         Game.UI.DisplayScore(sa.Goomba, goomba.Location);
     }
     else
     {
         goomba.Physics.YVelocity = 0;
         MoveGoomba();
     }
 }
示例#2
0
        private void Form1_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Escape)
            {
                Close();
            }

            if (e.KeyCode == Keys.Left || e.KeyCode == Keys.A)
            {
                Mario.left     = true;
                Fireball.left  = true;
                Fireball.right = false;
            }

            if (e.KeyCode == Keys.Right || e.KeyCode == Keys.D)
            {
                Mario.right    = true;
                Fireball.right = true;
                Fireball.left  = false;
            }

            if (!Mario.jump && (e.KeyCode == Keys.Up || e.KeyCode == Keys.W))
            {
                Mario.jump  = true;
                Mario.force = Mario.jumpspeed;
            }

            if (e.KeyCode == Keys.Down || e.KeyCode == Keys.S)
            {
                Mario.crouch = true;
                if (Mario.upgrade != 0)
                {
                    Mario.mario.Size = new Size(Engine.x, Engine.x);
                    Mario.mario.Top += Engine.x;
                }
            }

            if (Mario.upgrade == 2 && e.KeyCode == Keys.Space)
            {
                Fireball f;
                if (Mario.left)
                {
                    f = new Fireball(new Point(Mario.mario.Left, Mario.mario.Bottom - Engine.x));
                }
                else
                {
                    f = new Fireball(new Point(Mario.mario.Right, Mario.mario.Bottom - Engine.x));
                }
                Resources.fireballs.Add(f);
            }
        }
示例#3
0
        internal static void FirballCollisions()
        {
            Fireball usedFireball = null;

            foreach (Fireball f in Resources.fireballs)
            {
                foreach (Control c in form.Controls)
                {
                    if (c is PictureBox && c.Tag == "block" && Math.Abs((c as PictureBox).Left - Mario.mario.Left) <= 20 * x)
                    {
                        if (f.fire.Bounds.IntersectsWith(c.Bounds))
                        {
                            if (BottomCollision(f.fire, c as PictureBox))
                            {
                                f.fire.Top = c.Top - x / 3;
                                f.force    = 9;
                            }
                            else
                            {
                                f.Disappear();
                                usedFireball = f;
                            }
                        }
                    }
                }

                Enemy deadEnemy = null;
                foreach (Enemy en in Resources.levelOneEnemies)
                {
                    if (Math.Abs(en.enemy.Left - Mario.mario.Left) <= 20 * x)
                    {
                        if (f.fire.Bounds.IntersectsWith(en.enemy.Bounds))
                        {
                            en.Die();
                            deadEnemy = en;
                            f.Disappear();
                            usedFireball = f;
                        }
                    }
                }
                if (deadEnemy != null)
                {
                    Resources.levelOneEnemies.Remove(deadEnemy);
                }
            }

            if (usedFireball != null)
            {
                Resources.fireballs.Remove(usedFireball);
            }
        }
 void ShootFireBall(int direction)
 {
     if (Game.Mario.Health() == MarioStateMachine.MarioHealth.Dead)
     {
         return;
     }
     if (currentSize == MarioStateMachine.MarioSize.Fire)
     {
         MarioSoundBoard.Instance.PlayMarioFireball();
         IObject fireBall = ObjectSpriteFactory.Instance.GetFireBall();
         fireBall.Location = Game.Mario.Location + new Vector2(5 * direction, 5);
         Game.objects.Add(fireBall);
         Fireball fb = (Fireball)fireBall;
         fb.physics.XVelocity *= direction;
     }
 }
示例#5
0
 public void Execute()
 {
     if (side.TopOrLeft is Fireball)
     {
         Fireball fb = (Fireball)side.TopOrLeft;
         fb.collisionEnemy = true;
         pirana.KillPirana();
         Game.st.DefeatGoomba();
         ScoreAssignments sa = new ScoreAssignments();
         Game.UI.DisplayScore(sa.Pirana, pirana.Location);
     }
     else if (side.BottomOrRight is Fireball)
     {
         Fireball fb = (Fireball)side.BottomOrRight;
         fb.collisionEnemy = true;
         pirana.KillPirana();
         Game.st.DefeatGoomba();
         ScoreAssignments sa = new ScoreAssignments();
         Game.UI.DisplayScore(sa.Pirana, pirana.Location);
     }
 }
示例#6
0
 public static void UpdateObjects(Game1 game)
 {
     for (int i = 0; i < game.objects.Count; i++)
     {
         if (game.objects[i] is Fireball)
         {
             Fireball fb = (Fireball)game.objects[i];
             if (fb.fireBallJump >= 15 || fb.Location.Y > 224 || fb.collisionBlock || fb.collisionPipe || fb.collisionEnemy)
             {
                 game.objects.RemoveAt(i);
             }
             else
             {
                 game.objects.ElementAt(i).Update();
             }
         }
         else
         {
             game.objects.ElementAt(i).Update();
         }
     }
 }
示例#7
0
 public void Execute()
 {
     if (Object is Fireball)
     {
         Fireball fireBall = (Fireball)Object;
         if (Side is Top)
         {
             //fireBall.physics.YVelocity = 0;
             fireBall.Location          = (new Vector2(fireBall.Location.X, fireBall.Location.Y - Collision.Height));
             fireBall.physics.YVelocity = fireBall.physics.YMinVelocity;
             fireBall.fireBallJump++;
         }
         else if ((Side is Left || Side is Right) && !(block.State is FloorBlockState))
         {
             fireBall.collisionBlock = true;
         }
         else if ((Side is Left || Side is Right) && block.State is FloorBlockState && fireBall.Location.Y > 192)
         {
             fireBall.collisionBlock = true;
         }
     }
 }
 public void Execute()
 {
     if (side.TopOrLeft is Fireball)
     {
         Fireball fb = (Fireball)side.TopOrLeft;
         fb.collisionEnemy = true;
         koopa.KillKoopa();
         Game.st.KoopaFire();
         ScoreAssignments sa = new ScoreAssignments();
         Game.UI.DisplayScore(sa.KoopaFire, koopa.Location);
     }
     else if (side.BottomOrRight is Fireball)
     {
         Fireball fb = (Fireball)side.BottomOrRight;
         fb.collisionEnemy = true;
         koopa.KillKoopa();
         Game.st.KoopaFire();
         ScoreAssignments sa = new ScoreAssignments();
         Game.UI.DisplayScore(sa.KoopaFire, koopa.Location);
     }
     koopa.Physics.YVelocity = 0;
     Movekoopa();
 }
示例#9
0
        internal static void FireballMovements()
        {
            Fireball lostFireball = null;

            foreach (Fireball f in Resources.fireballs)
            {
                if (Math.Abs(f.fire.Left - Mario.mario.Left) <= 18 * x)
                {
                    if (f.currentLeft)
                    {
                        f.fire.Left -= 12;
                    }
                    else
                    {
                        f.fire.Left += 12;
                    }
                }
                else
                {
                    f.Disappear();
                    lostFireball = f;
                }

                f.fire.Top -= f.force;
                f.force    -= 1;
                if (f.force < -Mario.jumpspeed)
                {
                    f.force = -Mario.jumpspeed;
                }
            }

            if (lostFireball != null)
            {
                Resources.fireballs.Remove(lostFireball);
            }
        }
 public void Execute()
 {
     if (fire is Fireball && (objects is SmallPipe || objects is MedPipe || objects is TallPipe))
     {
         Fireball fireBall = (Fireball)fire;
         if (Side is Top)
         {
             //fireBall.physics.YVelocity = 0;
             fireBall.Location          = (new Vector2(fireBall.Location.X, fireBall.Location.Y - Collision.Height));
             fireBall.physics.YVelocity = fireBall.physics.YMinVelocity;
             fireBall.fireBallJump++;
         }
         else if (Side is Left || Side is Right)
         {
             fireBall.Location          = (new Vector2(fireBall.Location.X - Collision.Width, fireBall.Location.Y));
             fireBall.physics.XVelocity = fireBall.physics.XMinVelocity;
             fireBall.collisionPipe     = true;
         }
         else if (Side is Bottom)
         {
             fireBall.collisionPipe = true;
         }
     }
 }