mirror of
https://github.com/DerTyp7/fps-citybuild-unity.git
synced 2025-11-01 13:42:29 +01:00
Building Rework
This commit is contained in:
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 798eecf368f882c46a67ab4e6354bc7e
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,62 +0,0 @@
|
||||
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 Material blueprintMat;
|
||||
public Material collisionMat;
|
||||
|
||||
|
||||
public abstract void OnStartUp();
|
||||
public enum BuildingType
|
||||
{
|
||||
Housing,
|
||||
Storage,
|
||||
Decoration
|
||||
}
|
||||
|
||||
public BuildingType buildingType;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
gameObject.AddComponent<BuildingBlueprint>();
|
||||
|
||||
gameObject.GetComponent<BuildingBlueprint>().blueprintMat = blueprintMat;
|
||||
gameObject.GetComponent<BuildingBlueprint>().collisionMat = collisionMat;
|
||||
|
||||
FindChildByTag("Building").SetActive(false);
|
||||
FindChildByTag("Blueprint").SetActive(true);
|
||||
|
||||
OnStartUp();
|
||||
}
|
||||
|
||||
public void EndBlueprint(bool place = false)
|
||||
{
|
||||
if (place)
|
||||
{
|
||||
FindChildByTag("Blueprint").SetActive(false);
|
||||
FindChildByTag("Building").SetActive(true);
|
||||
Destroy(gameObject.GetComponent<BuildingBlueprint>());
|
||||
}
|
||||
else
|
||||
{
|
||||
Destroy(gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
public GameObject FindChildByTag(string tag)
|
||||
{
|
||||
foreach(Transform child in gameObject.transform)
|
||||
{
|
||||
if(child.tag == tag)
|
||||
{
|
||||
return child.gameObject;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5c2ebc4f7d4eb064b814863e80d9bab0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,130 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class BuildingBlueprint : MonoBehaviour
|
||||
{
|
||||
|
||||
public Material collisionMat;
|
||||
public Material blueprintMat;
|
||||
|
||||
|
||||
private GameObject terrain;
|
||||
private Canvas hud;
|
||||
private bool isColliding;
|
||||
|
||||
Ray ray;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
hud = GameObject.Find("HUD").GetComponent<Canvas>(); //Get HUD Canvas
|
||||
terrain = GameObject.FindGameObjectWithTag("Terrain"); //Get Terrain
|
||||
|
||||
hud.enabled = false; //Hide HUD
|
||||
}
|
||||
|
||||
public void Update()
|
||||
{
|
||||
FollowMouse();
|
||||
Rotate();
|
||||
|
||||
//COLLISION
|
||||
if (isColliding)
|
||||
{
|
||||
Debug.Log("Collision");
|
||||
MeshRenderer[] mr = gameObject.GetComponent<Building>().FindChildByTag("Blueprint").GetComponentsInChildren<MeshRenderer>();
|
||||
foreach (MeshRenderer r in mr)
|
||||
{
|
||||
r.material = collisionMat;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
MeshRenderer[] mr = gameObject.GetComponent<Building>().FindChildByTag("Blueprint").GetComponentsInChildren<MeshRenderer>();
|
||||
foreach (MeshRenderer r in mr)
|
||||
{
|
||||
r.material = blueprintMat;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//PLACE
|
||||
if (Input.GetMouseButtonDown(0) && !isColliding)
|
||||
{
|
||||
gameObject.GetComponent<Building>().EndBlueprint(true);
|
||||
hud.enabled = true;
|
||||
}
|
||||
|
||||
if (Input.GetButtonDown("Build"))
|
||||
{
|
||||
gameObject.GetComponent<Building>().EndBlueprint(false);
|
||||
hud.enabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//Collision
|
||||
public void OnTriggerEnter(Collider other)
|
||||
{
|
||||
isColliding = true;
|
||||
Debug.Log("Colliding True");
|
||||
}
|
||||
public void OnTriggerStay(Collider other)
|
||||
{
|
||||
isColliding = true;
|
||||
Debug.Log("Colliding True");
|
||||
}
|
||||
public void OnTriggerExit(Collider other)
|
||||
{
|
||||
isColliding = false;
|
||||
Debug.Log("Colliding False");
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
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:
|
||||
@@ -1,26 +0,0 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 891ae650cdb2a6a438a2fd1bbb520db2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,26 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class BuildingPlacement : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private GameObject terrain;
|
||||
[SerializeField] private GameObject prefab;
|
||||
|
||||
Ray ray;
|
||||
|
||||
void Update()
|
||||
{
|
||||
// Build Button Handler
|
||||
if (Input.GetButtonDown("Build"))
|
||||
{ // Wenn man den Button 'B'
|
||||
ray = Camera.main.ScreenPointToRay(Input.mousePosition);
|
||||
RaycastHit hitData;
|
||||
if (terrain.GetComponent<Collider>().Raycast(ray, out hitData, Mathf.Infinity))
|
||||
{
|
||||
Instantiate(prefab, hitData.point, Quaternion.identity);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2fe01a752f991734aa307cc7b7665015
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 67b1c241d94696c409ad579573961232
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e0c8f7012e4cce54bb00c3edeac83c65
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,14 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class HouseBuildingScript : Building
|
||||
{
|
||||
public override void OnStartUp()
|
||||
{
|
||||
title = "House";
|
||||
description = "A place to live in";
|
||||
buildingType = BuildingType.Housing;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 255558bfba6648641822c24b4555e7db
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,26 +0,0 @@
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b49d2e0b5f1b960469b9dc34355fcc5f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 03d0b1e434e28de4f9f37f90abf6d095
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,15 +0,0 @@
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8a48bc1459390b4459fbf54ad16b50f9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,25 +0,0 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c290e17b16e818841aabd5083a3475db
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,25 +0,0 @@
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0b83755523bca294c8ebaacb9bfd6f02
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,517 +0,0 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!1 &5360703792772738077
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 5360703792772738076}
|
||||
- component: {fileID: 5360703792772738078}
|
||||
- component: {fileID: 5360703792772738079}
|
||||
m_Layer: 9
|
||||
m_Name: HouseCube
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &5360703792772738076
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 5360703792772738077}
|
||||
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 64.59468, y: 44, z: 20.101233}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 5360703793539700796}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!33 &5360703792772738078
|
||||
MeshFilter:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 5360703792772738077}
|
||||
m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
|
||||
--- !u!23 &5360703792772738079
|
||||
MeshRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 5360703792772738077}
|
||||
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: 2100000, guid: 78d3985cb7b88204b930cd05567c0c61, 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!1 &5360703793236804447
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 5360703793236804446}
|
||||
- component: {fileID: 5360703793236804450}
|
||||
- component: {fileID: 5360703793236804451}
|
||||
m_Layer: 7
|
||||
m_Name: HouseCube
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &5360703793236804446
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 5360703793236804447}
|
||||
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 64.59468, y: 44, z: 20.101233}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 5360703794001325739}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!33 &5360703793236804450
|
||||
MeshFilter:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 5360703793236804447}
|
||||
m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
|
||||
--- !u!23 &5360703793236804451
|
||||
MeshRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 5360703793236804447}
|
||||
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!1 &5360703793423176871
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 5360703793423176870}
|
||||
- component: {fileID: 5360703793423176874}
|
||||
- component: {fileID: 5360703793423176875}
|
||||
- component: {fileID: 5360703793423176872}
|
||||
- component: {fileID: 5360703793423176873}
|
||||
m_Layer: 0
|
||||
m_Name: Sign
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &5360703793423176870
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 5360703793423176871}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 32.34, y: 10, z: 6.38}
|
||||
m_LocalScale: {x: 0.61721, y: 1.3248, z: 2.108}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 5360703794001325739}
|
||||
m_RootOrder: 1
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!33 &5360703793423176874
|
||||
MeshFilter:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 5360703793423176871}
|
||||
m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
|
||||
--- !u!23 &5360703793423176875
|
||||
MeshRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 5360703793423176871}
|
||||
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: 2100000, guid: 1fae3d354d8f44b438d51fbc992ccae4, 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!65 &5360703793423176872
|
||||
BoxCollider:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 5360703793423176871}
|
||||
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!114 &5360703793423176873
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 5360703793423176871}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 0b83755523bca294c8ebaacb9bfd6f02, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
interactionType: 0
|
||||
--- !u!1 &5360703793539700797
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 5360703793539700796}
|
||||
- component: {fileID: 1517405387498435762}
|
||||
m_Layer: 9
|
||||
m_Name: HouseBlueprint
|
||||
m_TagString: Blueprint
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &5360703793539700796
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 5360703793539700797}
|
||||
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 0.5113401, y: 0.64607, z: 0.70913}
|
||||
m_Children:
|
||||
- {fileID: 5360703792772738076}
|
||||
- {fileID: 5360703794877200717}
|
||||
m_Father: {fileID: 5360703794841841444}
|
||||
m_RootOrder: 1
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!65 &1517405387498435762
|
||||
BoxCollider:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 5360703793539700797}
|
||||
m_Material: {fileID: 0}
|
||||
m_IsTrigger: 1
|
||||
m_Enabled: 1
|
||||
serializedVersion: 2
|
||||
m_Size: {x: 92.57468, y: 48.040638, z: 29.317003}
|
||||
m_Center: {x: -4.6876817, y: 0.38128814, z: -0.8356206}
|
||||
--- !u!1 &5360703794001325736
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 5360703794001325739}
|
||||
- component: {fileID: 5360703794001325738}
|
||||
- component: {fileID: 3042064361800759033}
|
||||
m_Layer: 0
|
||||
m_Name: House
|
||||
m_TagString: Building
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &5360703794001325739
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 5360703794001325736}
|
||||
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 0.5113401, y: 0.64607, z: 0.70913}
|
||||
m_Children:
|
||||
- {fileID: 5360703793236804446}
|
||||
- {fileID: 5360703793423176870}
|
||||
m_Father: {fileID: 5360703794841841444}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!54 &5360703794001325738
|
||||
Rigidbody:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 5360703794001325736}
|
||||
serializedVersion: 2
|
||||
m_Mass: 1
|
||||
m_Drag: 0
|
||||
m_AngularDrag: 0.05
|
||||
m_UseGravity: 1
|
||||
m_IsKinematic: 0
|
||||
m_Interpolate: 0
|
||||
m_Constraints: 126
|
||||
m_CollisionDetection: 0
|
||||
--- !u!65 &3042064361800759033
|
||||
BoxCollider:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 5360703794001325736}
|
||||
m_Material: {fileID: 0}
|
||||
m_IsTrigger: 0
|
||||
m_Enabled: 1
|
||||
serializedVersion: 2
|
||||
m_Size: {x: 80, y: 40, z: 30}
|
||||
m_Center: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &5360703794841841442
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 5360703794841841444}
|
||||
- component: {fileID: 5360703794841841445}
|
||||
m_Layer: 0
|
||||
m_Name: TestHouse
|
||||
m_TagString: Building
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &5360703794841841444
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 5360703794841841442}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 4.299156, y: 27.5, z: 53.029934}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children:
|
||||
- {fileID: 5360703794001325739}
|
||||
- {fileID: 5360703793539700796}
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!114 &5360703794841841445
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 5360703794841841442}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 255558bfba6648641822c24b4555e7db, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
title: New Building
|
||||
description: A cool new building
|
||||
blueprintMat: {fileID: 2100000, guid: 78d3985cb7b88204b930cd05567c0c61, type: 2}
|
||||
collisionMat: {fileID: 2100000, guid: a1e8fb1ea637c0e45bed70dd7d1feaab, type: 2}
|
||||
buildingType: 0
|
||||
--- !u!1 &5360703794877200714
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 5360703794877200717}
|
||||
- component: {fileID: 5360703794877200719}
|
||||
- component: {fileID: 5360703794877200716}
|
||||
m_Layer: 9
|
||||
m_Name: Sign
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &5360703794877200717
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 5360703794877200714}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 32.34, y: 10, z: 6.38}
|
||||
m_LocalScale: {x: 0.61721, y: 1.3248, z: 2.108}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 5360703793539700796}
|
||||
m_RootOrder: 1
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!33 &5360703794877200719
|
||||
MeshFilter:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 5360703794877200714}
|
||||
m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
|
||||
--- !u!23 &5360703794877200716
|
||||
MeshRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 5360703794877200714}
|
||||
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: 2100000, guid: 78d3985cb7b88204b930cd05567c0c61, 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}
|
||||
@@ -1,7 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bfe47c8c98918254086591539306d4fa
|
||||
PrefabImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: efcc2aca90f2a2b4eb81b54c475f3df4
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,108 +0,0 @@
|
||||
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 override void OnStartUp()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
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<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;
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9cd3101a861849b4f97e2f4f499d7d46
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user