Started working on Builder job and building buildings
This commit is contained in:
@@ -51,7 +51,7 @@ Material:
|
|||||||
m_Scale: {x: 1, y: 1}
|
m_Scale: {x: 1, y: 1}
|
||||||
m_Offset: {x: 0, y: 0}
|
m_Offset: {x: 0, y: 0}
|
||||||
- _MainTex:
|
- _MainTex:
|
||||||
m_Texture: {fileID: 0}
|
m_Texture: {fileID: 2800000, guid: 51148e3057e25994c80f5321340afc7b, type: 3}
|
||||||
m_Scale: {x: 1, y: 1}
|
m_Scale: {x: 1, y: 1}
|
||||||
m_Offset: {x: 0, y: 0}
|
m_Offset: {x: 0, y: 0}
|
||||||
- _MetallicGlossMap:
|
- _MetallicGlossMap:
|
||||||
|
|||||||
3814
Assets/Prefabs/Buildings/House.prefab
Normal file
3814
Assets/Prefabs/Buildings/House.prefab
Normal file
File diff suppressed because it is too large
Load Diff
7
Assets/Prefabs/Buildings/House.prefab.meta
Normal file
7
Assets/Prefabs/Buildings/House.prefab.meta
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 951751753bd491349a68c9f347c3782c
|
||||||
|
PrefabImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
3406
Assets/Prefabs/NPC.prefab
Normal file
3406
Assets/Prefabs/NPC.prefab
Normal file
File diff suppressed because it is too large
Load Diff
7
Assets/Prefabs/NPC.prefab.meta
Normal file
7
Assets/Prefabs/NPC.prefab.meta
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: f97a75ea176e29648bedd5f9d0da92c4
|
||||||
|
PrefabImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -6,15 +6,16 @@ public class GameManager : MonoBehaviour
|
|||||||
{
|
{
|
||||||
public Dictionary<Resource.ResourceType, int> statistics = new Dictionary<Resource.ResourceType, int>();
|
public Dictionary<Resource.ResourceType, int> statistics = new Dictionary<Resource.ResourceType, int>();
|
||||||
public static GameManager Instance;
|
public static GameManager Instance;
|
||||||
[SerializeField]private float money, citizens, wood, stone, metal;
|
[SerializeField]private float money, population, wood, stone, metal;
|
||||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||||
void Awake()
|
void Awake()
|
||||||
{
|
{
|
||||||
Instance = this;
|
Instance = this;
|
||||||
|
CalculatePopulation();
|
||||||
}
|
}
|
||||||
void Start()
|
void Start()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
// Update is called once per frame
|
// Update is called once per frame
|
||||||
void Update()
|
void Update()
|
||||||
@@ -37,8 +38,8 @@ public class GameManager : MonoBehaviour
|
|||||||
case Resource.ResourceType.Money:
|
case Resource.ResourceType.Money:
|
||||||
money += amountToAdd;
|
money += amountToAdd;
|
||||||
break;
|
break;
|
||||||
case Resource.ResourceType.Citizens:
|
case Resource.ResourceType.Population:
|
||||||
citizens += amountToAdd;
|
population += amountToAdd;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -54,9 +55,19 @@ public class GameManager : MonoBehaviour
|
|||||||
return metal;
|
return metal;
|
||||||
case Resource.ResourceType.Money:
|
case Resource.ResourceType.Money:
|
||||||
return money;
|
return money;
|
||||||
case Resource.ResourceType.Citizens:
|
case Resource.ResourceType.Population:
|
||||||
return citizens;
|
return population;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
public void CalculatePopulation()
|
||||||
|
{
|
||||||
|
NPC[] npcs = FindObjectsByType<NPC>(FindObjectsSortMode.None);
|
||||||
|
AddResource(Resource.ResourceType.Population, npcs.Length);
|
||||||
|
}
|
||||||
|
public Building[] CountBuildings()
|
||||||
|
{
|
||||||
|
Building[] buildings = FindObjectsByType<Building>(FindObjectsSortMode.None);
|
||||||
|
return buildings;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
33
Assets/Scripts/JobManager.cs
Normal file
33
Assets/Scripts/JobManager.cs
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
2
Assets/Scripts/JobManager.cs.meta
Normal file
2
Assets/Scripts/JobManager.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 4bd36540681fbaa4eb9be52d4b051ace
|
||||||
@@ -20,7 +20,7 @@ public class NPC : MonoBehaviour
|
|||||||
[SerializeField] Animator animationController;
|
[SerializeField] Animator animationController;
|
||||||
[SerializeField] float movementSpeed, interactionRadius;
|
[SerializeField] float movementSpeed, interactionRadius;
|
||||||
[SerializeField] Image jobImg;
|
[SerializeField] Image jobImg;
|
||||||
[SerializeField] Sprite miner, forester, citizen, farmer, merchant, soldier;
|
[SerializeField] Sprite miner, forester, citizen, farmer, merchant, soldier, builder;
|
||||||
|
|
||||||
private Resource currentTargetResource;
|
private Resource currentTargetResource;
|
||||||
private Building currentTargetBuilding; // Cache the TownHall so we don't search for it every frame
|
private Building currentTargetBuilding; // Cache the TownHall so we don't search for it every frame
|
||||||
@@ -209,6 +209,8 @@ public class NPC : MonoBehaviour
|
|||||||
switch (job)
|
switch (job)
|
||||||
{
|
{
|
||||||
case Job.Builder:
|
case Job.Builder:
|
||||||
|
//resourceToWorkWith = Resource.ResourceType.Building;
|
||||||
|
jobImg.sprite = builder;
|
||||||
break;
|
break;
|
||||||
case Job.Soldier:
|
case Job.Soldier:
|
||||||
break;
|
break;
|
||||||
@@ -227,7 +229,7 @@ public class NPC : MonoBehaviour
|
|||||||
jobImg.sprite = miner;
|
jobImg.sprite = miner;
|
||||||
break;
|
break;
|
||||||
case Job.Citizen:
|
case Job.Citizen:
|
||||||
resourceToWorkWith = Resource.ResourceType.Citizens;
|
resourceToWorkWith = Resource.ResourceType.Population;
|
||||||
jobImg.sprite = citizen;
|
jobImg.sprite = citizen;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,8 +8,9 @@ public class Resource : MonoBehaviour
|
|||||||
Stone,
|
Stone,
|
||||||
Metal,
|
Metal,
|
||||||
Money,
|
Money,
|
||||||
Citizens,
|
Population,
|
||||||
Food
|
Food,
|
||||||
|
Building
|
||||||
}
|
}
|
||||||
public ResourceType resourceType;
|
public ResourceType resourceType;
|
||||||
public enum ResourceState
|
public enum ResourceState
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ public class UIController : MonoBehaviour
|
|||||||
{
|
{
|
||||||
wood.text = GameManager.Instance.GetResource(Resource.ResourceType.Wood).ToString();
|
wood.text = GameManager.Instance.GetResource(Resource.ResourceType.Wood).ToString();
|
||||||
stone.text = GameManager.Instance.GetResource(Resource.ResourceType.Stone).ToString();
|
stone.text = GameManager.Instance.GetResource(Resource.ResourceType.Stone).ToString();
|
||||||
population.text = GameManager.Instance.GetResource(Resource.ResourceType.Citizens).ToString();
|
population.text = GameManager.Instance.GetResource(Resource.ResourceType.Population).ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called by left-clicking a JobButton
|
// Called by left-clicking a JobButton
|
||||||
|
|||||||
Reference in New Issue
Block a user