public override bool DoInteractAtEntity(GameLevel gameLevel, int interactId, SkyPlayer player, SkyPlayer target) { MurderLevel murderLevel = (MurderLevel)gameLevel; Item itemInHand = player.Inventory.GetItemInHand(); if (player == murderLevel.Murderer && itemInHand is ItemMurderKnife && target != null) { KillPlayer((MurderLevel)gameLevel, target); player.Inventory.SetInventorySlot(0, new ItemMurderKnife()); //Update Knife } //Left click only (Right click charges up) else if (interactId != 2 && itemInHand is ItemInnocentGun && PlayerAmmoCounts[player.Username] > 0) { if (player.Experience > 0.05f) { return(true); } var arrow = new GunProjectile(player, gameLevel) { Damage = 0, KnownPosition = (PlayerLocation)player.KnownPosition.Clone() }; arrow.KnownPosition.Y += 1.62f; arrow.Velocity = arrow.KnownPosition.GetHeadDirection() * (2 * 2.0f * 1.5f); arrow.KnownPosition.Yaw = (float)arrow.Velocity.GetYaw(); arrow.KnownPosition.Pitch = (float)arrow.Velocity.GetPitch(); arrow.BroadcastMovement = true; arrow.DespawnOnImpact = true; arrow.SpawnEntity(); int currentAmmo = --PlayerAmmoCounts[player.Username]; if (currentAmmo <= 0) { player.Inventory.SetInventorySlot(0, new ItemAir()); //Remove Gun } else { //Ensure the gun is updated to a 'ItemInnocentGun' rather than an ItemBow RunnableTask.RunTaskLater(() => player.Inventory.SetInventorySlot(0, new ItemInnocentGun()), 50); } const float levelOneFullBarXp = 6.65f; player.Experience = 0; player.AddExperience(levelOneFullBarXp); player.Inventory.SetInventorySlot(9, new ItemAir()); const int updateTicks = 60; const int timerMillis = 50; RunnableTask.RunTaskTimer(() => { player.AddExperience(-(levelOneFullBarXp / updateTicks)); if (currentAmmo > 0 && player.Experience <= 0.1) { player.Inventory.SetInventorySlot(9, new ItemArrow()); } }, timerMillis, updateTicks + 2); } return(true); }
public MurderGunPartEntity(MurderRunningState gameState, MurderLevel level, PlayerLocation spawnLocation) : base(level, new ItemGoldIngot()) { GameState = gameState; KnownPosition = spawnLocation; SpawnLocation = spawnLocation; }