public override void update(GameTime currentTime) { switch (dropItem) { case DropItemType.CoinDrop: if (state == DropState.Active) { animationTime += currentTime.ElapsedGameTime.Milliseconds; for (int i = 0; i < parentWorld.EntityList.Count; i++) { if (parentWorld.EntityList[i] is Player) { if (hitTest(parentWorld.EntityList[i])) { GameCampaign.Player_Coin_Amount = GameCampaign.Player_Coin_Amount + (int)value; LevelState.ElapsedCoinAmount += (int)value; AudioLib.playSoundEffect("testCoin"); state = DropState.Inactive; } } } if (isKnockedBack) { knockedBackTime += currentTime.ElapsedGameTime.Milliseconds; if (knockedBackTime > knockBackDuration) { isKnockedBack = false; } } else { velocity = Vector2.Zero; } Vector2 nextStep = position + (velocity * currentTime.ElapsedGameTime.Milliseconds); Vector2 finalPos = parentWorld.Map.reloactePosition(position, nextStep, dimensions); position = finalPos; } else { position = new Vector2(-100, -100); } break; case DropItemType.AmmoDrop: if (state == DropState.Active) { for (int i = 0; i < parentWorld.EntityList.Count; i++) { if (parentWorld.EntityList[i] is Player) { InputDevice2.PPG_Player playerIndex = ((Player)parentWorld.EntityList[i]).Index; if (hitTest(parentWorld.EntityList[i])) { AudioLib.playSoundEffect("ammoPickup"); if (ammo_value == AmmoValue.fullAmmo) { if (playerIndex == InputDevice2.PPG_Player.Player_1) { GameCampaign.Player_Ammunition = 100; } else { GameCampaign.Player2_Ammunition = 100; } } else { if (playerIndex == InputDevice2.PPG_Player.Player_1) { float ammo = GameCampaign.Player_Ammunition + (int)ammo_value; if (ammo > 100) { GameCampaign.Player_Ammunition = 100; } else { GameCampaign.Player_Ammunition += (int)ammo_value; } } else { float ammo = GameCampaign.Player_Ammunition + (int)ammo_value; if (ammo > 100) { GameCampaign.Player2_Ammunition = 100; } else { GameCampaign.Player2_Ammunition += (int)ammo_value; } } } state = DropState.Inactive; } } } if (isKnockedBack) { knockedBackTime += currentTime.ElapsedGameTime.Milliseconds; if (knockedBackTime > knockBackDuration) { isKnockedBack = false; } } else { velocity = Vector2.Zero; } Vector2 nextStep = position + (velocity * currentTime.ElapsedGameTime.Milliseconds); Vector2 finalPos = parentWorld.Map.reloactePosition(position, nextStep, dimensions); position = finalPos; } else { position = new Vector2(-100, -100); } break; case DropItemType.MedDrop: if (state == DropState.Active) { for (int i = 0; i < parentWorld.EntityList.Count; i++) { if (parentWorld.EntityList[i] is Player) { if (hitTest(parentWorld.EntityList[i])) { InputDevice2.PPG_Player playerIndex = ((Player)parentWorld.EntityList[i]).Index; AudioLib.playSoundEffect("healthSound"); if (med_value == MedValue.fullPack) { if (((Player)parentWorld.EntityList[i]).Index == InputDevice2.PPG_Player.Player_1) { GameCampaign.Player_Health = 100; } else { GameCampaign.Player2_Health = 100; } } else { if (((Player)parentWorld.EntityList[i]).Index == InputDevice2.PPG_Player.Player_1) { float health = GameCampaign.Player_Health + (int)med_value; if (health > 100) { GameCampaign.Player_Health = 100; } else { GameCampaign.Player_Health += (int)med_value; } } else { float health = GameCampaign.Player2_Health + (int)med_value; if (health > 100) { GameCampaign.Player2_Health = 100; } else { GameCampaign.Player2_Health += (int)med_value; } } } state = DropState.Inactive; } } } if (isKnockedBack) { knockedBackTime += currentTime.ElapsedGameTime.Milliseconds; if (knockedBackTime > knockBackDuration) { isKnockedBack = false; } } else { velocity = Vector2.Zero; } Vector2 nextStep = position + (velocity * currentTime.ElapsedGameTime.Milliseconds); Vector2 finalPos = parentWorld.Map.reloactePosition(position, nextStep, dimensions); position = finalPos; } else { position = new Vector2(-100, -100); } break; default: throw new System.InvalidOperationException("invalid DropItem state"); } }
public Player(LevelState parentWorld, float initial_x, float initial_y, InputDevice2.PPG_Player index) { position = new Vector2(initial_x, initial_y); dimensions = new Vector2(32.0f, 58.5f); velocity = Vector2.Zero; if (index == InputDevice2.PPG_Player.Player_1) { Player_Right_Item = getItemWhenLoading(GameCampaign.Player_Right_Item); Player_Left_Item = getItemWhenLoading(GameCampaign.Player_Left_Item); } else if (index == InputDevice2.PPG_Player.Player_2) { Player_Right_Item = getItemWhenLoading(GameCampaign.Player2_Item_1); Player_Left_Item = getItemWhenLoading(GameCampaign.Player2_Item_2); } state = playerState.Moving; disable_movement = false; direction_facing = GlobalGameConstants.Direction.Down; this.parentWorld = parentWorld; if (index == InputDevice2.PPG_Player.Player_1) { if (GameCampaign.PlayerColor == 0) { walk_down = AnimationLib.loadNewAnimationSet("jensenDown"); walk_right = AnimationLib.loadNewAnimationSet("jensenRight"); walk_left = AnimationLib.loadNewAnimationSet("jensenRight"); walk_up = AnimationLib.loadNewAnimationSet("jensenUp"); } else if (GameCampaign.PlayerColor == 1) { walk_down = AnimationLib.loadNewAnimationSet("jensenDown_RED"); walk_right = AnimationLib.loadNewAnimationSet("jensenRight_RED"); walk_left = AnimationLib.loadNewAnimationSet("jensenRight_RED"); walk_up = AnimationLib.loadNewAnimationSet("jensenUp_RED"); } else if (GameCampaign.PlayerColor == 2) { walk_down = AnimationLib.loadNewAnimationSet("jensenDown_PURPLE"); walk_right = AnimationLib.loadNewAnimationSet("jensenRight_PURPLE"); walk_left = AnimationLib.loadNewAnimationSet("jensenRight_PURPLE"); walk_up = AnimationLib.loadNewAnimationSet("jensenUp_PURPLE"); } else if (GameCampaign.PlayerColor == 3) { walk_down = AnimationLib.loadNewAnimationSet("jensenDown_BLUE"); walk_right = AnimationLib.loadNewAnimationSet("jensenRight_BLUE"); walk_left = AnimationLib.loadNewAnimationSet("jensenRight_BLUE"); walk_up = AnimationLib.loadNewAnimationSet("jensenUp_BLUE"); } else if (GameCampaign.PlayerColor == 4) { walk_down = AnimationLib.loadNewAnimationSet("jensenDown_CYAN"); walk_right = AnimationLib.loadNewAnimationSet("jensenRight_CYAN"); walk_left = AnimationLib.loadNewAnimationSet("jensenRight_CYAN"); walk_up = AnimationLib.loadNewAnimationSet("jensenUp_CYAN"); } else if (GameCampaign.PlayerColor == 5) { walk_down = AnimationLib.loadNewAnimationSet("jensenDown_BROWN"); walk_right = AnimationLib.loadNewAnimationSet("jensenRight_BROWN"); walk_left = AnimationLib.loadNewAnimationSet("jensenRight_BROWN"); walk_up = AnimationLib.loadNewAnimationSet("jensenUp_BROWN"); } } else if (index == InputDevice2.PPG_Player.Player_2) { if (GameCampaign.Player2Color == 0) { walk_down = AnimationLib.loadNewAnimationSet("femaleJensenDown"); walk_right = AnimationLib.loadNewAnimationSet("femaleJensenRight"); walk_left = AnimationLib.loadNewAnimationSet("femaleJensenRight"); walk_up = AnimationLib.loadNewAnimationSet("femaleJensenUp"); } else if (GameCampaign.Player2Color == 1) { walk_down = AnimationLib.loadNewAnimationSet("femaleJensenDown_RED"); walk_right = AnimationLib.loadNewAnimationSet("femaleJensenRight_RED"); walk_left = AnimationLib.loadNewAnimationSet("femaleJensenRight_RED"); walk_up = AnimationLib.loadNewAnimationSet("femaleJensenUp_RED"); } else if (GameCampaign.Player2Color == 2) { walk_down = AnimationLib.loadNewAnimationSet("femaleJensenDown_PURPLE"); walk_right = AnimationLib.loadNewAnimationSet("femaleJensenRight_PURPLE"); walk_left = AnimationLib.loadNewAnimationSet("femaleJensenRight_PURPLE"); walk_up = AnimationLib.loadNewAnimationSet("femaleJensenUp_PURPLE"); } else if (GameCampaign.Player2Color == 3) { walk_down = AnimationLib.loadNewAnimationSet("femaleJensenDown_BLUE"); walk_right = AnimationLib.loadNewAnimationSet("femaleJensenRight_BLUE"); walk_left = AnimationLib.loadNewAnimationSet("femaleJensenRight_BLUE"); walk_up = AnimationLib.loadNewAnimationSet("femaleJensenUp_BLUE"); } else if (GameCampaign.Player2Color == 4) { walk_down = AnimationLib.loadNewAnimationSet("femaleJensenDown_CYAN"); walk_right = AnimationLib.loadNewAnimationSet("femaleJensenRight_CYAN"); walk_left = AnimationLib.loadNewAnimationSet("femaleJensenRight_CYAN"); walk_up = AnimationLib.loadNewAnimationSet("femaleJensenUp_CYAN"); } else if (GameCampaign.Player2Color == 5) { walk_down = AnimationLib.loadNewAnimationSet("femaleJensenDown_BROWN"); walk_right = AnimationLib.loadNewAnimationSet("femaleJensenRight_BROWN"); walk_left = AnimationLib.loadNewAnimationSet("femaleJensenRight_BROWN"); walk_up = AnimationLib.loadNewAnimationSet("femaleJensenUp_BROWN"); } } remove_from_list = false; current_skeleton = walk_right; current_skeleton.Animation = current_skeleton.Skeleton.Data.FindAnimation("run"); death = false; enemy_type = EnemyType.Player; this.index = index; setAnimationWeapons(walk_down, GlobalGameConstants.Direction.Right); setAnimationWeapons(walk_right, GlobalGameConstants.Direction.Right); setAnimationWeapons(walk_left, GlobalGameConstants.Direction.Left); setAnimationWeapons(walk_up, GlobalGameConstants.Direction.Right); }