Ejemplo n.º 1
0
 public void Handle(ICollidable player, ICollidable koopa, CollisionDirection.DirectionTag direction)
 {
     if (player.GetType() == typeof(Mario) && koopa.GetType() == typeof(Koopa))
     {
         this.player     = (Mario)player;
         this.koopa      = (Koopa)koopa;
         this.koopaShell = new KoopaShell(this.koopa.Location());
         if (direction == CollisionDirection.DirectionTag.Top)
         {
             this.player.Physics.yPosition  = this.koopa.GetTopSide() - this.player.GetHeight();
             this.player.Physics.yVelocity *= -1;
             GameManager.Instance.Replace(this.koopa, koopaShell);
             koopaShell.Still();
         }
         else if (direction == CollisionDirection.DirectionTag.Bottom ||
                  direction == CollisionDirection.DirectionTag.Left ||
                  direction == CollisionDirection.DirectionTag.Right)
         {
             if (this.player.IsBig() || this.player.IsFire())
             {
                 this.player.TakeDamage();
             }
             else if (this.player.IsSmall())
             {
                 this.player.TakeDamage();
             }
             else
             {
                 GameManager.Instance.Replace(this.koopa, koopaShell);
                 koopaShell.Fall();
             }
         }
     }
 }
Ejemplo n.º 2
0
 public void Handle(ICollidable player, ICollidable koopaShell, CollisionDirection.DirectionTag direction)
 {
     if (typeof(Mario).IsInstanceOfType(player) && typeof(KoopaShell).IsInstanceOfType(koopaShell))
     {
         this.player        = (Mario)player;
         this.koopaShell    = (KoopaShell)koopaShell;
         reversedKoopaShell = new ReversedKoopaShell(this.koopaShell.Location());
         //when mario is star
         if (!this.player.IsBig() && !this.player.IsFire() && !this.player.IsSmall())
         {
             this.player.Boost();
             GameManager.Instance.Replace(this.koopaShell, reversedKoopaShell);
         }
         else
         {
             if (direction == CollisionDirection.DirectionTag.Left)
             {
                 this.player.TakeDamage();
             }
             else if (direction == CollisionDirection.DirectionTag.Right)
             {
                 this.player.TakeDamage();
             }
             if (direction == CollisionDirection.DirectionTag.Top)
             {
                 this.player.Boost();
                 this.player.Physics.yPosition  = this.koopaShell.GetTopSide() - this.player.GetHeight();
                 this.player.Physics.yVelocity *= -1;
             }
             SoundEffectManager.Instance.PlaySoundEffect(SoundEffectManager.SoundEffectTag.Kick);
         }
     }
     if (typeof(StarMario).IsInstanceOfType(player))
     {
         ((StarMario)player).Boost();
         reversedKoopaShell = new ReversedKoopaShell(((KoopaShell)koopaShell).Location());
         GameManager.Instance.Replace((KoopaShell)koopaShell, reversedKoopaShell);
     }
 }
Ejemplo n.º 3
0
 public void Handle(ICollidable player, ICollidable koopaShell, CollisionDirection.DirectionTag direction)
 {
     if (typeof(Mario).IsInstanceOfType(player) && typeof(KoopaShell).IsInstanceOfType(koopaShell))
     {
         this.player     = (Mario)player;
         this.koopaShell = (KoopaShell)koopaShell;
         if (direction == CollisionDirection.DirectionTag.Left)
         {
             this.koopaShell.Kick();
         }
         else if (direction == CollisionDirection.DirectionTag.Right)
         {
             this.koopaShell.Kick();
             this.koopaShell.ChangeDirection();
         }
         else if (direction == CollisionDirection.DirectionTag.Top)
         {
             this.player.Physics.yPosition  = this.koopaShell.GetTopSide() - this.player.GetHeight();
             this.player.Physics.yVelocity *= -1;
         }
         SoundEffectManager.Instance.PlaySoundEffect(SoundEffectManager.SoundEffectTag.Kick);
     }
 }
Ejemplo n.º 4
0
 private void OnTriggerEnter2D(Collider2D c)
 {
     if (c.tag == "Enemy Barrier")
     {
         Debug.Log("Programmer Log: " + gameObject.name + " collided with " + c.gameObject.tag);
         moveValue = -moveValue;
         flip();
     }
     else if (c.tag == "Player")
     {
         if (!isShell)
         {
             anim.Play("Koopa_Shell");
             toggleShell();
         }
         else
         {
             playSound(deathSFX);
             KoopaShell temp = Instantiate(koopaShellPrefab, transform.position, transform.rotation);
             Destroy(gameObject);
             temp.moving = true;
         }
     }
 }
Ejemplo n.º 5
0
 public KoopaShellController(KoopaShell e)
     : base(e)
 {
     //---
 }
Ejemplo n.º 6
0
 public void Handle(ICollidable player, ICollidable koopa, CollisionDirection.DirectionTag direction)
 {
     if (player.GetType() == typeof(Mario) && koopa.GetType() == typeof(Koopa))
     {
         this.player        = (Mario)player;
         this.koopa         = (Koopa)koopa;
         reversedKoopaShell = new ReversedKoopaShell(this.koopa.Location());
         if (this.koopa.Physics.xVelocity == 0)
         {
             if (direction == CollisionDirection.DirectionTag.Left ||
                 (direction == CollisionDirection.DirectionTag.Top &&
                  this.koopa.Physics.xPosition > this.player.Physics.xPosition))
             {
                 this.koopa.Physics.xPosition += Config.GetKoopaToKoopaShellFaultTolerancePosition();
                 this.koopa.Physics.yPosition += Config.GetKoopaToKoopaShellFaultTolerancePosition();
                 koopaShell = new KoopaShell(this.koopa.Location());
                 this.player.Boost();
                 GameManager.Instance.Replace(this.koopa, koopaShell);
                 koopaShell.MoveRight();
             }
             else if (direction == CollisionDirection.DirectionTag.Right ||
                      (direction == CollisionDirection.DirectionTag.Top &&
                       this.koopa.Physics.xPosition <= this.player.Physics.xPosition))
             {
                 this.koopa.Physics.xPosition -= Config.GetKoopaToKoopaShellFaultTolerancePosition();
                 this.koopa.Physics.yPosition += Config.GetKoopaToKoopaShellFaultTolerancePosition();
                 koopaShell = new KoopaShell(this.koopa.Location());
                 this.player.Boost();
                 GameManager.Instance.Replace(this.koopa, koopaShell);
                 koopaShell.MoveLeft();
             }
         }
         else
         {
             if (direction == CollisionDirection.DirectionTag.Top)
             {
                 this.player.Physics.yPosition  = this.koopa.GetTopSide() - this.player.GetHeight();
                 this.player.Physics.yVelocity *= -1;
                 this.koopa.BecomeStaticKS();
             }
             else if (direction == CollisionDirection.DirectionTag.Bottom ||
                      direction == CollisionDirection.DirectionTag.Left ||
                      direction == CollisionDirection.DirectionTag.Right)
             {
                 if (this.player.IsBig() || this.player.IsFire())
                 {
                     this.player.TakeDamage();
                 }
                 else if (this.player.IsSmall())
                 {
                     this.player.TakeDamage();
                 }
             }
         }
     }
     if (typeof(StarMario).IsInstanceOfType(player) && typeof(Koopa).IsInstanceOfType(koopa))
     {
         ((StarMario)player).Boost();
         reversedKoopaShell = new ReversedKoopaShell(((Koopa)koopa).Location());
         GameManager.Instance.Replace((Koopa)koopa, reversedKoopaShell);
     }
 }