Finish monument unlocking mvp

This commit is contained in:
2024-08-18 21:51:12 +02:00
committed by Minz
parent 6303d8c2fa
commit fedf29bebe
6 changed files with 1385 additions and 169 deletions

View File

@@ -1,5 +1,180 @@
%YAML 1.1 %YAML 1.1
%TAG !u! tag:unity3d.com,2011: %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 --- !u!1 &891704993983032679
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@@ -35,6 +210,7 @@ Transform:
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: m_Children:
- {fileID: 264988062392608053} - {fileID: 264988062392608053}
- {fileID: 1245108835880382635}
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!33 &2507123039334392309 --- !u!33 &2507123039334392309

File diff suppressed because it is too large Load Diff

View File

@@ -19,6 +19,13 @@ public class GameManager : MonoBehaviour
{ {
private int currentView = 0; 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>() private Dictionary<Resource, int> resources = new Dictionary<Resource, int>()
{ {
{ Resource.ROCK, 0 }, { Resource.ROCK, 0 },
@@ -29,21 +36,34 @@ public class GameManager : MonoBehaviour
{ Resource.GLASS, 0 }, { Resource.GLASS, 0 },
{ Resource.HOUSE, 1 }, { Resource.HOUSE, 1 },
{ Resource.WORKER, 0 }, { Resource.WORKER, 0 },
{ Resource.TOTAL_WORKER, 0 }, { Resource.TOTAL_WORKER, 0 }
}; };
public TMPro.TMP_Text debugText; public TMPro.TMP_Text debugText;
[SerializeField] [SerializeField]
GameObject mainViewBtn, mapViewBtn; private TMPro.TMP_Text resourceLabel;
[SerializeField] [SerializeField]
private Transform mainCameraPos, worldMapCameraPos; 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 // Start is called before the first frame update
void Start() void Start()
{ {
Camera.main.transform.position = mainCameraPos.position; Camera.main.transform.position = mainCameraPos.position;
monumentManager = GameObject.Find("MonumentManager").GetComponent<MonumentManager>();
} }
// Update is called once per frame // Update is called once per frame
@@ -54,6 +74,24 @@ public class GameManager : MonoBehaviour
{ {
debugText.text += item.ToString(); 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) public void AddResource(Resource res, int amt)
@@ -71,19 +109,26 @@ public class GameManager : MonoBehaviour
return resources[res]; return resources[res];
} }
public Dictionary<Resource, int> GetCommitedResources()
{
return new Dictionary<Resource, int>(committedResources);
}
public void SetView(int view) public void SetView(int view)
{ {
switch (view) switch (view)
{ {
case 0: //Main view case 0: //Main view
Camera.main.transform.position = mainCameraPos.position; Camera.main.transform.position = mainCameraPos.position;
mainViewBtn.SetActive(true); mainViewBtn.SetActive(false);
mapViewBtn.SetActive(false); mapViewBtn.SetActive(true);
commitBtn.SetActive(false);
break; break;
case 1: //Map View case 1: //Map View
Camera.main.transform.position = worldMapCameraPos.position; Camera.main.transform.position = worldMapCameraPos.position;
mainViewBtn.SetActive(false); mainViewBtn.SetActive(true);
mapViewBtn.SetActive(true); mapViewBtn.SetActive(false);
commitBtn.SetActive(true);
break; break;
default: default:
break; break;

View File

@@ -8,6 +8,8 @@ public class Mine : MonoBehaviour
public Resource resource; public Resource resource;
private GameManager gameManager; private GameManager gameManager;
[SerializeField]
private TMPro.TextMeshPro storedLabel;
private float nextTick = 0f; private float nextTick = 0f;
private AssignableWorker assignableWorker; private AssignableWorker assignableWorker;
// Start is called before the first frame update // Start is called before the first frame update
@@ -31,6 +33,7 @@ public class Mine : MonoBehaviour
private void Tick() private void Tick()
{ {
storedLabel.text = gameManager.GetResourceCount(resource).ToString();
gameManager.AddResource(resource, 1 * assignableWorker.GetAssignedWorkers()); gameManager.AddResource(resource, 1 * assignableWorker.GetAssignedWorkers());
} }

View 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})";
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: ec105ee063189bf4fba3ec1ba36e36ea