mirror of
https://github.com/DerTyp7/fps-citybuild-unity.git
synced 2025-10-29 12:22:07 +01:00
Merge branch 'Resources' into main
This commit is contained in:
@@ -38,7 +38,7 @@ RenderSettings:
|
||||
m_ReflectionIntensity: 1
|
||||
m_CustomReflection: {fileID: 0}
|
||||
m_Sun: {fileID: 705507994}
|
||||
m_IndirectSpecularColor: {r: 0.2277222, g: 0.2251251, b: 0.2237271, a: 1}
|
||||
m_IndirectSpecularColor: {r: 0.5996083, g: 0.5927744, b: 0.588867, a: 1}
|
||||
m_UseRadianceAmbientProbe: 0
|
||||
--- !u!157 &3
|
||||
LightmapSettings:
|
||||
@@ -382,6 +382,7 @@ Transform:
|
||||
- {fileID: 1667291200}
|
||||
- {fileID: 1238304666}
|
||||
- {fileID: 1300620966}
|
||||
- {fileID: 763358974}
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 6
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
@@ -638,6 +639,119 @@ RectTransform:
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 0, y: 0}
|
||||
m_Pivot: {x: 0, y: 0}
|
||||
--- !u!1 &763358969
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 763358974}
|
||||
- component: {fileID: 763358973}
|
||||
- component: {fileID: 763358972}
|
||||
- component: {fileID: 763358971}
|
||||
- component: {fileID: 763358970}
|
||||
m_Layer: 0
|
||||
m_Name: Warehouse
|
||||
m_TagString: StorageBuilding
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!114 &763358970
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 763358969}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 8a48bc1459390b4459fbf54ad16b50f9, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
title: New Building
|
||||
description: A cool new building
|
||||
inventory: []
|
||||
inventorySpace: 0
|
||||
--- !u!65 &763358971
|
||||
BoxCollider:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 763358969}
|
||||
m_Material: {fileID: 0}
|
||||
m_IsTrigger: 0
|
||||
m_Enabled: 1
|
||||
serializedVersion: 2
|
||||
m_Size: {x: 1, y: 1, z: 1}
|
||||
m_Center: {x: 0, y: 0, z: 0}
|
||||
--- !u!23 &763358972
|
||||
MeshRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 763358969}
|
||||
m_Enabled: 1
|
||||
m_CastShadows: 1
|
||||
m_ReceiveShadows: 1
|
||||
m_DynamicOccludee: 1
|
||||
m_StaticShadowCaster: 0
|
||||
m_MotionVectors: 1
|
||||
m_LightProbeUsage: 1
|
||||
m_ReflectionProbeUsage: 1
|
||||
m_RayTracingMode: 2
|
||||
m_RayTraceProcedural: 0
|
||||
m_RenderingLayerMask: 1
|
||||
m_RendererPriority: 0
|
||||
m_Materials:
|
||||
- {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0}
|
||||
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!33 &763358973
|
||||
MeshFilter:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 763358969}
|
||||
m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
|
||||
--- !u!4 &763358974
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 763358969}
|
||||
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
||||
m_LocalPosition: {x: 84.6, y: 21, z: 29.60771}
|
||||
m_LocalScale: {x: 10, y: 10, z: 10}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 317073667}
|
||||
m_RootOrder: 4
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &1048269303
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -849,6 +963,10 @@ PrefabInstance:
|
||||
propertyPath: m_LocalEulerAnglesHint.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 1118460100164241581, guid: 613866d46c759a848b2a462973745a74, type: 3}
|
||||
propertyPath: m_LocalPosition.x
|
||||
value: 36.7
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 5179206290616997027, guid: 613866d46c759a848b2a462973745a74, type: 3}
|
||||
propertyPath: m_Name
|
||||
value: House
|
||||
@@ -1093,6 +1211,8 @@ GameObject:
|
||||
- component: {fileID: 1861247505}
|
||||
- component: {fileID: 1861247504}
|
||||
- component: {fileID: 1861247506}
|
||||
- component: {fileID: 1861247507}
|
||||
- component: {fileID: 1861247508}
|
||||
m_Layer: 0
|
||||
m_Name: GameManager
|
||||
m_TagString: Untagged
|
||||
@@ -1143,6 +1263,31 @@ MonoBehaviour:
|
||||
eventObject: {fileID: 8681335675325213624, guid: 240f676d062888042ac64a67d71aaa9d, type: 3}
|
||||
parentEventObject: {fileID: 1690461076}
|
||||
events: []
|
||||
--- !u!114 &1861247507
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1861247503}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 241231c1be475704d8a3fded0c1a9d63, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
storageBuildings: []
|
||||
--- !u!114 &1861247508
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1861247503}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 3f1735c997ccb39408dfa8bf3790319f, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
--- !u!1001 &7029954222161724659
|
||||
PrefabInstance:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -1259,5 +1404,9 @@ PrefabInstance:
|
||||
propertyPath: m_LocalEulerAnglesHint.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8390537189371922023, guid: 6a86db7765f277243b912c20f451dc47, type: 3}
|
||||
propertyPath: m_LocalPosition.z
|
||||
value: -18.4
|
||||
objectReference: {fileID: 0}
|
||||
m_RemovedComponents: []
|
||||
m_SourcePrefab: {fileID: 100100000, guid: 6a86db7765f277243b912c20f451dc47, type: 3}
|
||||
|
||||
@@ -4,9 +4,15 @@ using UnityEngine;
|
||||
|
||||
public abstract class Building : MonoBehaviour
|
||||
{
|
||||
public string title = "New Building";
|
||||
public string description = "A cool new building";
|
||||
|
||||
public abstract string GetTitle();
|
||||
public abstract string GetDescription();
|
||||
|
||||
public enum BuildingType
|
||||
{
|
||||
Housing,
|
||||
Storage,
|
||||
Decoration
|
||||
}
|
||||
|
||||
public BuildingType buildingType;
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ public abstract class BuildingBlueprint : MonoBehaviour
|
||||
Ray ray;
|
||||
|
||||
public abstract void Init();
|
||||
|
||||
public abstract void WhileColliding();
|
||||
public abstract void WhileNotColliding();
|
||||
|
||||
|
||||
8
Assets/Scripts/Building/Buildings.meta
Normal file
8
Assets/Scripts/Building/Buildings.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 67b1c241d94696c409ad579573961232
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -4,23 +4,29 @@ using UnityEngine;
|
||||
|
||||
public class HouseBlueprint : BuildingBlueprint
|
||||
{
|
||||
public Material collisionMat;
|
||||
|
||||
public Material collisionMat;
|
||||
public Material blueprintMat;
|
||||
|
||||
|
||||
private Transform houseCube;
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
//Haus cube ím Obj -> hier wird es benutzt zum material ändern
|
||||
houseCube = gameObject.transform.Find("HouseCube");
|
||||
}
|
||||
|
||||
public override void WhileColliding()
|
||||
{
|
||||
//Wenn es collidet soll der HouseCube IM Object verändert werden!
|
||||
//Das ist bei jedem Building anders
|
||||
houseCube.GetComponent<MeshRenderer>().material = collisionMat;
|
||||
}
|
||||
|
||||
public override void WhileNotColliding()
|
||||
{
|
||||
//Das selbe wie bei "WhileColliding"
|
||||
houseCube.GetComponent<MeshRenderer>().material = blueprintMat;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class HouseBuildingScript : Building
|
||||
{
|
||||
private void Start()
|
||||
{
|
||||
title = "House";
|
||||
description = "A place to live in";
|
||||
buildingType = BuildingType.Housing;
|
||||
}
|
||||
|
||||
}
|
||||
8
Assets/Scripts/Building/Buildings/Warehouse.meta
Normal file
8
Assets/Scripts/Building/Buildings/Warehouse.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 03d0b1e434e28de4f9f37f90abf6d095
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,13 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class WarehouseBuilding : StorageBuilding
|
||||
{
|
||||
|
||||
private void Start()
|
||||
{
|
||||
inventorySpace = 500;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8a48bc1459390b4459fbf54ad16b50f9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,18 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class HouseBuildingScript : Building
|
||||
{
|
||||
[SerializeField] private string title = "House";
|
||||
[SerializeField] private string description = "A place for people to live in.";
|
||||
|
||||
public override string GetTitle()
|
||||
{
|
||||
return title;
|
||||
}
|
||||
public override string GetDescription()
|
||||
{
|
||||
return description;
|
||||
}
|
||||
}
|
||||
@@ -19,8 +19,6 @@ public class InfoSign : Interactable
|
||||
|
||||
public override void Interact()
|
||||
{
|
||||
Debug.Log(parentBuilding.GetTitle());
|
||||
|
||||
Debug.Log("interact");
|
||||
}
|
||||
}
|
||||
|
||||
8
Assets/Scripts/Building/Types.meta
Normal file
8
Assets/Scripts/Building/Types.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: efcc2aca90f2a2b4eb81b54c475f3df4
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
102
Assets/Scripts/Building/Types/StorageBuilding.cs
Normal file
102
Assets/Scripts/Building/Types/StorageBuilding.cs
Normal file
@@ -0,0 +1,102 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
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)
|
||||
{
|
||||
bool added = false;
|
||||
//Check if the Item can get stacked
|
||||
foreach (Item i in inventory)
|
||||
{
|
||||
if (i.uuid == item.uuid)
|
||||
{
|
||||
i.count += item.count;
|
||||
added = true;
|
||||
return;
|
||||
}
|
||||
added = false;
|
||||
|
||||
|
||||
}
|
||||
|
||||
//If foreach does not work just ADD (List is empty)
|
||||
if (!added)
|
||||
{
|
||||
inventory.Add(item);
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log("Inventory Full");
|
||||
}
|
||||
|
||||
//TODO mach wenn nicht ganz voll, dass dann so viele items added werden wie platz ist
|
||||
//Sonst wird bei 20 Holz KOMPLETT nein gesagt weil/obowhl 19 Space noch da ist
|
||||
}
|
||||
|
||||
public void Remove(Item item)
|
||||
{
|
||||
//Check if the Item can get stacked
|
||||
foreach (Item i in inventory)
|
||||
{
|
||||
if (i.uuid == item.uuid)
|
||||
{
|
||||
if(i.count > item.count)
|
||||
{
|
||||
i.count -= item.count;
|
||||
}else if(i.count <= item.count)
|
||||
{
|
||||
//!!!Muss eventuell sp<73>ter anders gehandelt werden!!!
|
||||
inventory.Remove(i); //Wenn du mehr entfernst als im Inventar ist, dann wird das Item einfach komplett removed
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int GetCountOfItem(Item item)
|
||||
{
|
||||
int count = 0;
|
||||
foreach(Item i in inventory)
|
||||
{
|
||||
if(i.uuid == item.uuid)
|
||||
{
|
||||
count += i.count;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
|
||||
}
|
||||
|
||||
public int GetUsedSpace()
|
||||
{
|
||||
int usedSpace = 0;
|
||||
|
||||
foreach(Item item in inventory)
|
||||
{
|
||||
usedSpace += item.count;
|
||||
}
|
||||
|
||||
return usedSpace;
|
||||
}
|
||||
|
||||
public int GetFreeSpace()
|
||||
{
|
||||
return inventorySpace - GetUsedSpace();
|
||||
}
|
||||
public List<Item> Getinventory()
|
||||
{
|
||||
return inventory;
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Building/Types/StorageBuilding.cs.meta
Normal file
11
Assets/Scripts/Building/Types/StorageBuilding.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9cd3101a861849b4f97e2f4f499d7d46
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Scripts/NPC.meta
Normal file
8
Assets/Scripts/NPC.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3cbe760ab4339094882e9b35d42a7d39
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
40
Assets/Scripts/NPC/TerrainGenerator.cs
Normal file
40
Assets/Scripts/NPC/TerrainGenerator.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class TerrainGenerator : MonoBehaviour
|
||||
{
|
||||
public (float y, bool isTerrain) GetTerrainHit(float x, float z)
|
||||
{
|
||||
float y = 0;
|
||||
bool isTerrain = false;
|
||||
Vector3 position = new Vector3(x, 50, z);
|
||||
|
||||
|
||||
RaycastHit hit;
|
||||
|
||||
if(Physics.Raycast(position, Vector3.down, out hit, Mathf.Infinity))
|
||||
{
|
||||
if(hit.transform.tag == "Terrain")
|
||||
{
|
||||
Debug.Log("Terrain Hit");
|
||||
y = hit.point.y;
|
||||
Debug.Log(hit.point.y);
|
||||
isTerrain = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
y = hit.point.y;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log("Terrain not Hit");
|
||||
}
|
||||
|
||||
|
||||
|
||||
return (y, isTerrain);
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/NPC/TerrainGenerator.cs.meta
Normal file
11
Assets/Scripts/NPC/TerrainGenerator.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3f1735c997ccb39408dfa8bf3790319f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
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:
|
||||
8
Assets/Scripts/Resources.meta
Normal file
8
Assets/Scripts/Resources.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c318b4d6ca7f8af44b4234e942d6725f
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Scripts/Resources/Items.meta
Normal file
8
Assets/Scripts/Resources/Items.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6dd941a22f986e3439f2aaa7c5219004
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
13
Assets/Scripts/Resources/Items/StoneItem.cs
Normal file
13
Assets/Scripts/Resources/Items/StoneItem.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class StoneItem : Item
|
||||
{
|
||||
public StoneItem(int c = 1)
|
||||
{
|
||||
count = c;
|
||||
name = "Stone";
|
||||
uuid = "item_stone";
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Resources/Items/StoneItem.cs.meta
Normal file
11
Assets/Scripts/Resources/Items/StoneItem.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 437c0f4d48ae7a441beeaf0c3b7376a6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
13
Assets/Scripts/Resources/Items/WoodItem.cs
Normal file
13
Assets/Scripts/Resources/Items/WoodItem.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class WoodItem : Item
|
||||
{
|
||||
public WoodItem(int c = 1)
|
||||
{
|
||||
count = c;
|
||||
name = "Wood";
|
||||
uuid = "item_wood";
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Resources/Items/WoodItem.cs.meta
Normal file
11
Assets/Scripts/Resources/Items/WoodItem.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7e095dfc35783fe418bcfddbdf69924f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Scripts/Resources/Scripts.meta
Normal file
8
Assets/Scripts/Resources/Scripts.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d06f1d835d44a674cbb2ca674e31830d
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
17
Assets/Scripts/Resources/Scripts/Item.cs
Normal file
17
Assets/Scripts/Resources/Scripts/Item.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
[System.Serializable]
|
||||
public class Item
|
||||
{
|
||||
public string name = "New Item";
|
||||
public string uuid = "new_item";
|
||||
public Sprite icon = null;
|
||||
public int count = 1;
|
||||
|
||||
public Item(int c = 1)
|
||||
{
|
||||
count = c;
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Resources/Scripts/Item.cs.meta
Normal file
11
Assets/Scripts/Resources/Scripts/Item.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 232c60ba7df6f074d9c92fa97215e412
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
72
Assets/Scripts/Resources/Scripts/ResourceManager.cs
Normal file
72
Assets/Scripts/Resources/Scripts/ResourceManager.cs
Normal file
@@ -0,0 +1,72 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
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))
|
||||
{
|
||||
Item wood = new WoodItem(10);
|
||||
storageBuildings[0].GetComponent<StorageBuilding>().Add(wood);
|
||||
}
|
||||
|
||||
if (Input.GetKeyDown(KeyCode.I))
|
||||
{
|
||||
Item stone = new StoneItem(12);
|
||||
storageBuildings[0].GetComponent<StorageBuilding>().Add(stone);
|
||||
}
|
||||
|
||||
if (Input.GetKeyDown(KeyCode.L))
|
||||
{
|
||||
GetAllResources();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public List<Item> GetAllResources()
|
||||
{
|
||||
List<Item> inventory = new List<Item>();
|
||||
|
||||
//F<>r jedes StorageBuilding
|
||||
foreach(GameObject b in storageBuildings)
|
||||
{
|
||||
List<Item> buildingInv = b.GetComponent<StorageBuilding>().Getinventory();
|
||||
|
||||
//Add items to already existing item +=
|
||||
foreach (Item item in buildingInv)
|
||||
{
|
||||
foreach(Item i in inventory)
|
||||
{
|
||||
if(i.uuid == item.uuid)
|
||||
{
|
||||
i.count += item.count;
|
||||
buildingInv.Remove(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Add den Rest
|
||||
foreach(Item item in buildingInv)
|
||||
{
|
||||
inventory.Add(item);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Debug.Log(inventory);
|
||||
Debug.Log(inventory[0].count);
|
||||
Debug.Log(inventory[1].count);*/
|
||||
|
||||
return inventory;
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Resources/Scripts/ResourceManager.cs.meta
Normal file
11
Assets/Scripts/Resources/Scripts/ResourceManager.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 241231c1be475704d8a3fded0c1a9d63
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ TagManager:
|
||||
- Building
|
||||
- Terrain
|
||||
- Blueprint
|
||||
- StorageBuilding
|
||||
layers:
|
||||
- Default
|
||||
- TransparentFX
|
||||
|
||||
Reference in New Issue
Block a user