private IEnumerator FightCoroutine(Alive target) { //Transform attackableSpot = target.GetClosestAttackableSpot( myTr.position ); //while ( fighting && !target.IsDead && IsCloseEnough(attackableSpot.position) ) { while (fighting && (target != null) && !target.IsDead && IsCloseToFight(target.transform.position)) { SendMessage("OnAttack", target, SendMessageOptions.DontRequireReceiver); yield return(new WaitForSeconds(.4f)); target.GetHit(this); yield return(new WaitForSeconds(attackRate)); } if (fighting && !target.IsDead) { SendMessage("OnTargetLost", target, SendMessageOptions.DontRequireReceiver); } if (target.IsDead) { SendMessage("OnTargetDead", target, SendMessageOptions.DontRequireReceiver); } fighting = false; }
private IEnumerator FightCoroutine(Alive target) { //Transform attackableSpot = target.GetClosestAttackableSpot( myTr.position ); //while ( fighting && !target.IsDead && IsCloseEnough(attackableSpot.position) ) { while ( fighting && (target != null) && !target.IsDead && IsCloseToFight(target.transform.position) ) { SendMessage("OnAttack", target, SendMessageOptions.DontRequireReceiver); yield return new WaitForSeconds(.4f); target.GetHit( this ); yield return new WaitForSeconds( attackRate ); } if (fighting && !target.IsDead) { SendMessage("OnTargetLost", target, SendMessageOptions.DontRequireReceiver); } if (target.IsDead) { SendMessage("OnTargetDead", target, SendMessageOptions.DontRequireReceiver); } fighting = false; }