コード例 #1
0
        private void OnCollisionEnter(Collision collision)
        {
            IShotable target = collision.gameObject.GetComponent <IShotable>();

            if (target != null)
            {
                target.OnBeingShot(this);
            }
            PutToPool();
        }
コード例 #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);
            }
        }
    }
コード例 #3
0
ファイル: PlayerController.cs プロジェクト: smith-st/Tank
 /// <summary>
 /// объект игрока
 /// </summary>
 public void SetPlayer(GameObject obj)
 {
     tankMove = obj.GetComponent <IMoveable> ();
     tankShot = obj.GetComponent <IShotable> ();
 }