public override void OnHitByProjectile(Projectile projectile)
 {
     if (projectile is SeedEntity) {
         if (Toggle())
             (projectile as SeedEntity).DestroyWithAbsorbedEffect(false);
     }
     if (projectile is SwitchHookProjectile) {
         if (Toggle())
             (projectile as SwitchHookProjectile).Intercept();
     }
     else if (projectile is MagicRodFire) {
         if (Toggle())
             (projectile as MagicRodFire).InterceptAndAbsorb();
     }
     else if (projectile is Arrow) {
         if (Toggle())
             (projectile as Arrow).Intercept();
     }
     else if (projectile is SwordBeam) {
         if (Toggle())
             (projectile as SwordBeam).Intercept();
     }
     else if (projectile is PlayerBoomerang) {
         if (Toggle())
             (projectile as PlayerBoomerang).Intercept();
     }
 }
 public override void OnHitProjectile(Projectile projectile)
 {
     if (Player.CurrentState != Player.HoldSwordState &&
         projectile.ProjectileType == ProjectileType.Physical)
     {
         projectile.Intercept();
         AudioSystem.PlaySound(GameData.SOUND_SHIELD_DEFLECT);
     }
 }
 public override void OnHitProjectile(Projectile projectile)
 {
     if (projectile.ProjectileType == ProjectileType.Physical ||
         (projectile.ProjectileType == ProjectileType.Beam && itemShield.Level == Item.Level3))
     {
         projectile.Intercept();
         AudioSystem.PlaySound(GameData.SOUND_SHIELD_DEFLECT);
     }
 }
Beispiel #4
0
        //-----------------------------------------------------------------------------
        // Overridden methods
        //-----------------------------------------------------------------------------
        // Called when the items button is pressed (A or B).
        public override void OnButtonPress()
        {
            // Shoot an arrow!
            if (ammo[currentAmmo].IsEmpty)
                return;

            Player.Direction = Player.UseDirection;

            Projectile projectile = new Projectile();

            // General
            projectile.Owner			= Player;
            projectile.Position			= new Vector2F(Player.X, Player.Y - 8) + (Directions.ToVector(Player.Direction) * 8.0f);
            projectile.ZPosition		= Player.ZPosition;
            projectile.Angle			= Directions.ToAngle(Player.Direction);
            projectile.Physics.Velocity	= Directions.ToVector(Player.Direction) * 3.0f;

            Player.Direction = Player.Direction;

            // Graphics.
            projectile.Graphics.SubStripIndex = projectile.Angle;
            projectile.Graphics.PlayAnimation(GameData.ANIM_PROJECTILE_PLAYER_ARROW);

            // Physics.
            projectile.Physics.CollisionBox	= new Rectangle2F(-2, -2, 4, 4);
            projectile.EnablePhysics(PhysicsFlags.CollideWorld | PhysicsFlags.LedgePassable |
                                PhysicsFlags.HalfSolidPassable | PhysicsFlags.DestroyedOutsideRoom);

            // Crash event.
            Vector2F v = projectile.Physics.Velocity;
            projectile.EventCollision += delegate() {
                // Create crash effect.
                Effect effect = new Effect();
                effect.Position = projectile.Position;
                effect.CreateDestroyTimer(32);

                effect.Physics.Velocity		= -(v.Normalized) * 0.25f;
                effect.Physics.ZVelocity	= 1;
                effect.Physics.Gravity		= 0.07f;
                effect.EnablePhysics(PhysicsFlags.HasGravity);

                effect.Graphics.IsShadowVisible = false;
                effect.Graphics.PlayAnimation(GameData.ANIM_PROJECTILE_PLAYER_ARROW_CRASH);

                RoomControl.SpawnEntity(effect);
                projectile.Destroy();
            };

            RoomControl.SpawnEntity(projectile);
            ammo[currentAmmo].Amount--;

            Player.Graphics.PlayAnimation(GameData.ANIM_PLAYER_THROW);
            Player.BeginBusyState(10);
        }
Beispiel #5
0
 public Projectile ShootProjectile(Projectile projectile, Vector2F velocity, Vector2F positionOffset, int zPositionOffset)
 {
     projectile.Owner		= this;
     projectile.Direction	= direction;
     projectile.Physics.Velocity	= velocity;
     RoomControl.SpawnEntity(projectile, Center + positionOffset, zPosition + zPositionOffset);
     return projectile;
 }
Beispiel #6
0
 public Projectile ShootProjectile(Projectile projectile, Vector2F velocity)
 {
     return ShootProjectile(projectile, velocity, Vector2F.Zero, 0);
 }
Beispiel #7
0
 public Projectile ShootFromDirection(Projectile projectile, int direction, float speed, Vector2F positionOffset, int zPositionOffset = 0)
 {
     projectile.Owner		= this;
     projectile.Direction	= direction;
     projectile.Physics.Velocity	= Directions.ToVector(direction) * speed;
     RoomControl.SpawnEntity(projectile, Center + positionOffset, zPosition + zPositionOffset);
     return projectile;
 }
Beispiel #8
0
 //-----------------------------------------------------------------------------
 // Projectiles
 //-----------------------------------------------------------------------------
 public Projectile ShootFromDirection(Projectile projectile, int direction, float speed)
 {
     return ShootFromDirection(projectile, direction, speed, Vector2F.Zero, 0);
 }
Beispiel #9
0
 public Projectile ShootFromAngle(Projectile projectile, int angle, float speed, Vector2F positionOffset, int zPositionOffset = 0)
 {
     projectile.Owner	= this;
     projectile.Angle	= angle;
     projectile.Physics.Velocity	= Angles.ToVector(angle, true) * speed;
     RoomControl.SpawnEntity(projectile, Center + positionOffset, zPosition + zPositionOffset);
     return projectile;
 }
Beispiel #10
0
 public Projectile ShootFromAngle(Projectile projectile, int angle, float speed)
 {
     return ShootFromAngle(projectile, angle, speed, Vector2F.Zero, 0);
 }
Beispiel #11
0
 public virtual void OnHitProjectile(Projectile projectile)
 {
 }
Beispiel #12
0
 // Called when the tile is hit by one of the player's projectile.
 public virtual void OnHitByProjectile(Projectile projectile)
 {
     if (projectile is SeedEntity) {
         SeedEntity seed = (SeedEntity) projectile;
         OnSeedHit(seed.SeedType, seed);
     }
 }