Exemplo n.º 1
0
        //-----------------------------------------------------------------------------
        // Virtual
        //-----------------------------------------------------------------------------

        public override void OnButtonPress()
        {
            if (bombTracker.IsEmpty)
            {
                if (HasAmmo())
                {
                    // Conjure a new bomb.
                    UseAmmo();
                    Bomb bomb = new Bomb();
                    bombTracker.TrackEntity(bomb);
                    Player.CarryState.SetCarryObject(bomb);
                    Player.BeginState(Player.CarryState);
                }
            }
            else
            {
                // Pickup a bomb from the ground.
                Bomb bomb = bombTracker.GetEntity();
                if (bomb != null && Player.Physics.IsSoftMeetingEntity(bomb))
                {
                    Player.BeginState(new PlayerCarryState(bomb));
                    bomb.RemoveFromRoom();
                }
            }
        }
Exemplo n.º 2
0
        //-----------------------------------------------------------------------------
        // Overridden methods
        //-----------------------------------------------------------------------------

        public override void OnButtonPress()
        {
            if (boomerangTracker.IsMaxedOut)
            {
                return;
            }

            // Shoot and track the boomerang.
            PlayerBoomerang boomerang = new PlayerBoomerang(this);

            Player.ShootFromAngle(boomerang, Player.UseAngle, boomerang.Speed);
            boomerangTracker.TrackEntity(boomerang);

            if (level == Item.Level1)
            {
                // Begin the standard busy state for the regular boomerang.
                Player.BeginBusyState(10, GameData.ANIM_PLAYER_THROW, GameData.ANIM_PLAYER_MINECART_THROW);
            }
            else
            {
                // Enter a player state to control the magic boomerang.
                Player.MagicBoomerangState.Weapon          = this;
                Player.MagicBoomerangState.BoomerangEntity = boomerang;
                Player.BeginState(Player.MagicBoomerangState);
            }
        }
Exemplo n.º 3
0
        //-----------------------------------------------------------------------------
        // Overridden methods
        //-----------------------------------------------------------------------------

        // Called when the items button is pressed (A or B).
        public override void OnButtonPress()
        {
            if (!HasAmmo())
            {
                return;
            }

            SeedType seedType = CurrentSeedType;

            if (seedType == SeedType.Ember)
            {
                if (emberSeedTracker.IsAvailable)
                {
                    emberSeedTracker.TrackEntity(ThrowSeed(SeedType.Ember));
                }
            }
            else if (seedType == SeedType.Scent)
            {
                if (scentSeedTracker.IsAvailable)
                {
                    scentSeedTracker.TrackEntity(ThrowSeed(SeedType.Scent));
                }
            }
            else if (seedType == SeedType.Pegasus)
            {
                // Start sprinting.
                if (!Player.Movement.IsSprinting)
                {
                    Player.RoomControl.SpawnEntity(
                        new Effect(GameData.ANIM_EFFECT_PEGASUS_DUST, DepthLayer.EffectPegasusDust, true),
                        Player.Center - new Point2I(0, 8));
                    Player.Movement.StartSprinting(
                        GameSettings.PLAYER_SPRINT_DURATION,
                        GameSettings.PLAYER_SPRINT_SPEED_SCALE);
                    UseAmmo();
                }
            }
            else if (seedType == SeedType.Gale)
            {
                if (galeSeedTracker.IsAvailable)
                {
                    galeSeedTracker.TrackEntity(DropSeed(SeedType.Gale));
                }
            }
            else if (seedType == SeedType.Mystery)
            {
                if (mysterySeedTracker.IsAvailable)
                {
                    mysterySeedTracker.TrackEntity(ThrowSeed(SeedType.Mystery));
                }
            }
        }
Exemplo n.º 4
0
        //-----------------------------------------------------------------------------
        // Overridden methods
        //-----------------------------------------------------------------------------

        // Called when the items button is pressed (A or B).
        public override void OnButtonPress()
        {
            if (arrowTracker.IsMaxedOut || !HasAmmo())
            {
                return;
            }

            UseAmmo();
            Player.Direction = Player.UseDirection;

            // Shoot and track the arrow projectile.
            Arrow arrow = new Arrow();

            Player.ShootFromDirection(arrow, Player.Direction,
                                      GameSettings.PROJECTILE_ARROW_SPEED,
                                      Directions.ToVector(Player.Direction) * 8.0f);
            arrowTracker.TrackEntity(arrow);

            AudioSystem.PlaySound(GameData.SOUND_SHOOT_PROJECTILE);

            // Begin the busy state.
            Player.BeginBusyState(10, GameData.ANIM_PLAYER_THROW, GameData.ANIM_PLAYER_MINECART_THROW);
        }
Exemplo n.º 5
0
        //-----------------------------------------------------------------------------
        // Overridden methods
        //-----------------------------------------------------------------------------

        // Called when the items button is pressed (A or B).
        public override void OnButtonPress()
        {
            if (!seedTracker.IsEmpty || !HasAmmo())
            {
                return;
            }

            UseAmmo();

            SeedType seedType = CurrentSeedType;

            int direction = Player.UseDirection;

            Player.Direction = direction;

            // Determine the seed spawn position based on player facing direction.
            Vector2F seedPos;

            if (direction == Directions.Up)
            {
                seedPos = Directions.ToVector(direction) * 1;
            }
            else if (direction == Directions.Down)
            {
                seedPos = Directions.ToVector(direction) * 8;
            }
            else
            {
                seedPos = new Vector2F(0, 6) + (Directions.ToVector(direction) * 4);
            }

            // Spawn the main seed projectile.
            SeedProjectile seed = new SeedProjectile(seedType, false);

            Player.ShootProjectile(seed,
                                   Directions.ToVector(direction) * GameSettings.SLINGSHOT_SEED_SPEED,
                                   seedPos, 5);
            seedTracker.TrackEntity(seed);

            // Spawn the extra 2 seeds for the Hyper Slingshot.
            if (level == Item.Level2)
            {
                for (int i = 0; i < 2; i++)
                {
                    int sideDirection = direction + (i == 0 ? 1 : 3);

                    // Calculate the velocity based on a degree offset.
                    float degrees = direction * GMath.QuarterAngle;
                    if (i == 0)
                    {
                        degrees += GameSettings.SLINGSHOT_SEED_DEGREE_OFFSET;
                    }
                    else
                    {
                        degrees -= GameSettings.SLINGSHOT_SEED_DEGREE_OFFSET;
                    }
                    Vector2F velocity = Vector2F.CreatePolar(GameSettings.SLINGSHOT_SEED_SPEED, degrees);
                    velocity.Y = -velocity.Y;

                    // Spawn the seed.
                    seed = new SeedProjectile(seedType, false);
                    Player.ShootProjectile(seed, velocity, seedPos, 5);
                    seedTracker.TrackEntity(seed);
                }
            }

            // Set the tool animation.
            Player.EquipTool(Player.ToolVisual);
            if (level == Item.Level1)
            {
                Player.ToolVisual.PlayAnimation(GameData.ANIM_SLINGSHOT_1);
            }
            else
            {
                Player.ToolVisual.PlayAnimation(GameData.ANIM_SLINGSHOT_2);
            }
            Player.ToolVisual.AnimationPlayer.SubStripIndex = direction;

            // Begin the player busy state.
            Player.BusyState.SetEndAction(delegate(PlayerState playerState) {
                playerState.Player.UnequipTool(playerState.Player.ToolVisual);
            });
            Player.BeginBusyState(10, GameData.ANIM_PLAYER_THROW, GameData.ANIM_PLAYER_MINECART_THROW);
        }