示例#1
0
 void TakeDamage(DeathByAngel deathAngel)
 {
     if (deathAngel.active)
     {
         TakeDamage(deathAngel.damage);
         var clone = Instantiate(explosionPrefab, deathAngel.transform.position, Quaternion.identity);
         clone.transform.localScale = Vector3.one * Mathf.Max(1, deathAngel.damage * 0.3f);
         deathAngel.Kill();
     }
 }
示例#2
0
 void OnTriggerEnter(Collider other)
 {
     if (!dead)
     {
         DeathByAngel deathAngel = other.GetComponent <DeathByAngel>();
         if (deathAngel != null)
         {
             TakeDamage(deathAngel);
         }
     }
 }
示例#3
0
    void OnTriggerEnter(Collider other)
    {
        if (other.tag == "bullet")
        {
            Rigidbody rbody = other.attachedRigidbody;

            // Go towards the angel
            Vector3 angel = GameObject.FindGameObjectWithTag("Angel bullet target").transform.position;
            Vector3 diff  = angel - transform.position;

            // velocity = direction * original velocity speed
            // in this case its velocity is set to away from this object
            rbody.velocity = diff.normalized * rbody.velocity.magnitude;

            DeathByTimer deathTimer = rbody.GetComponent <DeathByTimer>();
            deathTimer.ResetTimer();

            DeathByAngel deathAngel = rbody.GetComponent <DeathByAngel>();
            deathAngel.active = true;
        }
    }