/* private void OnCollisionEnter(Collision collision) * { * if (collision.collider.CompareTag("Enemy")) * { * health -= 25; * enemy.WalkForward = false; * enemy.GotStick(); * } * * } */ private void OnTriggerEnter(Collider other) { if (other.CompareTag("Enemy")) { Health -= 25; other.gameObject.GetComponent <EnemyMover>().WalkForward = false; other.gameObject.GetComponent <EnemyMover>().GotStick(); BurgDamageTaken(); WarningManager warn = WarningManager.FindClosestWarningManager(other.transform.position); warn.StartCoroutine(warn.ColorWarnObjects("damage")); } }
public void OnTriggerEnter(Collider other) { if (other.CompareTag("Projectile") && !gotHit) { WalkForward = false; if (StoleStick) { GameObject.Find("Burg").GetComponent <BurgScript>().Health += 25; GameObject.Find("Burg").GetComponent <BurgScript>().BurgHealthReceived(); GameObject.Find("GameManager").GetComponent <ScoreScript>().EnemyHit(5); StoleStick = false; gameObject.GetComponentInChildren <Animator>().SetBool("StoleStick", false); killWithStick++; PlayerPrefs.SetInt("KillWithStickKey", killWithStick); } else { GameObject.Find("GameManager").GetComponent <ScoreScript>().EnemyHit(5); GameObject.Find("GameManager").GetComponent <ScoreScript>().EnemyHit(5); killWithoutStick++; PlayerPrefs.SetInt("KillWithoutStickKey", killWithoutStick); } gotHit = true; GameObject.Find("Treffer").GetComponent <AudioSource>().pitch = Random.Range(0.6f, 0.9f); GameObject.Find("Treffer").GetComponent <AudioSource>().Play(); gameObject.GetComponentInChildren <Animator>().SetBool("SpatOn", true); } else if (other.CompareTag("CloseWarning")) { WarningManager warn = WarningManager.FindClosestWarningManager(gameObject.transform.position); warn.StartCoroutine(warn.ColorWarnObjects("close")); } else if (other.CompareTag("FarWarning")) { WarningManager warn = WarningManager.FindClosestWarningManager(gameObject.transform.position); warn.StartCoroutine(warn.ColorWarnObjects("far")); } }