void OnTriggerEnter(Collider other) { if (other.gameObject.CompareTag("Powerup")) { DefinePowerup pow = other.gameObject.GetComponent <DefinePowerup>(); DefinePowerup.ePowerupType pt = pow.GetTypeOfPowerup(); if (pt == DefinePowerup.ePowerupType.Health) { health += 25; if (health > 100) { health = 100; } if (!inSpecialMode) { LoseApproval(); } if (isAI) { aiMangr.gotPowerup = true; } } else if (pt == DefinePowerup.ePowerupType.Relic) { if (!inSpecialMode) { health -= 10; if (health < 0) { health = 0; } GainApproval(); } if (isAI) { aiMangr.gotPowerup = true; } } pow.PlayPowerupSound(); Destroy(other.gameObject); } }
private void ChaseRelic() { if (!targetFound) { GameObject[] go = GameObject.FindGameObjectsWithTag("Powerup"); foreach (GameObject obj in go) { DefinePowerup pow = obj.GetComponent <DefinePowerup>(); if (pow.thePowerupType == DefinePowerup.ePowerupType.Relic) { targetFound = true; currentTarget = obj; break; } } } else { ConstantlyFaceTarget(currentTarget); ThrustAI(1.0f); } }