Beispiel #1
0
        public void update(Player parent, GameTime currentTime, LevelState parentWorld)
        {
            item_direction = parent.Direction_Facing;
            play_sfx       = true;
            switch (flamethrower_state)
            {
            case FlameThrowerState.Neutral:
                if (((parent.Index == InputDevice2.PPG_Player.Player_1 ? GameCampaign.Player_Right_Item : GameCampaign.Player2_Item_1) == ItemType() && InputDevice2.IsPlayerButtonDown(parent.Index, InputDevice2.PlayerButton.UseItem1)) || ((parent.Index == InputDevice2.PPG_Player.Player_1 ? GameCampaign.Player_Left_Item : GameCampaign.Player2_Item_2) == ItemType() && InputDevice2.IsPlayerButtonDown(parent.Index, InputDevice2.PlayerButton.UseItem2)))
                {
                    position = new Vector2(parent.LoadAnimation.Skeleton.FindBone(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "lGunMuzzle" : "rGunMuzzle").WorldX, parent.LoadAnimation.Skeleton.FindBone(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "lGunMuzzle" : "rGunMuzzle").WorldY);
                    switch (parent.Direction_Facing)
                    {
                    case GlobalGameConstants.Direction.Right:
                        angle1 = (float)(-1 * Math.PI / 12);
                        angle2 = (float)(Math.PI / 12);
                        break;

                    case GlobalGameConstants.Direction.Left:
                        angle1 = (float)(1 * Math.PI / 1.09);
                        angle2 = (float)(-1 * Math.PI / 1.09);
                        break;

                    case GlobalGameConstants.Direction.Up:
                        angle1 = (float)(-1 * Math.PI / 1.71);
                        angle2 = (float)(-1 * Math.PI / 2.4);
                        break;

                    default:
                        angle1 = (float)(Math.PI / 2.4);
                        angle2 = (float)(Math.PI / 1.71);
                        break;
                    }
                }

                if ((parent.Index == InputDevice2.PPG_Player.Player_1) ? GameCampaign.Player_Ammunition >= 0.1 : GameCampaign.Player2_Ammunition >= 0.1)
                {
                    flamethrower_state             = FlameThrowerState.Fire;
                    parent.Velocity                = Vector2.Zero;
                    parent.LoadAnimation.Animation = parent.LoadAnimation.Skeleton.Data.FindAnimation("idle");
                }
                else
                {
                    parent.State       = Player.playerState.Moving;
                    flamethrower_state = FlameThrowerState.Neutral;
                }
                break;

            case FlameThrowerState.Fire:
                parentWorld.Particles.pushFlame(new Vector2(parent.LoadAnimation.Skeleton.FindBone(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "lGunMuzzle" : "rGunMuzzle").WorldX, parent.LoadAnimation.Skeleton.FindBone(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "lGunMuzzle" : "rGunMuzzle").WorldY), (float)((int)parent.Direction_Facing * Math.PI / 2));

                if (parent.Index == InputDevice2.PPG_Player.Player_1)
                {
                    GameCampaign.Player_Ammunition -= 0.1f;
                }
                else if (parent.Index == InputDevice2.PPG_Player.Player_2)
                {
                    GameCampaign.Player2_Ammunition -= 0.1f;
                }

                foreach (Entity en in parentWorld.EntityList)
                {
                    if (hitTest(en))
                    {
                        Vector2 direction = en.CenterPoint - parent.CenterPoint;
                        en.knockBack(direction, knockback_magnitude, damage, parent);
                    }
                }

                if (parent.Index == InputDevice2.PPG_Player.Player_1)
                {
                    if ((GameCampaign.Player_Right_Item == ItemType() && !InputDevice2.IsPlayerButtonDown(parent.Index, InputDevice2.PlayerButton.UseItem1)) || (GameCampaign.Player_Left_Item == ItemType() && !InputDevice2.IsPlayerButtonDown(parent.Index, InputDevice2.PlayerButton.UseItem1)) || GameCampaign.Player_Ammunition < 1)
                    {
                        play_sfx           = false;
                        flamethrower_state = FlameThrowerState.Neutral;
                        parent.State       = Player.playerState.Moving;
                    }
                }
                else if (parent.Index == InputDevice2.PPG_Player.Player_2)
                {
                    if ((GameCampaign.Player2_Item_1 == ItemType() && !InputDevice2.IsPlayerButtonDown(parent.Index, InputDevice2.PlayerButton.UseItem1)) || (GameCampaign.Player2_Item_2 == ItemType() && !InputDevice2.IsPlayerButtonDown(parent.Index, InputDevice2.PlayerButton.UseItem1)) || GameCampaign.Player2_Ammunition < 1)
                    {
                        play_sfx           = false;
                        flamethrower_state = FlameThrowerState.Neutral;
                        parent.State       = Player.playerState.Moving;
                    }
                }

                AudioLib.playFlameSoundEffect(play_sfx);

                break;

            case FlameThrowerState.Reset:
                break;
            }
        }