private void InteractWithBuyable(BuyableWeapons buyable) { if (gameManager.points < buyable.cost) { return; } if (GetOwnWeapon(buyable.ID) != null) { uiManager.UpdateInteractableText(buyable.name + "Ammo: $" + buyable.ammoCost.ToString()); if (CheckInteractionInput() == false) { return; } GetOwnWeapon(buyable.ID).MaxOutAmmo(); gameManager.ConsumePoints(buyable.ammoCost); } else { uiManager.UpdateInteractableText(buyable.name + ": $" + buyable.cost.ToString()); if (CheckInteractionInput() == false) { return; } AssignWeapon(buyable.ID, buyable.packAPunched); gameManager.ConsumePoints(buyable.cost); } if (buyable.machine) { buyable.gameObject.SetActive(false); } }
private void CheckInteractions() { RaycastHit hit; if (!Physics.Raycast(GetRay(), out hit, interactionDistance)) { //turn UI off uiManager.UpdateInteractableText(""); return; } Drink drink = hit.transform.GetComponent <Drink>(); MysteryBox mysteryBox = hit.transform.GetComponent <MysteryBox>(); PackAPunch packAPunch = hit.transform.GetComponent <PackAPunch>(); BuyableWeapons buyable = hit.transform.GetComponent <BuyableWeapons>(); Obstacle obstacle = hit.transform.GetComponent <Obstacle>(); if (buyable != null) { InteractWithBuyable(buyable); } else if (drink != null) { InteractWithDrink(drink); } else if (mysteryBox != null) { InteractWithMysteryBox(mysteryBox); } else if (packAPunch != null) { InteractWithPackAPunch(packAPunch); } else if (obstacle != null) { uiManager.UpdateInteractableText(obstacle.blockedArea + ": $" + obstacle.cost.ToString()); if (CheckInteractionInput() == false) { return; } if (gameManager.points < obstacle.cost) { return; } obstacle.Buy(); gameManager.ConsumePoints(obstacle.cost); } }
private void DeactivateWeapons(BuyableWeapons weapon) { weapon.gameObject.SetActive(false); }