Exemplo n.º 1
0
    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;
    }
Exemplo n.º 2
0
    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;
    }