Example #1
0
 private IEnumerator MoveUntilDone(Transform shooter, float damage, ParentObject enemy)
 {
     transform.LookAt(enemy.GetHitpoint(transform.position));
     while (enemy != null && Vector3.Distance(transform.position, enemy.GetHitpoint(transform.position)) > 0.1f)
     {
         transform.LookAt(enemy.GetHitpoint(transform.position));
         transform.position = Vector3.MoveTowards(transform.position, enemy.GetHitpoint(transform.position), speed * Time.deltaTime);
         yield return(null);
     }
     //Enemy could be dead by now
     if (enemy != null && enemy.isActiveAndEnabled)
     {
         enemy.TakeDamage(damage);
         gameObject.SetActive(false);
     }
     else
     {
         while (Vector3.Distance(transform.position, backupTarget) > 0.1f)
         {
             transform.LookAt(backupTarget);
             transform.position = Vector3.MoveTowards(transform.position, backupTarget, speed * Time.deltaTime);
             yield return(null);
         }
         gameObject.SetActive(false);
     }
 }
Example #2
0
 private IEnumerator MoveUntilDone(Transform shooter, float damage, ParentObject enemy)
 {
     while (enemy != null && Vector3.Distance(transform.position, enemy.GetHitpoint(transform.position)) > 0.1f)
     {
         transform.RotateAround(transform.position, Vector3.up, 2);
         transform.position = Vector3.MoveTowards(transform.position, enemy.GetHitpoint(transform.position), speed * Time.deltaTime);
         yield return(null);
     }
     //Enemy could be dead by now
     if (enemy != null && enemy.isActiveAndEnabled)
     {
         enemy.TakeDamage(damage);
         if (enemy is ParentBuilding)
         {
             ParentBuilding temp = (ParentBuilding)enemy;
             if (temp.gameObject.activeInHierarchy)
             {
                 temp.SpawnDustParticles(2);
                 temp.Shake();
             }
         }
         gameObject.SetActive(false);
     }
     else
     {
         while (Vector3.Distance(transform.position, backupTarget) > 0.1f)
         {
             transform.RotateAround(transform.position, Vector3.up, 2);
             transform.position = Vector3.MoveTowards(transform.position, backupTarget, speed * Time.deltaTime);
             yield return(null);
         }
         gameObject.SetActive(false);
     }
 }
Example #3
0
 public virtual void Shoot(Transform shooter, float damage, ParentObject enemy)
 {
     backupTarget = enemy.GetHitpoint(transform.position);
 }