Ejemplo n.º 1
0
    public IEnumerator <Coroutine> FindPathAndMove(TriCell target, bool entityCheck, bool terrainCheck)
    {
        TriGrid inst = TriGrid.Instance;

        if (target && IsValidDestination(target))
        {
            inst.FindPath(Location, target, entityCheck, terrainCheck);
            if (inst.HasPath)
            {
                pathToTravel = inst.GetPath();
                CancelNowAct();
                yield return(nowRoutine = StartCoroutine(TravelPath()));

                inst.ClearPath();
                ActResult = true;
            }
            else
            {
                ActResult = false;
            }
        }
        else
        {
            inst.ClearPath();
            ActResult = false;
        }
        yield return(null);
    }
Ejemplo n.º 2
0
 public void SetEditMode(bool toggle)
 {
     enabled = !toggle;
     grid.ClearPath();
 }
Ejemplo n.º 3
0
 public override void Tick()
 {
     base.Tick();
     if (Clock.IsDay())
     {
         if (Work)
         {
             RoutineTarget = Work;
         }
         else if (Company)
         {
             RoutineTarget = Company;
         }
         else if (Home)
         {
             RoutineTarget = Home;
         }
         else
         {
             RoutineTarget = TriIsland.GetCamp();
         }
     }
     else
     {
         if (Home)
         {
             RoutineTarget = Home;
         }
         else
         {
             RoutineTarget = TriIsland.GetCamp();
         }
     }
     if (nowWork == null && !acting && commandQueue.Count == 0 && RoutineTarget && RoutineTarget != Building)
     {
         CancelAllAct();
         Debug.LogWarning("<color=#ff0000>act canceled</color> and moved to : " + routineTarget);
         TriGrid inst = TriGrid.Instance;
         inst.FindPath(Location, routineTarget.EntranceLocation, true, true);
         if (inst.HasPath)
         {
             inst.ClearPath();
             AddCommand(new MoveCommand(RoutineTarget.EntranceLocation, true, true));
             AddCommand(new GetInCommand(RoutineTarget));
         }
         else
         {
             inst.ClearPath();
             if (RoutineTarget == Work)
             {
                 AddCommand(new ChangeWorkCommand(null));
             }
             else if (RoutineTarget == Company)
             {
                 AddCommand(new ChangeJobCommand(null));
             }
             else if (RoutineTarget == Home)
             {
                 AddCommand(new ChangeHomeCommand(null));
             }
         }
     }
 }