using System.Collections; using System.Collections.Generic; using UnityEngine; using Photon.Pun; public class BulletsProp : MonoBehaviour { [Header("Refrences & Variables")] public GameObject child; public bool canInteract; public float targetTime; public float regenTime; [Header("Ammo")] public int ammoReplace; public int magReplace; public bool bulletReplace; [Header("Health")] public bool healthReplace; public int healthReplace2; public bool healthEqual; public bool healthAdd; [Header("Rarity")] public bool isRare; public int LikleyHood; public int outOf; public int randomNumber; public int targetNumber; void OnTriggerEnter(Collider collision) { if(canInteract){ if (collision.gameObject.tag == "Player" || collision.gameObject.tag == "master") { canInteract = false; if(bulletReplace) { collision.gameObject.GetComponentInChildren().mag += magReplace; collision.gameObject.GetComponentInChildren().ammo = ammoReplace; } if(healthReplace) { if(healthAdd) { collision.gameObject.GetComponent().health += healthReplace2; } if(healthEqual) { collision.gameObject.GetComponent().health = healthReplace2; } } } } } void Update() { Debug.Log("Update"); if(!canInteract) { child.SetActive(false); Debug.Log("can't interact"); Debug.Log("I'm Counting"); targetTime -= Time.deltaTime; child.SetActive(false); if (targetTime <= 0.0f) { timerEnded(); targetTime = regenTime; Debug.Log("I'm Done Counting!"); } } if(canInteract) { child.SetActive(true); Debug.Log("can interact"); } } void timerEnded() { if(!isRare) { canInteract = true; targetTime = regenTime; } if(isRare){ RollDice(); } } void RollDice() { if(isRare) { randomNumber = Random.Range(outOf, LikleyHood); RarityCheck(); } void RarityCheck(){ if(randomNumber == targetNumber) { canInteract = true; } } } }