private void OnCollisionEnter(Collision collision) { AN_EnemyBaheviour en = collision.gameObject.GetComponent <AN_EnemyBaheviour>(); AN_Bullet bullet = collision.gameObject.GetComponent <AN_Bullet>(); if (bullet == null) // for shortgun { if (!EnemyBullet) { if (en != null) { en.CurrentHealth -= Damage; Instantiate(Blood, transform.position, transform.rotation); } Destroy(gameObject); } else // enemy bullet { AN_PlayerParams pr = collision.gameObject.GetComponent <AN_PlayerParams>(); if (pr != null) { pr.CurrentHealth -= Damage; Instantiate(Blood, transform.position, transform.rotation); Destroy(gameObject); } else if (en == null) { Destroy(gameObject); } } } }
private void Start() { agent = GetComponent <NavMeshAgent>(); player = FindObjectOfType <AN_PlayerParams>(); // size AN_GameManager man = FindObjectOfType <AN_GameManager>(); float size = 1f + man.Respowned * .01f; size = Mathf.Clamp(size, 1f, 2f); transform.localScale = Vector3.one * Random.Range(1f, size); CurrentHealth *= size * 1.5f; }
private void Start() { if (ImpulseDamage) { Collider[] checkObj = Physics.OverlapSphere(transform.position, Radius); foreach (var obj in checkObj) { AN_PlayerParams pr = obj.GetComponent <AN_PlayerParams>(); AN_EnemyBaheviour en = obj.GetComponent <AN_EnemyBaheviour>(); if (pr != null) { pr.CurrentHealth -= Damage; } if (en != null) { en.CurrentHealth -= Damage; } } } }