public GunBullet(Vector2 position, GlobalGameConstants.Direction direction, PatrolGuard parent) { active = true; this.position = position; hitbox = GlobalGameConstants.TileSize / new Vector2(2, 2); reloadTime = 0.0f; this.parent = parent; switch (direction) { case GlobalGameConstants.Direction.Up: velocity = new Vector2(0, -bulletSpeed); break; case GlobalGameConstants.Direction.Down: velocity = new Vector2(0, bulletSpeed); break; case GlobalGameConstants.Direction.Left: velocity = new Vector2(-bulletSpeed, 0); break; case GlobalGameConstants.Direction.Right: velocity = new Vector2(bulletSpeed, 0); break; default: velocity = Vector2.Zero; break; } }
public void pushPistolFlash(Vector2 position, Color color, GlobalGameConstants.Direction direction) { for (int i = 0; i < particlePoolSize; i++) { if (particlePool[i].active) { continue; } Particle.NewPistolFlash(ref particlePool[i], position, color, direction); return; } }
public Rocket(Vector2 position, GlobalGameConstants.Direction direction) { active = true; this.position = position; this.direction = 0; dimensions = GlobalGameConstants.TileSize; timeAlive = 0; animationTime = 0; switch (direction) { case GlobalGameConstants.Direction.Down: velocity = new Vector2(0, rocketSpeed); this.direction = (float)(Math.PI / 2); break; case GlobalGameConstants.Direction.Up: velocity = new Vector2(0, -rocketSpeed); this.direction = (float)(Math.PI / -2); break; case GlobalGameConstants.Direction.Left: velocity = new Vector2(-rocketSpeed, 0); this.direction = (float)(Math.PI); break; case GlobalGameConstants.Direction.Right: velocity = new Vector2(rocketSpeed, 0); this.direction = 0; break; default: velocity = Vector2.Zero; break; } }
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; } }
public void update(Player parent, GameTime currentTime, LevelState parentWorld) { item_direction = parent.Direction_Facing; parent.Velocity = Vector2.Zero; item_state_time += currentTime.ElapsedGameTime.Milliseconds; if (sword_state == Sword_State.preslash) { //sword is on the right hand side of the player, if hitboxes are different dimensions, need to adjust the position of sword. parent.Animation_Time = 0.0f; 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.LoadAnimation.Animation = parent.LoadAnimation.Skeleton.Data.FindAnimation(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "lSlash" : "rSlash"); } else if ((parent.Index == InputDevice2.PPG_Player.Player_1 ? GameCampaign.Player_Left_Item : GameCampaign.Player2_Item_2) == ItemType() && InputDevice2.IsPlayerButtonDown(parent.Index, InputDevice2.PlayerButton.UseItem2)) { parent.LoadAnimation.Animation = parent.LoadAnimation.Skeleton.Data.FindAnimation(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "rSlash" : "lSlash"); } switch (item_direction) { case GlobalGameConstants.Direction.Right: position.X = parent.Position.X + parent.Dimensions.X; position.Y = parent.Position.Y; break; case GlobalGameConstants.Direction.Left: position.X = parent.Position.X - hitbox.X; position.Y = parent.Position.Y; break; case GlobalGameConstants.Direction.Up: position.Y = parent.Position.Y - hitbox.Y; position.X = parent.CenterPoint.X - hitbox.X / 2; break; default: position.Y = parent.CenterPoint.Y + parent.Dimensions.Y / 2; position.X = parent.CenterPoint.X - hitbox.X / 2; break; } if (item_state_time > delay) { sword_state = Sword_State.slash; sword_swing = true; AudioLib.playSoundEffect(swordSound); } } else if (sword_state == Sword_State.slash) { for (int i = 0; i < parentWorld.EntityList.Count; i++) { if (parentWorld.EntityList[i] is Enemy || parentWorld.EntityList[i] is ShopKeeper || parentWorld.EntityList[i] is Key || parentWorld.EntityList[i] is Coin || parentWorld.EntityList[i] is Pickup) { if (hitTest(parentWorld.EntityList[i])) { Vector2 direction = parentWorld.EntityList[i].CenterPoint - parent.CenterPoint; parentWorld.EntityList[i].knockBack(direction, knockback_magnitude, sword_damage, parent); AudioLib.playSoundEffect(hitSound); } } } sword_state = Sword_State.endslash; } //time delay for the player to be in this state else if (sword_state == Sword_State.endslash) { parent.State = Player.playerState.Moving; item_state_time = 0.0f; parent.Disable_Movement = true; sword_swing = false; sword_state = Sword_State.preslash; } }
public void update(Player parent, GameTime currentTime, LevelState parentWorld) { for (int i = 0; i < laser_projectile.Count(); i++) { if (laser_projectile[i].active) { laser_projectile[i].update(parentWorld, currentTime, parent); } } item_direction = parent.Direction_Facing; if (fire_projectile) { for (int i = 0; i < laser_projectile.Count(); i++) { if (laser_projectile[i].active) { continue; } else { float bullet_angle = 0.0f; if (item_direction == GlobalGameConstants.Direction.Right || item_direction == GlobalGameConstants.Direction.Left) { bullet_angle = 0.0f; } else { bullet_angle = (float)Math.PI / 2; } if ((GameCampaign.Player_Right_Item == ItemType() && InputDevice2.IsPlayerButtonDown(parent.Index, InputDevice2.PlayerButton.UseItem1))) { if ((parent.Index == InputDevice2.PPG_Player.Player_1 ? GameCampaign.Player_Ammunition : GameCampaign.Player2_Ammunition) >= ammo_consumption) { AudioLib.playSoundEffect("lazorFire"); laser_projectile[i] = new laserProjectile(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), (parent.Direction_Facing == GlobalGameConstants.Direction.Right) ? new Vector2(10, 0) : (parent.Direction_Facing == GlobalGameConstants.Direction.Left) ? new Vector2(-10, 0) : (parent.Direction_Facing == GlobalGameConstants.Direction.Up) ? new Vector2(0, -10) : new Vector2(0, 10), bullet_angle); if (parent.Index == InputDevice2.PPG_Player.Player_1) { GameCampaign.Player_Ammunition -= ammo_consumption; } else { GameCampaign.Player2_Ammunition -= ammo_consumption; } } } else if ((GameCampaign.Player_Left_Item == ItemType() && InputDevice2.IsPlayerButtonDown(parent.Index, InputDevice2.PlayerButton.UseItem2))) { if ((parent.Index == InputDevice2.PPG_Player.Player_1 ? GameCampaign.Player_Ammunition : GameCampaign.Player2_Ammunition) >= ammo_consumption) { AudioLib.playSoundEffect("lazorFire"); laser_projectile[i] = new laserProjectile(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), (parent.Direction_Facing == GlobalGameConstants.Direction.Right) ? new Vector2(15, 0) : (parent.Direction_Facing == GlobalGameConstants.Direction.Left) ? new Vector2(-15, 0) : (parent.Direction_Facing == GlobalGameConstants.Direction.Up) ? new Vector2(0, -15) : new Vector2(0, 15), bullet_angle); if (parent.Index == InputDevice2.PPG_Player.Player_1) { GameCampaign.Player_Ammunition -= ammo_consumption; } else { GameCampaign.Player2_Ammunition -= ammo_consumption; } } } parent.State = Player.playerState.Moving; parent.LoadAnimation.Animation = parent.LoadAnimation.Skeleton.Data.FindAnimation(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "lLaser" : "rLaser"); fire_timer = 0.0f; fire_projectile = false; return; } } } else { parent.State = Player.playerState.Moving; } }
public void update(Player parent, GameTime currentTime, LevelState parentWorld) { item_direction = parent.Direction_Facing; parent.Velocity = Vector2.Zero; item_state_time += currentTime.ElapsedGameTime.Milliseconds; switch (bushido_state) { case BushidoState.preslash: parent.Animation_Time = 0.0f; 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.LoadAnimation.Animation = parent.LoadAnimation.Skeleton.Data.FindAnimation(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "lSlash" : "rSlash"); } else if ((parent.Index == InputDevice2.PPG_Player.Player_1 ? GameCampaign.Player_Left_Item : GameCampaign.Player2_Item_2) == ItemType() && InputDevice2.IsPlayerButtonDown(parent.Index, InputDevice2.PlayerButton.UseItem2)) { parent.LoadAnimation.Animation = parent.LoadAnimation.Skeleton.Data.FindAnimation(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "rSlash" : "lSlash"); } switch (item_direction) { case GlobalGameConstants.Direction.Right: position.X = parent.Position.X + parent.Dimensions.X; position.Y = parent.Position.Y; break; case GlobalGameConstants.Direction.Left: position.X = parent.Position.X - hitbox.X; position.Y = parent.Position.Y; break; case GlobalGameConstants.Direction.Up: position.Y = parent.Position.Y - hitbox.Y; position.X = parent.CenterPoint.X - hitbox.X / 2; break; default: position.Y = parent.CenterPoint.Y + parent.Dimensions.Y / 2; position.X = parent.CenterPoint.X - hitbox.X / 2; break; } if (item_state_time > delay) { for (int i = 0; i < 5; i++) { parentWorld.Particles.pushDotParticle(new Vector2(parent.LoadAnimation.Skeleton.FindBone(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "lHand" : "rHand").WorldX, parent.LoadAnimation.Skeleton.FindBone(parent.Direction_Facing == GlobalGameConstants.Direction.Left ? "lHand" : "rHand").WorldY), (float)(Game1.rand.NextDouble() * 2 * Math.PI), Color.Lerp(Color.Yellow, Color.YellowGreen, (float)Game1.rand.NextDouble())); } bushido_state = BushidoState.slash; sword_swing = true; } break; case BushidoState.slash: foreach (Entity en in parentWorld.EntityList) { if (en is Enemy || en is ShopKeeper) { if (hitTest(en)) { Vector2 betweenVector = en.CenterPoint - parent.CenterPoint; Vector2 betweenVectorNormal = Vector2.Normalize(betweenVector); for (int i = 0; i < 6; i++) { parentWorld.Particles.pushDirectedParticle2(parent.CenterPoint + (betweenVector / 2), Color.Yellow, (float)(Math.PI * 2 * (i / 6f))); } for (int i = 0; i < 30; i++) { parentWorld.Particles.pushDotParticle2(parent.CenterPoint + (betweenVector / 2), (float)(Math.Atan2(betweenVector.Y, betweenVector.X) + Math.PI / 2), Color.YellowGreen, 5 + (i / 10.0f)); parentWorld.Particles.pushDotParticle2(parent.CenterPoint + (betweenVector / 2), (float)(Math.Atan2(betweenVector.Y, betweenVector.X) - Math.PI / 2), Color.YellowGreen, 5 + (i / 10.0f)); } Vector2 direction = en.CenterPoint - parent.CenterPoint; en.knockBack(direction, knockback_magnitude, sword_damage, parent); enemy_explode = true; enemy_explode_position = en.CenterPoint - new Vector2(24.0f * 3.0f, 24.0f * 3.0f); } } } bushido_state = BushidoState.endslash; break; default: parent.State = Player.playerState.Moving; item_state_time = 0.0f; parent.Disable_Movement = true; sword_swing = false; bushido_state = BushidoState.preslash; break; } }
public void setAnimationWeapons(AnimationLib.SpineAnimationSet current_skeleton, GlobalGameConstants.Direction direction_facing) { current_skeleton.Skeleton.B = 1.0f; current_skeleton.Skeleton.G = 1.0f; current_skeleton.Skeleton.R = 1.0f; switch (direction_facing == GlobalGameConstants.Direction.Left ? Player_Right_Item.ItemType() : Player_Left_Item.ItemType()) { case GlobalGameConstants.itemType.Sword: current_skeleton.Skeleton.SetAttachment("lWeapon", "lSword"); break; case GlobalGameConstants.itemType.Bomb: current_skeleton.Skeleton.SetAttachment("lWeapon", "lBomb"); break; case GlobalGameConstants.itemType.Gun: current_skeleton.Skeleton.SetAttachment("lWeapon", "lPistol"); break; case GlobalGameConstants.itemType.MachineGun: current_skeleton.Skeleton.SetAttachment("lWeapon", "lMGun"); break; case GlobalGameConstants.itemType.DungeonMap: current_skeleton.Skeleton.SetAttachment("lWeapon", "lMap"); break; case GlobalGameConstants.itemType.WaveMotionGun: current_skeleton.Skeleton.SetAttachment("lWeapon", "lRayGun"); break; case GlobalGameConstants.itemType.ShotGun: current_skeleton.Skeleton.SetAttachment("lWeapon", "lShotgun"); break; case GlobalGameConstants.itemType.Compass: current_skeleton.Skeleton.SetAttachment("lWeapon", "lCompass"); break; case GlobalGameConstants.itemType.BushidoBlade: current_skeleton.Skeleton.SetAttachment("lWeapon", "lBushidoBlade"); break; case GlobalGameConstants.itemType.WandOfGyges: current_skeleton.Skeleton.SetAttachment("lWeapon", "lWand"); break; case GlobalGameConstants.itemType.HermesSandals: current_skeleton.Skeleton.SetAttachment("lWeapon", "lHermes"); break; case GlobalGameConstants.itemType.RocketLauncher: current_skeleton.Skeleton.SetAttachment("lWeapon", "lRocket"); break; case GlobalGameConstants.itemType.FlameThrower: current_skeleton.Skeleton.SetAttachment("lWeapon", "lFlamethrower"); break; case GlobalGameConstants.itemType.LazerGun: current_skeleton.Skeleton.SetAttachment("lWeapon", "lLaser"); break; default: current_skeleton.Skeleton.SetAttachment("lWeapon", "lEmpty"); break; } switch (direction_facing == GlobalGameConstants.Direction.Left ? Player_Left_Item.ItemType() : Player_Right_Item.ItemType()) { case GlobalGameConstants.itemType.Sword: current_skeleton.Skeleton.SetAttachment("rWeapon", "rSword"); break; case GlobalGameConstants.itemType.Bomb: current_skeleton.Skeleton.SetAttachment("rWeapon", "rBomb"); break; case GlobalGameConstants.itemType.Gun: current_skeleton.Skeleton.SetAttachment("rWeapon", "rPistol"); break; case GlobalGameConstants.itemType.MachineGun: current_skeleton.Skeleton.SetAttachment("rWeapon", "rMGun"); break; case GlobalGameConstants.itemType.DungeonMap: current_skeleton.Skeleton.SetAttachment("rWeapon", "rMap"); break; case GlobalGameConstants.itemType.WaveMotionGun: current_skeleton.Skeleton.SetAttachment("rWeapon", "rRayGun"); break; case GlobalGameConstants.itemType.ShotGun: current_skeleton.Skeleton.SetAttachment("rWeapon", "rShotgun"); break; case GlobalGameConstants.itemType.Compass: current_skeleton.Skeleton.SetAttachment("rWeapon", "rCompass"); break; case GlobalGameConstants.itemType.BushidoBlade: current_skeleton.Skeleton.SetAttachment("rWeapon", "rBushidoBlade"); break; case GlobalGameConstants.itemType.WandOfGyges: current_skeleton.Skeleton.SetAttachment("rWeapon", "rWand"); break; case GlobalGameConstants.itemType.HermesSandals: current_skeleton.Skeleton.SetAttachment("rWeapon", "rHermes"); break; case GlobalGameConstants.itemType.RocketLauncher: current_skeleton.Skeleton.SetAttachment("rWeapon", "rRocket"); break; case GlobalGameConstants.itemType.FlameThrower: current_skeleton.Skeleton.SetAttachment("rWeapon", "rFlamethrower"); break; case GlobalGameConstants.itemType.LazerGun: current_skeleton.Skeleton.SetAttachment("rWeapon", "rLaser"); break; default: current_skeleton.Skeleton.SetAttachment("rWeapon", "rEmpty"); break; } }
public override void update(GameTime currentTime) { double delta = currentTime.ElapsedGameTime.Milliseconds; /* * if (Keyboard.GetState().IsKeyDown(Keys.Space)) * { * parentWorld.Particles.pushGib(CenterPoint); * } */ if (index == InputDevice2.PPG_Player.Player_1 ? GameCampaign.Player_Health <= 0.0f : GameCampaign.Player2_Health <= 0.0f) { if (!parentWorld.Player1Dead) { BackGroundAudio.stopAllSongs(); AudioLib.playSoundEffect("missionFailed"); death = true; parentWorld.Particles.pushBloodParticle(CenterPoint); parentWorld.Particles.pushBloodParticle(CenterPoint); parentWorld.Particles.pushBloodParticle(CenterPoint); parentWorld.Particles.pushBloodParticle(CenterPoint); parentWorld.Particles.pushBloodParticle(CenterPoint); parentWorld.Particles.pushBloodParticle(CenterPoint); animation_time = 0; switch (Game1.rand.Next() % 3) { case 0: current_skeleton.Animation = current_skeleton.Skeleton.Data.FindAnimation("die"); break; case 1: current_skeleton.Animation = current_skeleton.Skeleton.Data.FindAnimation("die2"); break; default: current_skeleton.Animation = current_skeleton.Skeleton.Data.FindAnimation("die3"); break; } } animation_time += currentTime.ElapsedGameTime.Milliseconds / 1000f; current_skeleton.Animation.Apply(current_skeleton.Skeleton, animation_time, false); death = true; parentWorld.Player1Dead = true; velocity = Vector2.Zero; return; } //update the world map if you've visited a new room int currentNodeX = (int)((CenterPoint.X / GlobalGameConstants.TileSize.X) / GlobalGameConstants.TilesPerRoomWide); int currentNodeY = (int)((CenterPoint.Y / GlobalGameConstants.TileSize.Y) / GlobalGameConstants.TilesPerRoomHigh); if (currentNodeX >= 0 && currentNodeX < parentWorld.NodeMap.GetLength(0) && currentNodeY >= 0 && currentNodeY < parentWorld.NodeMap.GetLength(1)) { parentWorld.NodeMap[currentNodeX, currentNodeY].visited = true; } //knocked back if (disable_movement == true) { disable_movement_time += currentTime.ElapsedGameTime.Milliseconds; if (disable_movement_time > 300) { velocity = Vector2.Zero; disable_movement = false; disable_movement_time = 0; } if (Player_Right_Item != null) { Player_Right_Item.daemonupdate(this, currentTime, parentWorld); } if (Player_Left_Item != null) { Player_Left_Item.daemonupdate(this, currentTime, parentWorld); } } else { if (state == playerState.Item1) { if (Player_Right_Item == null) { state = playerState.Moving; } else { Player_Right_Item.update(this, currentTime, parentWorld); } if (Player_Left_Item != null) { Player_Left_Item.daemonupdate(this, currentTime, parentWorld); } } else if (state == playerState.Item2) { if (Player_Left_Item == null) { state = playerState.Moving; } else { Player_Left_Item.update(this, currentTime, parentWorld); } if (Player_Right_Item != null) { Player_Right_Item.daemonupdate(this, currentTime, parentWorld); } } else if (state == playerState.Moving) { loopAnimation = true; if (InputDevice2.IsPlayerButtonDown(index, InputDevice2.PlayerButton.UseItem1)) { state = playerState.Item1; } if (InputDevice2.IsPlayerButtonDown(index, InputDevice2.PlayerButton.UseItem2)) { state = playerState.Item2; } if (disable_movement == false) { if (InputDevice2.IsPlayerButtonDown(index, InputDevice2.PlayerButton.RightDirection)) { velocity.X = playerMoveSpeed; direction_facing = GlobalGameConstants.Direction.Right; } else if (InputDevice2.IsPlayerButtonDown(index, InputDevice2.PlayerButton.LeftDirection)) { velocity.X = -playerMoveSpeed; direction_facing = GlobalGameConstants.Direction.Left; } else { velocity.X = 0.0f; } if (InputDevice2.IsPlayerButtonDown(index, InputDevice2.PlayerButton.UpDirection)) { velocity.Y = -playerMoveSpeed; direction_facing = GlobalGameConstants.Direction.Up; } else if (InputDevice2.IsPlayerButtonDown(index, InputDevice2.PlayerButton.DownDirection)) { velocity.Y = playerMoveSpeed; direction_facing = GlobalGameConstants.Direction.Down; } else { velocity.Y = 0.0f; } GlobalGameConstants.Direction analogDirection = InputDevice2.PlayerAnalogStickDirection(index); direction_facing = (analogDirection != GlobalGameConstants.Direction.NoDirection) ? analogDirection : direction_facing; switch (direction_facing) { case GlobalGameConstants.Direction.Down: current_skeleton = walk_down; current_skeleton.Skeleton.FlipX = false; break; case GlobalGameConstants.Direction.Up: current_skeleton = walk_up; current_skeleton.Skeleton.FlipX = false; break; case GlobalGameConstants.Direction.Left: current_skeleton = walk_left; current_skeleton.Skeleton.FlipX = true; break; case GlobalGameConstants.Direction.Right: current_skeleton = walk_right; current_skeleton.Skeleton.FlipX = false; break; } //if player stands still then animation returns to idle if (velocity.X == 0.0f && velocity.Y == 0.0f) { current_skeleton.Animation = current_skeleton.Skeleton.Data.FindAnimation("idle"); } else { current_skeleton.Animation = current_skeleton.Skeleton.Data.FindAnimation("run"); } } bool itemTouched = false; //Check to see if player has encountered a pickup item for (int i = 0; i < parentWorld.EntityList.Count; i++) { if (parentWorld.EntityList[i] == this) { continue; } if (parentWorld.EntityList[i] is Pickup) { if (hitTest(parentWorld.EntityList[i])) { itemTouched = true; if (InputDevice2.IsPlayerButtonDown(index, InputDevice2.PlayerButton.SwitchItem1) && !item1_switch_button_down) { item1_switch_button_down = true; } else if (!InputDevice2.IsPlayerButtonDown(index, InputDevice2.PlayerButton.SwitchItem1) && item1_switch_button_down) { item1_switch_button_down = false; Player_Right_Item = ((Pickup)parentWorld.EntityList[i]).assignItem(Player_Right_Item, currentTime); if (index == InputDevice2.PPG_Player.Player_1) { GameCampaign.Player_Right_Item = Player_Right_Item.ItemType(); } else if (index == InputDevice2.PPG_Player.Player_2) { GameCampaign.Player2_Item_1 = Player_Right_Item.ItemType(); } setAnimationWeapons(walk_down, GlobalGameConstants.Direction.Right); setAnimationWeapons(walk_right, GlobalGameConstants.Direction.Right); setAnimationWeapons(walk_left, GlobalGameConstants.Direction.Left); setAnimationWeapons(walk_up, GlobalGameConstants.Direction.Right); } if (InputDevice2.IsPlayerButtonDown(index, InputDevice2.PlayerButton.SwitchItem2) && !item2_switch_button_down) { item2_switch_button_down = true; } else if (!InputDevice2.IsPlayerButtonDown(index, InputDevice2.PlayerButton.SwitchItem2) && item2_switch_button_down) { item2_switch_button_down = false; Player_Left_Item = ((Pickup)parentWorld.EntityList[i]).assignItem(Player_Left_Item, currentTime); if (index == InputDevice2.PPG_Player.Player_1) { GameCampaign.Player_Left_Item = Player_Left_Item.ItemType(); } else if (index == InputDevice2.PPG_Player.Player_2) { GameCampaign.Player2_Item_2 = Player_Left_Item.ItemType(); } setAnimationWeapons(walk_down, GlobalGameConstants.Direction.Right); setAnimationWeapons(walk_right, GlobalGameConstants.Direction.Right); setAnimationWeapons(walk_left, GlobalGameConstants.Direction.Left); setAnimationWeapons(walk_up, GlobalGameConstants.Direction.Right); } } } } if (!itemTouched && (item1_switch_button_down || item2_switch_button_down)) { item1_switch_button_down = false; item2_switch_button_down = false; } if (Player_Right_Item != null) { Player_Right_Item.daemonupdate(this, currentTime, parentWorld); } if (Player_Left_Item != null) { Player_Left_Item.daemonupdate(this, currentTime, parentWorld); } } } Vector2 pos = new Vector2(position.X, position.Y); Vector2 nextStep = new Vector2(position.X + velocity.X, position.Y + velocity.Y); Vector2 finalPos = parentWorld.Map.reloactePosition(pos, nextStep, dimensions); position = finalPos; animation_time += currentTime.ElapsedGameTime.Milliseconds / 1000f; current_skeleton.Animation.Apply(current_skeleton.Skeleton, animation_time, loopAnimation); }
public static void NewPistolFlash(ref Particle p, Vector2 position, Color c, GlobalGameConstants.Direction direction) { p.active = true; p.position = position; p.timeAlive = 0; p.maxTimeAlive = 75; p.rotation = (int)direction * (float)(Math.PI / 2); p.rotationSpeed = 0; p.animationTime = 0; p.animation = AnimationLib.getFrameAnimationSet("pistolFlash"); p.color = c; p.velocity = Vector2.Zero; p.acceleration = Vector2.Zero; p.scale = new Vector2(1); p.isGib = false; p.isCasing = false; p.originalPosition = p.position; switch (direction) { case GlobalGameConstants.Direction.Right: p.position -= new Vector2(0, 28); break; case GlobalGameConstants.Direction.Left: p.position -= new Vector2(78, 28); break; case GlobalGameConstants.Direction.Down: p.position -= new Vector2(46, 0); break; case GlobalGameConstants.Direction.Up: p.position -= new Vector2(28, 58); break; default: break; } }