Ejemplo n.º 1
0
 private void Awake()
 {
     humanAnimationController = gameObject.GetComponent <HumanAnimationController>();
     humanMovementController  = gameObject.GetComponent <HumanMovementController>();
     waitBeforeNextStep       = gameObject.AddComponent <Countdown>();
     pathInProgress           = PathInProgress.NOT_MOVING;
 }
Ejemplo n.º 2
0
    private void setRandomTargetPositionNearby()
    {
        var end = new int2(
            humanMovementController.getPosition().x + random(-1, 1),
            humanMovementController.getPosition().y + random(-1, 1, DateTime.Now.Millisecond + 1)
            );

        pathInProgress = humanMovementController.goTo(end);
    }
Ejemplo n.º 3
0
    private void Awake()
    {
        humanAnimationController = gameObject.GetComponent <HumanAnimationController>();
        humanMovementController  = gameObject.GetComponent <HumanMovementController>();

        var oneSquareBelow = new int2(humanMovementController.getPosition().x,
                                      humanMovementController.getPosition().y - 1);

        pathInProgress = humanMovementController.goTo(oneSquareBelow);
    }
Ejemplo n.º 4
0
 private void Awake()
 {
     humanController          = gameObject.GetComponent <HumanController>();
     humanAnimationController = gameObject.GetComponent <HumanAnimationController>();
     humanMovementController  = gameObject.GetComponent <HumanMovementController>();
     pathInProgress           = PathInProgress.NOT_MOVING;
     state = determineState();
     timeToGatherCountdown    = gameObject.AddComponent <Countdown>();
     timeToDepositCountdown   = gameObject.AddComponent <Countdown>();
     timeBeforeRetryCountdown = gameObject.AddComponent <Countdown>();
 }
Ejemplo n.º 5
0
 private void goGather()
 {
     if (!pathInProgress.isMoving() && retry)
     {
         var berryTreeController = getNearestBerryTreeMaybeCurrentlyCut();
         if (berryTreeController != null)
         {
             cutBerryTree(berryTreeController);
         }
         else
         {
             pathInProgress = humanMovementController.goToNearest(new GOTBerryTree(TreeStateEnum.FULL, null));
             if (!pathInProgress.isMoving())
             {
                 waitBeforeRetry();
             }
         }
     }
 }
Ejemplo n.º 6
0
 private void goReturnResource()
 {
     if (!pathInProgress.isMoving() && retry)
     {
         var townHallController = (TownHall)humanMovementController.getIfInRange(new GOTTownHall());
         if (townHallController != null)
         {
             depositFoodInto(townHallController);
         }
         else
         {
             pathInProgress = humanMovementController.goToNearest(new GOTTownHall());
             if (!pathInProgress.isMoving())
             {
                 waitBeforeRetry();
             }
         }
     }
 }
Ejemplo n.º 7
0
    public PathInProgress calculatePathToNearest(int2 start, IGridObjectType gridObjectType)
    {
        var pathfinding = new Pathfinding(width, height, cellSize, grid);

        return(PathInProgress.setPathToNearest(start, gridObjectType, pathfinding));
    }
Ejemplo n.º 8
0
    public PathInProgress calculatePath(int2 start, int2 end)
    {
        var pathfinding = new Pathfinding(width, height, cellSize, grid);

        return(PathInProgress.setPath(start, end, pathfinding));
    }
Ejemplo n.º 9
0
 private static bool isInRange(PathInProgress pathInProgress)
 {
     return(pathInProgress.isInARangeOf(RANGE));
 }