mirror of
https://github.com/DerTyp7/fps-citybuild-unity.git
synced 2026-07-31 14:59:02 +02:00
started working on Building rework
This commit is contained in:
18
Assets/Buildings/Scripts/Building.cs
Normal file
18
Assets/Buildings/Scripts/Building.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
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;
|
||||
}
|
||||
11
Assets/Buildings/Scripts/Building.cs.meta
Normal file
11
Assets/Buildings/Scripts/Building.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5c2ebc4f7d4eb064b814863e80d9bab0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
135
Assets/Buildings/Scripts/BuildingBlueprint.cs
Normal file
135
Assets/Buildings/Scripts/BuildingBlueprint.cs
Normal file
@@ -0,0 +1,135 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public abstract class BuildingBlueprint : MonoBehaviour
|
||||
{
|
||||
public bool isColliding;
|
||||
public GameObject constructionPrefab;
|
||||
|
||||
public Material collisionMat;
|
||||
public Material blueprintMat;
|
||||
|
||||
private GameObject terrain;
|
||||
private Canvas hud;
|
||||
|
||||
Ray ray;
|
||||
|
||||
public abstract void Init();
|
||||
|
||||
public abstract void WhileColliding();
|
||||
public abstract void WhileNotColliding();
|
||||
|
||||
private void Start()
|
||||
{
|
||||
hud = GameObject.Find("HUD").GetComponent<Canvas>(); //Get HUD Canvas
|
||||
terrain = GameObject.FindGameObjectWithTag("Terrain"); //Get Terrain
|
||||
|
||||
//Bug Fix Blueprints already existing
|
||||
//Delete/CleanUp all objs with tag "Blueprint"
|
||||
GameObject[] blueprints = GameObject.FindGameObjectsWithTag("Blueprint");
|
||||
foreach (GameObject blueprint in blueprints)
|
||||
Destroy(blueprint);
|
||||
|
||||
|
||||
gameObject.tag = "Blueprint"; //Give Gameobject the tag "Blueprint" (after deleting all objs with this tag)
|
||||
|
||||
|
||||
|
||||
Init(); //Call init callback function for children
|
||||
}
|
||||
|
||||
public void Update()
|
||||
{
|
||||
FollowMouse();
|
||||
Rotate();
|
||||
|
||||
//Collinding Callbacks
|
||||
if (isColliding)
|
||||
{
|
||||
WhileColliding();
|
||||
}
|
||||
else
|
||||
{
|
||||
WhileNotColliding();
|
||||
}
|
||||
|
||||
//PLACE
|
||||
if (Input.GetMouseButtonDown(0) && !isColliding)
|
||||
{
|
||||
Place();
|
||||
}
|
||||
}
|
||||
|
||||
void FollowMouse()
|
||||
{
|
||||
ray = Camera.main.ScreenPointToRay(Input.mousePosition);
|
||||
RaycastHit hitData;
|
||||
if (terrain.GetComponent<Collider>().Raycast(ray, out hitData, Mathf.Infinity))
|
||||
{
|
||||
transform.position = hitData.point;
|
||||
}
|
||||
}
|
||||
void Rotate()
|
||||
{
|
||||
if (Input.GetButtonDown("Rotate"))
|
||||
{
|
||||
Debug.Log("Rotate+");
|
||||
if (Input.GetKey(KeyCode.LeftShift))
|
||||
{
|
||||
transform.Rotate(0, 5, 0);
|
||||
}
|
||||
else if (Input.GetKey(KeyCode.LeftControl))
|
||||
{
|
||||
transform.Rotate(0, 45, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
transform.Rotate(0, 22.5f, 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (Input.GetButtonDown("CounterRotate"))
|
||||
{
|
||||
Debug.Log("Rotate-");
|
||||
if (Input.GetKey(KeyCode.LeftShift))
|
||||
{
|
||||
transform.Rotate(0, -5, 0);
|
||||
}
|
||||
else if (Input.GetKey(KeyCode.LeftControl))
|
||||
{
|
||||
transform.Rotate(0, -45, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
transform.Rotate(0, -22.5f, 0);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
void Place()
|
||||
{
|
||||
Instantiate(constructionPrefab, transform.position, transform.rotation);
|
||||
Destroy(this.gameObject);
|
||||
hud.enabled = true;
|
||||
}
|
||||
|
||||
|
||||
//Collision
|
||||
public void OnCollisionEnter(Collision c)
|
||||
{
|
||||
isColliding = true;
|
||||
Debug.Log("Colliding True");
|
||||
}
|
||||
public void OnCollisionStay(Collision c)
|
||||
{
|
||||
isColliding = true;
|
||||
Debug.Log("Colliding True");
|
||||
}
|
||||
public void OnCollisionExit(Collision c)
|
||||
{
|
||||
isColliding = false;
|
||||
Debug.Log("Colliding False");
|
||||
}
|
||||
}
|
||||
14
Assets/Buildings/Scripts/BuildingBlueprint.cs.meta
Normal file
14
Assets/Buildings/Scripts/BuildingBlueprint.cs.meta
Normal file
@@ -0,0 +1,14 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 76f9b3b57e22ab047b8f95bcb552289a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences:
|
||||
- constructionPrefab: {instanceID: 0}
|
||||
- collisionMat: {fileID: 2100000, guid: a1e8fb1ea637c0e45bed70dd7d1feaab, type: 2}
|
||||
- blueprintMat: {fileID: 2100000, guid: 78d3985cb7b88204b930cd05567c0c61, type: 2}
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
26
Assets/Buildings/Scripts/BuildingConstruction.cs
Normal file
26
Assets/Buildings/Scripts/BuildingConstruction.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public abstract class BuildingConstruction : MonoBehaviour
|
||||
{
|
||||
|
||||
public GameObject building;
|
||||
|
||||
public abstract bool CheckForResources();
|
||||
public abstract void Init();
|
||||
|
||||
private void Start()
|
||||
{
|
||||
Init();
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (CheckForResources())
|
||||
{
|
||||
Instantiate(building, gameObject.transform.position, Quaternion.identity);
|
||||
Destroy(this.gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Buildings/Scripts/BuildingConstruction.cs.meta
Normal file
11
Assets/Buildings/Scripts/BuildingConstruction.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 891ae650cdb2a6a438a2fd1bbb520db2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
35
Assets/Buildings/Scripts/BuildingPlacement.cs
Normal file
35
Assets/Buildings/Scripts/BuildingPlacement.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class BuildingPlacement : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private GameObject terrain;
|
||||
[SerializeField] private GameObject prefab;
|
||||
|
||||
Ray ray;
|
||||
private Canvas hud;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
hud = GameObject.Find("HUD").GetComponent<Canvas>();
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
// Build Button Handler
|
||||
if (Input.GetButtonDown("Build"))
|
||||
{ // Wenn man den Button 'B'
|
||||
//Get HUD Canvas
|
||||
hud.enabled = false; //Hide HUD
|
||||
|
||||
ray = Camera.main.ScreenPointToRay(Input.mousePosition);
|
||||
RaycastHit hitData;
|
||||
if (terrain.GetComponent<Collider>().Raycast(ray, out hitData, Mathf.Infinity))
|
||||
{
|
||||
Instantiate(prefab, hitData.point, Quaternion.identity);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Buildings/Scripts/BuildingPlacement.cs.meta
Normal file
11
Assets/Buildings/Scripts/BuildingPlacement.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2fe01a752f991734aa307cc7b7665015
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Buildings/Scripts/Buildings.meta
Normal file
8
Assets/Buildings/Scripts/Buildings.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 67b1c241d94696c409ad579573961232
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Buildings/Scripts/Buildings/House.meta
Normal file
8
Assets/Buildings/Scripts/Buildings/House.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e0c8f7012e4cce54bb00c3edeac83c65
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
31
Assets/Buildings/Scripts/Buildings/House/HouseBlueprint.cs
Normal file
31
Assets/Buildings/Scripts/Buildings/House/HouseBlueprint.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class HouseBlueprint : BuildingBlueprint
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
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,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6d49e2868fa536c4fac8ec278501f38b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 255558bfba6648641822c24b4555e7db
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,26 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class HouseConstruction : BuildingConstruction
|
||||
{
|
||||
[Header("Needed Resources")]
|
||||
[SerializeField] private int neededWood = 10;
|
||||
|
||||
[Header("Having Resources")]
|
||||
[SerializeField] private int havingWood = 0;
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
}
|
||||
|
||||
public override bool CheckForResources()
|
||||
{
|
||||
if (havingWood == neededWood)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b49d2e0b5f1b960469b9dc34355fcc5f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Buildings/Scripts/Buildings/Warehouse.meta
Normal file
8
Assets/Buildings/Scripts/Buildings/Warehouse.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 03d0b1e434e28de4f9f37f90abf6d095
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,34 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class WarehouseBlueprint : BuildingBlueprint
|
||||
{
|
||||
private MeshRenderer[] childrenMeshRenderer;
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
//Haus cube ím Obj -> hier wird es benutzt zum material ändern
|
||||
childrenMeshRenderer = gameObject.GetComponentsInChildren<MeshRenderer>();
|
||||
}
|
||||
|
||||
public override void WhileColliding()
|
||||
{
|
||||
//Wenn es collidet soll der HouseCube IM Object verändert werden!
|
||||
//Das ist bei jedem Building anders
|
||||
foreach(MeshRenderer r in childrenMeshRenderer)
|
||||
{
|
||||
r.material = collisionMat;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public override void WhileNotColliding()
|
||||
{
|
||||
//Das selbe wie bei "WhileColliding"
|
||||
foreach (MeshRenderer r in childrenMeshRenderer)
|
||||
{
|
||||
r.material = blueprintMat;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c08df78a8e2e51d4c80019a27fc2cc5c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,15 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class WarehouseBuilding : StorageBuilding
|
||||
{
|
||||
|
||||
private void Start()
|
||||
{
|
||||
title = "Warehouse";
|
||||
description = "A place to store your resources";
|
||||
inventorySpace = 500;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8a48bc1459390b4459fbf54ad16b50f9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,25 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class WarehouseConstruction : BuildingConstruction
|
||||
{
|
||||
[Header("Needed Resources")]
|
||||
[SerializeField] private int neededWood = 10;
|
||||
|
||||
[Header("Having Resources")]
|
||||
[SerializeField] private int havingWood = 0;
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
}
|
||||
|
||||
public override bool CheckForResources()
|
||||
{
|
||||
if (havingWood == neededWood)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c290e17b16e818841aabd5083a3475db
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
25
Assets/Buildings/Scripts/InfoSign.cs
Normal file
25
Assets/Buildings/Scripts/InfoSign.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class InfoSign : Interactable
|
||||
{
|
||||
private Building parentBuilding;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
parentBuilding = this.transform.parent.gameObject.GetComponent<Building>();
|
||||
}
|
||||
|
||||
|
||||
public override string GetDescription()
|
||||
{
|
||||
return "Press [E] to get <color=blue>info</color>.";
|
||||
}
|
||||
|
||||
public override void Interact()
|
||||
{
|
||||
Debug.Log("interact");
|
||||
}
|
||||
}
|
||||
|
||||
11
Assets/Buildings/Scripts/InfoSign.cs.meta
Normal file
11
Assets/Buildings/Scripts/InfoSign.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0b83755523bca294c8ebaacb9bfd6f02
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Buildings/Scripts/Types.meta
Normal file
8
Assets/Buildings/Scripts/Types.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: efcc2aca90f2a2b4eb81b54c475f3df4
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
105
Assets/Buildings/Scripts/Types/StorageBuilding.cs
Normal file
105
Assets/Buildings/Scripts/Types/StorageBuilding.cs
Normal file
@@ -0,0 +1,105 @@
|
||||
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 Awake()
|
||||
{
|
||||
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ä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/Buildings/Scripts/Types/StorageBuilding.cs.meta
Normal file
11
Assets/Buildings/Scripts/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:
|
||||
Reference in New Issue
Block a user