Ejemplo n.º 1
0
        private void OnCollisionEnter(Collision collision)
        {
            IShotable target = collision.gameObject.GetComponent <IShotable>();

            if (target != null)
            {
                target.OnBeingShot(this);
            }
            PutToPool();
        }
Ejemplo n.º 2
0
    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);
            }
        }
    }
Ejemplo n.º 3
0
 /// <summary>
 /// объект игрока
 /// </summary>
 public void SetPlayer(GameObject obj)
 {
     tankMove = obj.GetComponent <IMoveable> ();
     tankShot = obj.GetComponent <IShotable> ();
 }