public WaveMotionGun() { if (bulletAnimation == null) { bulletAnimation = AnimationLib.getFrameAnimationSet("waveMotionBullet"); } bullet1.active = false; bullet2.active = false; bullet3.active = false; state = WaveMotionState.Wait; }
public void update(Player parent, GameTime currentTime, LevelState parentWorld) { updateBullets(parentWorld, currentTime); if (state == WaveMotionState.Wait) { if (GameCampaign.Player_Ammunition >= 5) { shotTime = 0.0f; parent.Disable_Movement = true; parent.Velocity = Vector2.Zero; float shotDirection = 0.0f; switch (parent.Direction_Facing) { case GlobalGameConstants.Direction.Up: shotDirection = (float)Math.PI / -2; break; case GlobalGameConstants.Direction.Down: shotDirection = (float)Math.PI / 2; break; case GlobalGameConstants.Direction.Left: shotDirection = (float)Math.PI; break; case GlobalGameConstants.Direction.Right: shotDirection = 0.0f; break; } Vector2 bulletPos = Vector2.Zero; if (GameCampaign.Player_Right_Item == ItemType() && InputDevice2.IsPlayerButtonDown(parent.Index, InputDevice2.PlayerButton.UseItem1)) { if (parent.Index == InputDevice2.PPG_Player.Player_1) { GameCampaign.Player_Ammunition -= ammo_consumption; } else { GameCampaign.Player2_Ammunition -= ammo_consumption; } parent.LoadAnimation.Animation = parent.LoadAnimation.Skeleton.Data.FindAnimation(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "lRayGun" : "rRayGun"); bulletPos = 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); } else if (GameCampaign.Player_Left_Item == ItemType() && InputDevice2.IsPlayerButtonDown(parent.Index, InputDevice2.PlayerButton.UseItem2)) { GameCampaign.Player_Ammunition -= ammo_consumption; parent.LoadAnimation.Animation = parent.LoadAnimation.Skeleton.Data.FindAnimation(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "rRayGun" : "lRayGun"); bulletPos = new Vector2(parent.LoadAnimation.Skeleton.FindBone(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "rGunMuzzle" : "lGunMuzzle").WorldX, parent.LoadAnimation.Skeleton.FindBone(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "rGunMuzzle" : "lGunMuzzle").WorldY); } if (!bullet1.active) { bullet1 = new WaveMotionBullet(bulletPos, shotDirection); } else if (!bullet2.active) { bullet2 = new WaveMotionBullet(bulletPos, shotDirection); } else if (!bullet3.active) { bullet3 = new WaveMotionBullet(bulletPos, shotDirection); } AudioLib.playSoundEffect("waveShot"); state = WaveMotionState.Shooting; parent.Animation_Time = 0.0f; parent.LoopAnimation = false; } else { parent.State = Player.playerState.Moving; return; } } else if (state == WaveMotionState.Shooting) { shotTime += currentTime.ElapsedGameTime.Milliseconds; if (shotTime > shotWaitTime) { parent.Disable_Movement = false; parent.State = Player.playerState.Moving; state = WaveMotionState.Wait; } } }