private void OnCollisionEnter(Collision collision) { IShotable target = collision.gameObject.GetComponent <IShotable>(); if (target != null) { target.OnBeingShot(this); } PutToPool(); }
void NormalAttack() { RaycastHit hit; Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out hit)) { IEnemy enemyHealth = hit.collider.GetComponent <IEnemy>(); if (enemyHealth != null) { enemyHealth.takeDamage(10); return; } IShotable shootable = hit.collider.GetComponent <IShotable>(); if (shootable != null) { shootable.interact(hit.point); } } }
/// <summary> /// объект игрока /// </summary> public void SetPlayer(GameObject obj) { tankMove = obj.GetComponent <IMoveable> (); tankShot = obj.GetComponent <IShotable> (); }