private void OnTriggerStay(Collider other) { if (other.CompareTag("Player") && other != null) { other.GetComponentInParent <DroneEnergyTank>().RegenEnergy(droneChargeRate * Time.deltaTime); DroneHealth droneHealth = other.GetComponentInParent <DroneHealth>(); for (int i = 0; i < droneHealth.propellerHealth.Length; i++) { droneHealth.ThrusterUpdate(droneChargeRate, i); } HealBase(other.GetComponentInParent <DroneController>().DropOffEnergy()); } }
// Update is called once per frame void Update() { DroneHealth healthObj = drone.GetComponent <DroneHealth>(); float currentRatio = healthObj.health / healthObj.maxHealth; if (currentRatio < 1) { if (currentRatio >= 0.75) { float value = (currentRatio - 0.75f) / 0.25f; setIndicatorAmount(TL, value); } else if (currentRatio >= 0.5) { float value = (currentRatio - 0.5f) / 0.25f; setIndicatorAmount(TL, 0); setIndicatorAmount(BL, value); } else if (currentRatio >= 0.25) { float value = (currentRatio - 0.25f) / 0.25f; setIndicatorAmount(TL, 0); setIndicatorAmount(BL, 0); setIndicatorAmount(BR, value); } else { float value = currentRatio / 0.25f; setIndicatorAmount(TL, 0); setIndicatorAmount(BL, 0); setIndicatorAmount(BR, 0); setIndicatorAmount(TR, value); } } if (currentRatio < 0.20) { TL.GetComponent <Image>().color = dangerColor; BL.GetComponent <Image>().color = dangerColor; TR.GetComponent <Image>().color = dangerColor; BR.GetComponent <Image>().color = dangerColor; GetComponentInParent <SVGImage>().sprite = dangerGraphic; } }
void Awake() { // Setting up the references. anim = GetComponent <Animator>(); laserShotLine = GetComponentInChildren <LineRenderer>(); laserShotLight = laserShotLine.gameObject.light; col = GetComponent <SphereCollider>(); player = GameObject.FindGameObjectWithTag(Tags.player).transform; playerHealth = player.gameObject.GetComponent <PlayerHealth>(); drone = GameObject.FindGameObjectWithTag(Tags.drone).transform; droneHealth = drone.gameObject.GetComponent <DroneHealth>(); hash = GameObject.FindGameObjectWithTag(Tags.gameController).GetComponent <HashIDs>(); eAI = GetComponent <EnemyAI> (); // The line renderer and light are off to start. laserShotLine.enabled = false; laserShotLight.intensity = 0f; // The scaledDamage is the difference between the maximum and the minimum damage. scaledDamage = maximumDamage - minimumDamage; }
// Start is called before the first frame update void Start() { //rb = GetComponentInParent<Rigidbody>(); drone = GetComponentInParent <DroneHealth>(); }
public void changeDroneHealthUI(DroneHealth d) { currentHealth.GetComponent <Text>().text = d.health + " / " + d.maxHealth + " : HP"; }
void Awake() { health = GetComponent <DroneHealth>(); energyTank = GetComponent <DroneEnergyTank>(); }
void Awake() { player = GameObject.FindGameObjectWithTag(Tags.player).transform; droneShooting = GetComponent <DroneShooting>(); droneHealth = GetComponent <DroneHealth>(); }