Beispiel #1
0
 public void UpdatePosition(GameTime gameTime, ref ScreenManager Screenmanager, ref Mario mario)
 {
     if (LifeSpan < 2)
     {
         return;
     }
     Moving = "False";
     if (Keyboard.GetState().IsKeyDown(Keys.Right))
     {
         Position.X += 4;
         Direction   = "Right";
         Moving      = "True";
     }
     if (Keyboard.GetState().IsKeyDown(Keys.Left))
     {
         Position.X -= 4;
         Direction   = "Left";
         Moving      = "True";
     }
     if (Keyboard.GetState().IsKeyDown(Keys.Up))
     {
         if (Jumping == "False")
         {
             if (this.GetType() == typeof(MarioSmall))
             {
                 Content.Load <SoundEffect>("JumpSmall").Play();
             }
             else
             {
                 Content.Load <SoundEffect>("JumpSuper").Play();
             }
             Jumping = "True";
             Gravity = -20;
         }
     }
     if (Jumping == "True")
     {
         Position.Y += Gravity;
         Gravity++;
     }
     if (Position.X <= 0)
     {
         Screenmanager.Backward();
     }
     if (Position.X + Width >= 800)
     {
         Screenmanager.Forward();
     }
     if (Position.Y > 456)
     {
         mario.Mariostate = new MarioSmall(Content, mario.Mariostate.Position, 35, 40);
         mario.Destroy();
     }
 }
