예제 #1
0
 public override void UpdateAction()
 {
     if (!isDone)
     {
         if (currentAction.IsDone())
         {
             NextAction();
         }
         currentAction.UpdateAction();
     }
 }
 public override void UpdateAction()
 {
     if (!isDone)
     {
         if (currentAction.IsDone())
         {
             currentAction = new GotoPosition(dog, GetRandomTarget(), 0.5f);
         }
         currentAction.UpdateAction();
     }
 }
예제 #3
0
 public override void UpdateAction()
 {
     if (!isDone)
     {
         if (!currentAction.IsDone())
         {
             currentAction.UpdateAction();
         }
         else
         {
             isDone = true;
         }
     }
 }
 public override void UpdateAction()
 {
     if (!isDone)
     {
         currentAction.UpdateAction();
         if (Vector2.Distance(new Vector2(dog.transform.position.x, dog.transform.position.z), new Vector2(target.x, target.z)) < width)
         {
             if (waitForPlayerAtTarget)
             {
                 if (Vector2.Distance(new Vector2(player.position.x, player.position.z), new Vector2(target.x, target.z)) < 5f)
                 {
                     isDone = true;
                 }
             }
             else
             {
                 isDone = true;
             }
         }
         if (!ShouldWait())
         {
             if (isWaiting)
             {
                 if (currentAction.IsDone())
                 {
                     currentAction.EndAction();
                     currentAction = new GoStraightToPosition(dog, target, 1.5f);
                     currentAction.StartAction();
                     isWaiting = false;
                 }
             }
         }
         else
         {
             if (!isWaiting)
             {
                 currentAction.EndAction();
                 currentAction = new WaitForPlayer(dog, player, target, maxDistance / 2);
                 currentAction.StartAction();
                 isWaiting = true;
             }
         }
     }
 }
예제 #5
0
 void Update()
 {
     if (savedAction != null)
     {
         Debug.Log("saved action " + savedAction.ToString());
     }
     Debug.DrawLine(transform.position, transform.position + transform.forward * 3, Color.yellow);
     if (itemHand != null && itemHand.GetItemInHand() != null && itemHand.GetItemInHand().name == "Stick")
     {
         if (currentAction != null && currentAction.GetImportance() == DogAction.Importance.HIGH)
         {
             savedAction = currentAction;
         }
         if (Vector3.Distance(transform.position, player.position) < 3)
         {
             if (!isWaitingForFetch)
             {
                 ai.StartAction(new WaitForFetch(this, player));
             }
         }
         else
         {
             ai.StartAction(new FollowPlayer(this, player));
         }
     }
     if (currentAction != null)
     {
         currentAction.UpdateAction();
     }
     else if (savedAction != null)
     {
         currentAction = savedAction;
         currentAction.StartAction();
         savedAction = null;
     }
 }