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); }