Initial commit
This commit is contained in:
@@ -74,6 +74,15 @@ public class Building : MonoBehaviour
|
||||
{
|
||||
return buildingState;
|
||||
}
|
||||
public Resource.ResourceType[] GetResourceRequirement()
|
||||
{
|
||||
return constructionResources;
|
||||
}
|
||||
|
||||
public int[] GetConstructionCost()
|
||||
{
|
||||
return constructionCost;
|
||||
}
|
||||
private void SetBuildingModel(BuildingState state)
|
||||
{
|
||||
switch (state)
|
||||
@@ -105,24 +114,27 @@ public class Building : MonoBehaviour
|
||||
break;
|
||||
}
|
||||
}
|
||||
public void StartBuilding()
|
||||
{
|
||||
if (buildingState != BuildingState.Unbuilt)
|
||||
return;
|
||||
public void StartBuilding()
|
||||
{
|
||||
if (buildingState != BuildingState.Unbuilt)
|
||||
return;
|
||||
|
||||
for (int i = 0; i < constructionResources.Length && i < constructionCost.Length; i++)
|
||||
Resource.ResourceType[] resources = GetResourceRequirement();
|
||||
int[] costs = GetConstructionCost();
|
||||
|
||||
for (int i = 0; i < resources.Length && i < costs.Length; i++)
|
||||
{
|
||||
if (GameManager.Instance.GetResource(resources[i]) < costs[i])
|
||||
{
|
||||
if (GameManager.Instance.GetResource(constructionResources[i]) < constructionCost[i])
|
||||
{
|
||||
Debug.Log("Not enough resources");
|
||||
return;
|
||||
}
|
||||
GameManager.Instance.AddResource(constructionResources[i], -constructionCost[i]);
|
||||
Debug.Log("Not enough resources");
|
||||
return;
|
||||
}
|
||||
Debug.Log("Building Started");
|
||||
buildingState = BuildingState.Constructing;
|
||||
SetBuildingModel(buildingState);
|
||||
GameManager.Instance.AddResource(resources[i], -costs[i]);
|
||||
}
|
||||
Debug.Log("Building Started");
|
||||
buildingState = BuildingState.Constructing;
|
||||
SetBuildingModel(buildingState);
|
||||
}
|
||||
public void FinishBuilding()
|
||||
{
|
||||
if (buildingState != BuildingState.Constructing)
|
||||
|
||||
Reference in New Issue
Block a user