Esempio n. 1
0
        public override void HandleCollisions(CollisionBody collider, CollisionType colliderType)
        {
            if (collider is PowerUp)
            {
                PowerUp powerUp = collider as PowerUp;
                switch (powerUp.powerUpType)
                {
                case PowerUp.Attack:
                    shootLevel += 1;
                    break;

                case PowerUp.Health:
                    if (Main.playerHealth < 6)
                    {
                        Main.playerHealth += 1;
                    }
                    break;

                case PowerUp.Speed:
                    Main.playerSpeed += 0.2f;
                    break;
                }
                powerUp.DestoryInstance(powerUp);
            }

            /*if (collider is AbilityDrop)
             * {
             *  AbilityDrop abilityDrop = collider as AbilityDrop;
             *  switch (abilityDrop.abilityType)
             *  {
             *      case AbilityDrop.RapidFire:
             *          abilityActive[RapidFireAbility] = true;
             *          abilityDurations[RapidFireAbility] = 30 * 60;
             *          break;
             *  }
             *  abilityDrop.DestoryInstance(abilityDrop);
             * }*/

            if (immunityCounter > 0)
            {
                return;
            }

            if (abilityActive && abilityType == AbilityType.Shields)
            {
                return;
            }

            if (collider is Projectile)
            {
                Projectile collidingProjectile = collider as Projectile;

                if (!collidingProjectile.continuous)
                {
                    immunityCounter   += 30;
                    Main.playerHealth -= 1;
                    if (Main.playerHealth <= 0)
                    {
                        dying = true;
                    }
                    Explosion.NewExplosion(collidingProjectile.position, Vector2.Zero);
                    collidingProjectile.DestroyInstance(collidingProjectile);
                }
                if (collidingProjectile.continuous)
                {
                    if (collidingProjectile is ContinuousLaser)
                    {
                        immunityCounter   += 30;
                        Main.playerHealth -= 1;
                        if (Main.playerHealth <= 0)
                        {
                            dying = true;
                        }
                        Explosion.NewExplosion(position, Vector2.Zero);
                    }
                    if (collidingProjectile is StasisBeam)
                    {
                        stunTimer = 2;
                    }
                }
            }
            if (collider is Slicer)
            {
                immunityCounter   += 30;
                Main.playerHealth -= 1;
            }
        }
 /// <summary>
 /// A method that gets called whenever a collision happens.
 /// </summary>
 /// <param name="collider"> The collider. </param>
 /// <param name="colliderType"> The collision type of the collider. </param>
 public virtual void HandleCollisions(CollisionBody collider, CollisionType colliderType)
 {
 }