示例#1
0
        public static void Update(IProjectile fireball, IBoss BossPr, Collision.CollisionType collisionType)
        {
            switch (collisionType)
            {
            case Collision.CollisionType.Above:
                fireball.Attack(BossPr);

                return;

            case Collision.CollisionType.Below:
                fireball.Attack(BossPr);

                return;

            case Collision.CollisionType.Left:
                fireball.Attack(BossPr);

                return;

            case Collision.CollisionType.Right:
                fireball.Attack(BossPr);

                return;

            default:
                return;
            }
        }
        public void Handle(IEntity entity, IEntity target, Side side)
        {
            IProjectile fireball = (IProjectile)entity;

            // Fireball is colliding into a block
            if (target is IBlock)
            {
                IBlock block = (IBlock)target;
                // Fireball bounces on the top side of all kinds of blocks except hidden block
                if (side == Side.TOP && block.Type != "HiddenBlock")
                {
                    fireball.Bounce();
                }
                // Fire booms when colliding into a block if it is not a hidden block
                else if (block.Type != "HiddenBlock")
                {
                    SoundEffects.Instance.PlayBumpSound();
                    fireball.Boom();
                }
            }
            // Fireball is colliding into an enemy
            else if (target is IEnemy)
            {
                IEnemy enemy = (IEnemy)target;
                fireball.Attack(enemy);
                SoundEffects.Instance.PlayKickSound();
                fireball.Boom();
            }
        }