Beispiel #2
0
 public static void CollideEnemies(GameTime gameTIme, ref Mario mario, ref EnemyManager Enemymanager, ContentManager Content)
 {
     for (int i = 0; i < Enemymanager.Enemies.Count; i++)
     {
         if (mario == null)
         {
             return;
         }
         if (mario.Mariostate.LifeSpan < 2)
         {
             return;
         }
         if (Enemymanager.Enemies[i] == null)
         {
             continue;
         }
         if (Enemymanager.Enemies[i].LifeSpan == 0)
         {
             Enemymanager.Enemies[i] = null;
             continue;
         }
         if (mario.Bounds.Intersects(Enemymanager.Enemies[i].Bounds))
         {
             if (Enemymanager.Enemies[i].GetType() == typeof(Gumba) && Enemymanager.Enemies[i].LifeSpan == 2)
             {
                 if (mario.Mariostate.Jumping == "True" && mario.Mariostate.Position.Y < Enemymanager.Enemies[i].Position.Y)
                 {
                     Enemymanager.Enemies[i].Destroy();
                     int TempGravity = mario.Mariostate.Gravity;
                     mario.Mariostate.Gravity     = -TempGravity + (TempGravity / 2);
                     mario.Mariostate.Position.Y -= 10;
                     Content.Load <SoundEffect>("Kick").Play();
                 }
                 else if (mario.Mariostate.Vibrating == false)
                 {
                     string Direction = mario.Mariostate.Direction;
                     if (mario.Mariostate.GetType() == typeof(MarioFire))
                     {
                         mario.Mariostate           = new MarioBig(Content, new Vector2(mario.Bounds.X, mario.Bounds.Y), 45, 78);
                         mario.Mariostate.Direction = Direction;
                         mario.Mariostate.Vibrating = true;
                         Content.Load <SoundEffect>("Shrink").Play();
                     }
                     else if (mario.Mariostate.GetType() == typeof(MarioBig))
                     {
                         mario.Mariostate           = new MarioSmall(Content, new Vector2(mario.Bounds.X, mario.Bounds.Y + 38), 35, 40);
                         mario.Mariostate.Direction = Direction;
                         mario.Mariostate.Vibrating = true;
                         Content.Load <SoundEffect>("Shrink").Play();
                     }
                     else
                     {
                         mario.Destroy();
                     }
                 }
             }
             else if (Enemymanager.Enemies[i].GetType() == typeof(Spiny) || Enemymanager.Enemies[i].GetType() == typeof(BillBlasterBullet))
             {
                 if (Enemymanager.Enemies[i].GetType() == typeof(BillBlasterBullet) && mario.Mariostate.Landing == "BillBlaster")
                 {
                     continue;
                 }
                 if (mario.Mariostate.Vibrating == false)
                 {
                     string Direction = mario.Mariostate.Direction;
                     if (mario.Mariostate.GetType() == typeof(MarioFire))
                     {
                         mario.Mariostate           = new MarioBig(Content, new Vector2(mario.Bounds.X, mario.Bounds.Y), 45, 78);
                         mario.Mariostate.Direction = Direction;
                         mario.Mariostate.Vibrating = true;
                         Content.Load <SoundEffect>("Shrink").Play();
                     }
                     else if (mario.Mariostate.GetType() == typeof(MarioBig))
                     {
                         mario.Mariostate           = new MarioSmall(Content, new Vector2(mario.Bounds.X, mario.Bounds.Y + 38), 35, 40);
                         mario.Mariostate.Direction = Direction;
                         mario.Mariostate.Vibrating = true;
                         Content.Load <SoundEffect>("Shrink").Play();
                     }
                     else
                     {
                         mario.Destroy();
                     }
                 }
             }
             else if (Enemymanager.Enemies[i].GetType() == typeof(Plant))
             {
                 if (mario.Mariostate.Vibrating == false)
                 {
                     string Direction = mario.Mariostate.Direction;
                     if (mario.Mariostate.GetType() == typeof(MarioFire))
                     {
                         mario.Mariostate           = new MarioBig(Content, new Vector2(mario.Bounds.X, mario.Bounds.Y), 45, 78);
                         mario.Mariostate.Direction = Direction;
                         mario.Mariostate.Vibrating = true;
                         Content.Load <SoundEffect>("Shrink").Play();
                     }
                     else if (mario.Mariostate.GetType() == typeof(MarioBig))
                     {
                         mario.Mariostate           = new MarioSmall(Content, new Vector2(mario.Bounds.X, mario.Bounds.Y + 38), 35, 40);
                         mario.Mariostate.Direction = Direction;
                         mario.Mariostate.Vibrating = true;
                         Content.Load <SoundEffect>("Shrink").Play();
                     }
                     else
                     {
                         mario.Destroy();
                     }
                 }
             }
             else if (Enemymanager.Enemies[i].GetType() == typeof(Duck))
             {
                 if (mario.Mariostate.Vibrating == false)
                 {
                     if (mario.Mariostate.Jumping == "True")
                     {
                         int TempGravity = mario.Mariostate.Gravity;
                         mario.Mariostate.Gravity     = -TempGravity + (TempGravity / 2);
                         mario.Mariostate.Position.Y -= 10;
                         if (Enemymanager.Enemies[i].LifeSpan > 3)
                         {
                             Enemymanager.Enemies[i].LifeSpan = 3;
                         }
                         else
                         {
                             Enemymanager.Enemies[i] = null;
                         }
                         Content.Load <SoundEffect>("Kick").Play();
                     }
                     else if (mario.Mariostate.GetType() == typeof(MarioFire))
                     {
                         if (Enemymanager.Enemies[i].LifeSpan == 3)
                         {
                             if (mario.Mariostate.Position.X <= Enemymanager.Enemies[i].Position.X)
                             {
                                 Enemymanager.Enemies[i].LifeSpan    = 2;
                                 Enemymanager.Enemies[i].Direction   = "Right";
                                 Enemymanager.Enemies[i].Position.X += 7;
                             }
                             else
                             {
                                 Enemymanager.Enemies[i].LifeSpan    = 1;
                                 Enemymanager.Enemies[i].Direction   = "Left";
                                 Enemymanager.Enemies[i].Position.X -= 7;
                             }
                         }
                         else
                         {
                             mario.Mariostate           = new MarioBig(Content, new Vector2(mario.Bounds.X, mario.Bounds.Y), 45, 78);
                             mario.Mariostate.Vibrating = true;
                             Content.Load <SoundEffect>("Shrink").Play();
                         }
                     }
                     else if (mario.Mariostate.GetType() == typeof(MarioBig))
                     {
                         if (Enemymanager.Enemies[i].LifeSpan == 3)
                         {
                             if (mario.Mariostate.Position.X <= Enemymanager.Enemies[i].Position.X)
                             {
                                 Enemymanager.Enemies[i].LifeSpan    = 2;
                                 Enemymanager.Enemies[i].Direction   = "Right";
                                 Enemymanager.Enemies[i].Position.X += 7;
                             }
                             else
                             {
                                 Enemymanager.Enemies[i].LifeSpan    = 1;
                                 Enemymanager.Enemies[i].Direction   = "Left";
                                 Enemymanager.Enemies[i].Position.X -= 7;
                             }
                         }
                         else
                         {
                             mario.Mariostate           = new MarioSmall(Content, new Vector2(mario.Bounds.X, mario.Bounds.Y + 38), 35, 40);
                             mario.Mariostate.Vibrating = true;
                             Content.Load <SoundEffect>("Shrink").Play();
                         }
                     }
                     else
                     {
                         if (Enemymanager.Enemies[i].LifeSpan == 3)
                         {
                             if (mario.Mariostate.Position.X <= Enemymanager.Enemies[i].Position.X)
                             {
                                 Enemymanager.Enemies[i].LifeSpan    = 2;
                                 Enemymanager.Enemies[i].Direction   = "Right";
                                 Enemymanager.Enemies[i].Position.X += 7;
                             }
                             else
                             {
                                 Enemymanager.Enemies[i].LifeSpan    = 1;
                                 Enemymanager.Enemies[i].Direction   = "Left";
                                 Enemymanager.Enemies[i].Position.X -= 7;
                             }
                         }
                         else
                         {
                             mario.Destroy();
                         }
                     }
                 }
             }
         }
     }
 }