private void OnTriggerEnter(Collider other)
    {
        for (int i = 0; i < obstacleTags.Length; i++)
        {
            if (other.transform.tag == obstacleTags[i])
            {
                currentMovement = other.transform.GetComponentInParent <IObstacleMovement>();

                if (isCollided || currentMovement.tagged)
                {
                    return;
                }
                isCollided             = true;
                currentMovement.tagged = true;

                if (currentMovement != null && ownHealth != null)
                {
                    ownHealth.health -= currentMovement.damage;
                }
            }
        }


        if (!isPlayer)
        {
            if (other.transform.tag == "Player")
            {
                other.transform.GetComponent <UFOHealth>().health -= causeDamage;
                ownController.Reset();
                ownHealth.Refill();
                //count success
                Debug.Log("success");
                FileHandler.self.WriteString("success\n\n");
            }

            if (other.gameObject.CompareTag("bullet"))
            {
                bool isRocket = other.gameObject.GetComponent <BulletMovement>().isRocket;
                Debug.Log("other");
                ownHealth.health -= other.gameObject.GetComponent <BulletMovement>().dmg;
                other.gameObject.GetComponent <BulletMovement>().isShot = false;
                if (isRocket)
                {
                    PoolBehaviour.rocketPool.ReleaseObject(other.gameObject);
                }
                else
                {
                    PoolBehaviour.bulletPool.ReleaseObject(other.gameObject);
                }
            }
        }
    }
Esempio n. 2
0
 public override void GameOver()
 {
     Debug.Log("fail");
     controller.Reset();
     Refill();
 }