Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| cf0d7b2b35 | |||
| 19e2280875 | |||
| 4b83793066 |
@@ -1,5 +1,180 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!1 &857571624671216670
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 1245108835880382635}
|
||||
- component: {fileID: 1380240745138037931}
|
||||
- component: {fileID: 4291056457076491822}
|
||||
m_Layer: 0
|
||||
m_Name: storedLabel
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &1245108835880382635
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 857571624671216670}
|
||||
m_LocalRotation: {x: 0, y: 0.38268343, z: 0, w: 0.92387956}
|
||||
m_LocalPosition: {x: 0, y: 0, z: -1.358}
|
||||
m_LocalScale: {x: 0.15101083, y: 0.15101083, z: 0.15101083}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 8320751761511990669}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 45, z: 0}
|
||||
m_AnchorMin: {x: 0.5, y: 0.5}
|
||||
m_AnchorMax: {x: 0.5, y: 0.5}
|
||||
m_AnchoredPosition: {x: -1.312, y: 2.703}
|
||||
m_SizeDelta: {x: 20, y: 5}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!23 &1380240745138037931
|
||||
MeshRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 857571624671216670}
|
||||
m_Enabled: 1
|
||||
m_CastShadows: 0
|
||||
m_ReceiveShadows: 0
|
||||
m_DynamicOccludee: 1
|
||||
m_StaticShadowCaster: 0
|
||||
m_MotionVectors: 1
|
||||
m_LightProbeUsage: 1
|
||||
m_ReflectionProbeUsage: 1
|
||||
m_RayTracingMode: 2
|
||||
m_RayTraceProcedural: 0
|
||||
m_RayTracingAccelStructBuildFlagsOverride: 0
|
||||
m_RayTracingAccelStructBuildFlags: 1
|
||||
m_RenderingLayerMask: 1
|
||||
m_RendererPriority: 0
|
||||
m_Materials:
|
||||
- {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
|
||||
m_StaticBatchInfo:
|
||||
firstSubMesh: 0
|
||||
subMeshCount: 0
|
||||
m_StaticBatchRoot: {fileID: 0}
|
||||
m_ProbeAnchor: {fileID: 0}
|
||||
m_LightProbeVolumeOverride: {fileID: 0}
|
||||
m_ScaleInLightmap: 1
|
||||
m_ReceiveGI: 1
|
||||
m_PreserveUVs: 0
|
||||
m_IgnoreNormalsForChartDetection: 0
|
||||
m_ImportantGI: 0
|
||||
m_StitchLightmapSeams: 1
|
||||
m_SelectedEditorRenderState: 3
|
||||
m_MinimumChartSize: 4
|
||||
m_AutoUVMaxDistance: 0.5
|
||||
m_AutoUVMaxAngle: 89
|
||||
m_LightmapParameters: {fileID: 0}
|
||||
m_SortingLayerID: 0
|
||||
m_SortingLayer: 0
|
||||
m_SortingOrder: 0
|
||||
m_AdditionalVertexStreams: {fileID: 0}
|
||||
--- !u!114 &4291056457076491822
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 857571624671216670}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 9541d86e2fd84c1d9990edf0852d74ab, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Material: {fileID: 0}
|
||||
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_RaycastTarget: 1
|
||||
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
|
||||
m_Maskable: 1
|
||||
m_OnCullStateChanged:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_text: 10k
|
||||
m_isRightToLeft: 0
|
||||
m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
|
||||
m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
|
||||
m_fontSharedMaterials: []
|
||||
m_fontMaterial: {fileID: 0}
|
||||
m_fontMaterials: []
|
||||
m_fontColor32:
|
||||
serializedVersion: 2
|
||||
rgba: 4294967295
|
||||
m_fontColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_enableVertexGradient: 0
|
||||
m_colorMode: 3
|
||||
m_fontColorGradient:
|
||||
topLeft: {r: 1, g: 1, b: 1, a: 1}
|
||||
topRight: {r: 1, g: 1, b: 1, a: 1}
|
||||
bottomLeft: {r: 1, g: 1, b: 1, a: 1}
|
||||
bottomRight: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_fontColorGradientPreset: {fileID: 0}
|
||||
m_spriteAsset: {fileID: 0}
|
||||
m_tintAllSprites: 0
|
||||
m_StyleSheet: {fileID: 0}
|
||||
m_TextStyleHashCode: -1183493901
|
||||
m_overrideHtmlColors: 0
|
||||
m_faceColor:
|
||||
serializedVersion: 2
|
||||
rgba: 4294967295
|
||||
m_fontSize: 36
|
||||
m_fontSizeBase: 36
|
||||
m_fontWeight: 400
|
||||
m_enableAutoSizing: 0
|
||||
m_fontSizeMin: 18
|
||||
m_fontSizeMax: 72
|
||||
m_fontStyle: 0
|
||||
m_HorizontalAlignment: 2
|
||||
m_VerticalAlignment: 256
|
||||
m_textAlignment: 65535
|
||||
m_characterSpacing: 0
|
||||
m_wordSpacing: 0
|
||||
m_lineSpacing: 0
|
||||
m_lineSpacingMax: 0
|
||||
m_paragraphSpacing: 0
|
||||
m_charWidthMaxAdj: 0
|
||||
m_TextWrappingMode: 1
|
||||
m_wordWrappingRatios: 0.4
|
||||
m_overflowMode: 0
|
||||
m_linkedTextComponent: {fileID: 0}
|
||||
parentLinkedComponent: {fileID: 0}
|
||||
m_enableKerning: 0
|
||||
m_ActiveFontFeatures: 6e72656b
|
||||
m_enableExtraPadding: 0
|
||||
checkPaddingRequired: 0
|
||||
m_isRichText: 1
|
||||
m_EmojiFallbackSupport: 1
|
||||
m_parseCtrlCharacters: 1
|
||||
m_isOrthographic: 0
|
||||
m_isCullingEnabled: 0
|
||||
m_horizontalMapping: 0
|
||||
m_verticalMapping: 0
|
||||
m_uvLineOffset: 0
|
||||
m_geometrySortingOrder: 0
|
||||
m_IsTextObjectScaleStatic: 0
|
||||
m_VertexBufferAutoSizeReduction: 0
|
||||
m_useMaxVisibleDescender: 1
|
||||
m_pageToDisplay: 1
|
||||
m_margin: {x: 0, y: 0, z: 0, w: 0}
|
||||
m_isUsingLegacyAnimationComponent: 0
|
||||
m_isVolumetricText: 0
|
||||
_SortingLayer: 0
|
||||
_SortingLayerID: 0
|
||||
_SortingOrder: 0
|
||||
m_hasFontAssetChanged: 0
|
||||
m_renderer: {fileID: 1380240745138037931}
|
||||
m_maskType: 0
|
||||
--- !u!1 &891704993983032679
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -35,6 +210,7 @@ Transform:
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children:
|
||||
- {fileID: 264988062392608053}
|
||||
- {fileID: 1245108835880382635}
|
||||
m_Father: {fileID: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!33 &2507123039334392309
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -20,7 +20,7 @@ public class AssignableWorker : MonoBehaviour
|
||||
|
||||
public void AddWorker()
|
||||
{
|
||||
if(gameManager.GetResource(Resource.WORKER) > 0)
|
||||
if(gameManager.GetResourceCount(Resource.WORKER) > 0)
|
||||
{
|
||||
workersAssigned++;
|
||||
gameManager.RemoveResource(Resource.WORKER, 1);
|
||||
|
||||
@@ -36,11 +36,11 @@ public class Facility : MonoBehaviour
|
||||
|
||||
if (!processing) //Not processing but workers assigned, start new job if material is available
|
||||
{
|
||||
if (gameManager.GetResource(inputResource) < materialConsumption) return; //Not enough material
|
||||
if (gameManager.GetResourceCount(inputResource) < materialConsumption) return; //Not enough material
|
||||
|
||||
//Consumtion 5, 2
|
||||
int workerCount = (assignableWorker.GetAssignedWorkers() == 0 ? 1 : assignableWorker.GetAssignedWorkers());
|
||||
int maxPossibleBatch = gameManager.GetResource(inputResource) / materialConsumption;
|
||||
int maxPossibleBatch = gameManager.GetResourceCount(inputResource) / materialConsumption;
|
||||
currentProductionBatch = Mathf.Min(maxPossibleBatch, workerCount);
|
||||
|
||||
int requiredRessources = currentProductionBatch * materialConsumption;
|
||||
@@ -67,8 +67,9 @@ public class Facility : MonoBehaviour
|
||||
{
|
||||
if (processing) return; //Already processing
|
||||
|
||||
if (gameManager.GetResource(inputResource) < materialConsumption) return; //Not enough material
|
||||
if (gameManager.GetResourceCount(inputResource) < materialConsumption) return; //Not enough material
|
||||
|
||||
currentProductionBatch = 1;
|
||||
gameManager.RemoveResource(inputResource, materialConsumption);
|
||||
currentProcess = processingTime;
|
||||
processing = true;
|
||||
|
||||
@@ -17,6 +17,15 @@ public enum Resource
|
||||
}
|
||||
public class GameManager : MonoBehaviour
|
||||
{
|
||||
private int currentView = 0;
|
||||
|
||||
private Dictionary<Resource, int> committedResources = new Dictionary<Resource, int>()
|
||||
{
|
||||
{ Resource.BRICK, 0 },
|
||||
{ Resource.TILE, 0 },
|
||||
{ Resource.GLASS, 0 }
|
||||
};
|
||||
|
||||
private Dictionary<Resource, int> resources = new Dictionary<Resource, int>()
|
||||
{
|
||||
{ Resource.ROCK, 0 },
|
||||
@@ -27,15 +36,34 @@ public class GameManager : MonoBehaviour
|
||||
{ Resource.GLASS, 0 },
|
||||
{ Resource.HOUSE, 1 },
|
||||
{ Resource.WORKER, 0 },
|
||||
{ Resource.TOTAL_WORKER, 0 },
|
||||
{ Resource.TOTAL_WORKER, 0 }
|
||||
};
|
||||
|
||||
|
||||
public TMPro.TMP_Text debugText;
|
||||
[SerializeField]
|
||||
private TMPro.TMP_Text resourceLabel;
|
||||
[SerializeField]
|
||||
private TMPro.TMP_Text housingLabel;
|
||||
|
||||
[Header("Map View")]
|
||||
[SerializeField]
|
||||
private Transform worldMapCameraPos;
|
||||
[SerializeField]
|
||||
private GameObject mainViewBtn, commitBtn;
|
||||
|
||||
[Header("Main View")]
|
||||
[SerializeField]
|
||||
private Transform mainCameraPos;
|
||||
[SerializeField]
|
||||
private GameObject mapViewBtn;
|
||||
|
||||
private MonumentManager monumentManager;
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
Camera.main.transform.position = mainCameraPos.position;
|
||||
monumentManager = GameObject.Find("MonumentManager").GetComponent<MonumentManager>();
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
@@ -46,6 +74,24 @@ public class GameManager : MonoBehaviour
|
||||
{
|
||||
debugText.text += item.ToString();
|
||||
}
|
||||
|
||||
housingLabel.text = $"{resources[Resource.HOUSE]} Houses\n" +
|
||||
$"{resources[Resource.WORKER]} Workers";
|
||||
resourceLabel.text = $"Resources:\n" +
|
||||
$"Storage: Bricks {resources[Resource.BRICK]} | Tiles {resources[Resource.TILE]} | Glass {resources[Resource.GLASS]}\n" +
|
||||
$"Comitted: Bricks {committedResources[Resource.BRICK]} | Tiles {committedResources[Resource.TILE]} | Glass {committedResources[Resource.GLASS]}";
|
||||
}
|
||||
|
||||
public void CommitResources()
|
||||
{
|
||||
List<Resource> resourceList = new List<Resource>(committedResources.Keys);
|
||||
foreach (Resource resource in resourceList)
|
||||
{
|
||||
committedResources[resource] += GetResourceCount(resource);
|
||||
RemoveResource(resource, GetResourceCount(resource));
|
||||
}
|
||||
|
||||
monumentManager.UpdateUnlocks();
|
||||
}
|
||||
|
||||
public void AddResource(Resource res, int amt)
|
||||
@@ -58,9 +104,34 @@ public class GameManager : MonoBehaviour
|
||||
resources[res] -= amt;
|
||||
}
|
||||
|
||||
public int GetResource(Resource res)
|
||||
public int GetResourceCount(Resource res)
|
||||
{
|
||||
return resources[res];
|
||||
}
|
||||
|
||||
public Dictionary<Resource, int> GetCommitedResources()
|
||||
{
|
||||
return new Dictionary<Resource, int>(committedResources);
|
||||
}
|
||||
|
||||
public void SetView(int view)
|
||||
{
|
||||
switch (view)
|
||||
{
|
||||
case 0: //Main view
|
||||
Camera.main.transform.position = mainCameraPos.position;
|
||||
mainViewBtn.SetActive(false);
|
||||
mapViewBtn.SetActive(true);
|
||||
commitBtn.SetActive(false);
|
||||
break;
|
||||
case 1: //Map View
|
||||
Camera.main.transform.position = worldMapCameraPos.position;
|
||||
mainViewBtn.SetActive(true);
|
||||
mapViewBtn.SetActive(false);
|
||||
commitBtn.SetActive(true);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,9 +24,9 @@ public class HouseManager : MonoBehaviour
|
||||
} else
|
||||
{
|
||||
currentTtnw = ttnw;
|
||||
if (gameManager.GetResource(Resource.TOTAL_WORKER) < gameManager.GetResource(Resource.HOUSE) * workerPerHouse)
|
||||
if (gameManager.GetResourceCount(Resource.TOTAL_WORKER) < gameManager.GetResourceCount(Resource.HOUSE) * workerPerHouse)
|
||||
{
|
||||
int freeWorkerSlots = (gameManager.GetResource(Resource.HOUSE) * workerPerHouse) - gameManager.GetResource(Resource.TOTAL_WORKER);
|
||||
int freeWorkerSlots = (gameManager.GetResourceCount(Resource.HOUSE) * workerPerHouse) - gameManager.GetResourceCount(Resource.TOTAL_WORKER);
|
||||
int newWorkers = Mathf.CeilToInt((float)freeWorkerSlots / workerPerHouse);
|
||||
gameManager.AddResource(Resource.WORKER, newWorkers);
|
||||
gameManager.AddResource(Resource.TOTAL_WORKER, newWorkers);
|
||||
@@ -36,9 +36,9 @@ public class HouseManager : MonoBehaviour
|
||||
|
||||
public void BuildHouse()
|
||||
{
|
||||
if (gameManager.GetResource(Resource.BRICK) < 10 ||
|
||||
gameManager.GetResource(Resource.TILE) < 5 ||
|
||||
gameManager.GetResource(Resource.GLASS) < 2)
|
||||
if (gameManager.GetResourceCount(Resource.BRICK) < 10 ||
|
||||
gameManager.GetResourceCount(Resource.TILE) < 5 ||
|
||||
gameManager.GetResourceCount(Resource.GLASS) < 2)
|
||||
{
|
||||
Debug.Log("Not enough resources to build house!");
|
||||
return;
|
||||
|
||||
@@ -8,6 +8,8 @@ public class Mine : MonoBehaviour
|
||||
public Resource resource;
|
||||
private GameManager gameManager;
|
||||
|
||||
[SerializeField]
|
||||
private TMPro.TextMeshPro storedLabel;
|
||||
private float nextTick = 0f;
|
||||
private AssignableWorker assignableWorker;
|
||||
// Start is called before the first frame update
|
||||
@@ -31,6 +33,7 @@ public class Mine : MonoBehaviour
|
||||
|
||||
private void Tick()
|
||||
{
|
||||
storedLabel.text = gameManager.GetResourceCount(resource).ToString();
|
||||
gameManager.AddResource(resource, 1 * assignableWorker.GetAssignedWorkers());
|
||||
}
|
||||
|
||||
|
||||
74
Assets/Scripts/MonumentManager.cs
Normal file
74
Assets/Scripts/MonumentManager.cs
Normal file
@@ -0,0 +1,74 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
|
||||
[System.Serializable]
|
||||
public class Monument
|
||||
{
|
||||
public string name;
|
||||
public string description;
|
||||
public int brickCost, tileCost, glassCost;
|
||||
public GameObject worldObject;
|
||||
}
|
||||
public class MonumentManager : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
private List<Monument> monuments = new List<Monument>();
|
||||
[SerializeField]
|
||||
private TMP_Text nextUnlockLabel;
|
||||
|
||||
private GameManager gameManager;
|
||||
private Dictionary<Resource, int> resourcesForNextUnlock;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
gameManager = GameObject.Find("GameManager").GetComponent<GameManager>();
|
||||
UpdateUnlocks();
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void UpdateUnlocks()
|
||||
{
|
||||
Dictionary<Resource, int> availableResources = gameManager.GetCommitedResources();
|
||||
int lastMonumentIndex = -1;
|
||||
|
||||
for (int i = 0; i < monuments.Count; i++)
|
||||
{
|
||||
Monument monument = monuments[i];
|
||||
if(availableResources[Resource.BRICK] >= monument.brickCost &&
|
||||
availableResources[Resource.TILE] >= monument.tileCost &&
|
||||
availableResources[Resource.GLASS] >= monument.glassCost )
|
||||
{
|
||||
availableResources[Resource.BRICK] -= monument.brickCost;
|
||||
availableResources[Resource.TILE] -= monument.tileCost;
|
||||
availableResources[Resource.GLASS] -= monument.glassCost;
|
||||
monument.worldObject.GetComponent<Renderer>().material.color = Color.green;
|
||||
lastMonumentIndex = i;
|
||||
} else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
resourcesForNextUnlock = availableResources;
|
||||
|
||||
if (lastMonumentIndex == monuments.Count-1)
|
||||
{
|
||||
Debug.Log("All unlocked");
|
||||
return;
|
||||
}
|
||||
|
||||
nextUnlockLabel.text = $"Next Unlock: {monuments[lastMonumentIndex + 1].name} (" +
|
||||
$" B: {resourcesForNextUnlock[Resource.BRICK]}/{monuments[lastMonumentIndex + 1].brickCost}" +
|
||||
$" T: {resourcesForNextUnlock[Resource.TILE]}/{monuments[lastMonumentIndex + 1].tileCost}" +
|
||||
$" G: {resourcesForNextUnlock[Resource.GLASS]}/{monuments[lastMonumentIndex + 1].glassCost})";
|
||||
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/MonumentManager.cs.meta
Normal file
2
Assets/Scripts/MonumentManager.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ec105ee063189bf4fba3ec1ba36e36ea
|
||||
18
Assets/Scripts/UI/WorldMapUI.cs
Normal file
18
Assets/Scripts/UI/WorldMapUI.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
public class WorldMapUI : MonoBehaviour
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/UI/WorldMapUI.cs.meta
Normal file
2
Assets/Scripts/UI/WorldMapUI.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3f5605aef187419469548c23842f08da
|
||||
@@ -4,5 +4,12 @@
|
||||
EditorBuildSettings:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 2
|
||||
m_Scenes: []
|
||||
m_Scenes:
|
||||
- enabled: 1
|
||||
path: Assets/Scenes/Main.unity
|
||||
guid: 08f986a56e32d3a42bfba00595e560dd
|
||||
- enabled: 1
|
||||
path: Assets/Scenes/WorldMap.unity
|
||||
guid: 4eebe4d020578664287352b495c15e8c
|
||||
m_configObjects: {}
|
||||
m_UseUCBPForAssetBundles: 0
|
||||
|
||||
Reference in New Issue
Block a user