Esempio n. 1
0
    IEnumerator PostReachActionCoroutine()
    {
        // If the target is in action range, execute PostReachAction
        if (reached)
        {
            StartCoroutine("PostReachAction");
            while (!finishedPostReachAction)
            {
                yield return(null);
            }
        }
        // If lost target, turns to Warning state
        else if (!MazeUTL.CheckTargetInRangeAndDetectRegion(owner.CurrentTile, actionTarget.CurrentTile, owner.detectRange))
        {
            yield return(new WaitForSeconds(0.5f));

            if (owner.detectState == DetectState.Alerted)
            {
                owner.detectState = DetectState.Warning;
            }
        }

        SetActionFinished("PostReachActionCoroutine", true);
        yield return(null);
    }
Esempio n. 2
0
    //---------------------------------------
    //      Action
    //---------------------------------------
    IEnumerator TryReachActionRangeCoroutine()
    {
        CheckReached();

        if (!reached)
        {
            if (!MazeUTL.CheckTargetInRangeAndDetectRegion(owner.CurrentTile, actionTarget.CurrentTile, actionRange))
            {
                List <Tile> path = MazeUTL.GetShortestPath(owner.CurrentTile, actionTarget.CurrentTile, owner.detectRange);
                for (int i = 0; i < path.Count; i++)
                {
                    owner.TryMoveToTile(path[i]);
                    do
                    {
                        CheckReached();
                        yield return(new WaitForSeconds(0.01f));
                    } while (owner.CurrentAction == ActionType.Walking);

                    if (reached)
                    {
                        break;
                    }
                }
                owner.StopWalkingAnim();
            }
        }

        SetActionFinished("TryReachActionRangeCoroutine", true);
    }
Esempio n. 3
0
 //---------------------------------------
 //      Detection Logic
 //---------------------------------------
 void UpdateDetectState()
 {
     if (MazeUTL.CheckTargetInRangeAndDetectRegion(CurrentTile, level.playerCharacter.CurrentTile, detectRange))
     {
         detectState = DetectState.Alerted;
     }
 }
Esempio n. 4
0
    void CheckReached()
    {
        if (reached)
        {
            return;
        }
        if (actionTarget == null)
        {
            return;
        }
        if (!MazeUTL.CheckTargetInRangeAndDetectRegion(owner.CurrentTile, actionTarget.CurrentTile, actionRange))
        {
            return;
        }

        reached = true;
    }