protected virtual void Start() { currentHealth = startingHealth; currentShield = startingShield; regenTimer = regenDelay; ammoDrop = gameObject.GetComponent <AmmoDrop>(); gameover = GameObject.FindWithTag("WorldController").GetComponent <GameOver>(); gameController = GameObject.FindWithTag("WorldController").GetComponent <GameController>(); }
private IEnumerator Die() { AmmoDrop ammoDrop = Instantiate(ammoPrefab, transform.position, transform.rotation).GetComponent <AmmoDrop>(); ammoDrop.amount = Random.Range(minAmmoAmount, maxAmmoAmount); StopCoroutine(enemyComponent.Attack(this, target)); dead = true; agent.enabled = false; GetComponent <ShowBehindWalls>().active = false; Rigidbody rb = gameObject.AddComponent <Rigidbody>(); rb.AddForce(Random.insideUnitSphere, ForceMode.VelocityChange); yield return(new WaitForSeconds(corpseTimer)); Destroy(gameObject); }