mirror of
https://github.com/DerTyp7/fps-citybuild-unity.git
synced 2025-10-29 12:22:07 +01:00
ResourceText
This commit is contained in:
@@ -7,4 +7,12 @@ public abstract class Building : MonoBehaviour
|
||||
public string title = "New Building";
|
||||
public string description = "A cool new building";
|
||||
|
||||
public enum BuildingType
|
||||
{
|
||||
Housing,
|
||||
Storage,
|
||||
Decoration
|
||||
}
|
||||
|
||||
public BuildingType buildingType;
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ public class HouseBuildingScript : Building
|
||||
{
|
||||
title = "House";
|
||||
description = "A place to live in";
|
||||
buildingType = BuildingType.Housing;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -7,7 +7,10 @@ public class StorageBuilding : Building
|
||||
[SerializeField] private List<Item> inventory = new List<Item>();
|
||||
public int inventorySpace;
|
||||
|
||||
|
||||
public void Start()
|
||||
{
|
||||
buildingType = BuildingType.Storage;
|
||||
}
|
||||
public void Add(Item item)
|
||||
{
|
||||
if(GetFreeSpace() >= item.count)
|
||||
|
||||
35
Assets/Scripts/ResourceUiTextScript.cs
Normal file
35
Assets/Scripts/ResourceUiTextScript.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class ResourceUiTextScript : MonoBehaviour
|
||||
{
|
||||
private ResourceManager resourceManager;
|
||||
|
||||
|
||||
private string str = "";
|
||||
private TMPro.TextMeshProUGUI textResource;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
resourceManager = GameObject.Find("GameManager").GetComponent<ResourceManager>();
|
||||
textResource = GetComponent<TMPro.TextMeshProUGUI>();
|
||||
}
|
||||
void Update()
|
||||
{
|
||||
List<Item> inventory = new List<Item>();
|
||||
inventory = resourceManager.GetAllResources();
|
||||
str = "";
|
||||
foreach(Item i in inventory)
|
||||
{
|
||||
if(i != null)
|
||||
{
|
||||
str += i.count.ToString() + " " + i.name + "\n";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
textResource.text = str;
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/ResourceUiTextScript.cs.meta
Normal file
11
Assets/Scripts/ResourceUiTextScript.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fcb96c8b7ecf3554ab9aea050b13d5b1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -5,13 +5,13 @@ using UnityEngine;
|
||||
public class ResourceManager: MonoBehaviour
|
||||
{
|
||||
[SerializeField] private GameObject[] storageBuildings;
|
||||
|
||||
|
||||
private void Start()
|
||||
{
|
||||
storageBuildings = GameObject.FindGameObjectsWithTag("StorageBuilding");
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (Input.GetKeyDown(KeyCode.K))
|
||||
@@ -30,7 +30,7 @@ public class ResourceManager: MonoBehaviour
|
||||
{
|
||||
GetAllResources();
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
|
||||
public List<Item> GetAllResources()
|
||||
|
||||
@@ -5,18 +5,19 @@ using UnityEngine.UI;
|
||||
|
||||
public class TimeTextScript : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private GameObject GamerManager;
|
||||
private GameObject GameManager;
|
||||
|
||||
private string timeStr = "";
|
||||
private Text timeText;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
GameManager = GameObject.Find("GameManager");
|
||||
timeText = GetComponent<Text>();
|
||||
}
|
||||
void Update()
|
||||
{
|
||||
timeStr = GamerManager.GetComponent<TimeManager>().GetTimeString();
|
||||
timeStr = GameManager.GetComponent<TimeManager>().GetTimeString();
|
||||
timeText.text = timeStr;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user