Exemplo n.º 1
0
 public override void DoWork(PersonAI aI)
 {
     if (nearestStone == null)
     {
         aI.ReachedDestination = false;
         stoneNearby           = CheckNearbyResources(this.transform.position);
         if (stoneNearby.Count == 0)
         {
             SetBuildingEmpty(stones);
             this.maxWorkers = 0;
             aI.Idle();
             return;
         }
         nearestStone = GetShortestDistance(this.transform.position, stoneNearby, checkStoneRadius);
         nearestTile  = CheckNearbyTiles(nearestStone.placedTile, world);
         aI.MoveToPosition(nearestTile);
     }
     if (aI.ReachedDestination)
     {
         if (nearestStone == null || nearestStone.Worker != aI)
         {
             aI.ReachedDestination = false;
             stoneNearby           = CheckNearbyResources(this.transform.position);
             if (stoneNearby.Count == 0)
             {
                 SetBuildingEmpty(stones);
                 this.maxWorkers = 0;
                 aI.Idle();
                 return;
             }
             nearestStone = GetShortestDistance(this.transform.position, stoneNearby, checkStoneRadius);
             nearestTile  = CheckNearbyTiles(nearestStone.placedTile, world);
             aI.MoveToPosition(nearestTile);
         }
         GameplayController.instance.CurrentResources.Stone += stonePerWork;
         if (nearestStone.Anim != null)
         {
             nearestStone.Anim.Play();
         }
         nearestStone.Amount -= stonePerWork;
     }
 }
Exemplo n.º 2
0
 public override void WorkerAssigned(PersonAI aI)
 {
     base.WorkerAssigned(aI);
     aI.transform.position = spawnSpot.position;
     aI.UpdateCurrentTile();
     stoneNearby = CheckNearbyResources(this.transform.position);
     if (stoneNearby.Count == 0)
     {
         SetBuildingEmpty(stones);
         this.maxWorkers = 0;
         aI.Idle();
         return;
     }
     nearestStone        = GetShortestDistance(this.transform.position, stoneNearby, checkStoneRadius);
     nearestTile         = CheckNearbyTiles(nearestStone.placedTile, world);
     nearestStone.Worker = aI;
     aI.MoveToPosition(nearestTile);
 }