34 lines
873 B
C#
34 lines
873 B
C#
|
|
using UnityEngine;
|
||
|
|
|
||
|
|
public class JobManager : MonoBehaviour
|
||
|
|
{
|
||
|
|
private Building targetBuilding;
|
||
|
|
private Resource targetResource;
|
||
|
|
private NPC targetNPC;
|
||
|
|
public void RequestJob(NPC.Job jobType)
|
||
|
|
{
|
||
|
|
switch (jobType)
|
||
|
|
{
|
||
|
|
case NPC.Job.Builder:
|
||
|
|
targetBuilding = GetUnfinishedBuildings();
|
||
|
|
if(targetBuilding != null)
|
||
|
|
{
|
||
|
|
targetBuilding.StartBuilding();
|
||
|
|
}
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
private Building GetUnfinishedBuildings()
|
||
|
|
{
|
||
|
|
Building[] buildings = GameManager.Instance.CountBuildings();
|
||
|
|
foreach (Building building in buildings)
|
||
|
|
{
|
||
|
|
if(building.GetBuildingState() == Building.BuildingState.Unbuilt)
|
||
|
|
{
|
||
|
|
return building;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
return null;
|
||
|
|
}
|
||
|
|
}
|