Merge branch 'janis' into main

This commit is contained in:
DerTyp187
2021-09-26 14:25:56 +02:00
118 changed files with 5309 additions and 5684 deletions

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 798eecf368f882c46a67ab4e6354bc7e
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,12 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public abstract class Building : MonoBehaviour
{
public abstract string GetTitle();
public abstract string GetDescription();
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 663feed4d05ec994fb1deb18b1767962
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,75 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public abstract class BuildingBlueprint : MonoBehaviour
{
public bool isColliding;
public bool followMouse = true;
public GameObject constructionPrefab;
private GameObject terrain;
Ray ray;
public abstract void Init();
public abstract void WhileColliding();
public abstract void WhileNotColliding();
private void Start()
{
terrain = GameObject.FindGameObjectWithTag("Terrain");
Init();
}
//Collision
public void OnCollisionEnter(Collision collision)
{
isColliding = true;
Debug.Log("Colliding True");
}
public void OnCollisionStay(Collision collision)
{
isColliding = true;
Debug.Log("Colliding True");
}
public void OnCollisionExit(Collision collision)
{
isColliding = false;
Debug.Log("Colliding False");
}
//Placing
public void Update()
{
if (followMouse)
{
//Following Mouse
ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hitData;
if (terrain.GetComponent<Collider>().Raycast(ray, out hitData, Mathf.Infinity))
{
transform.position = hitData.point;
}
}
if (Input.GetMouseButtonDown(0) && !isColliding)
{
Instantiate(constructionPrefab, transform.position, transform.rotation);
Destroy(this.gameObject);
}
if (isColliding)
{
WhileColliding();
}
else
{
WhileNotColliding();
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 76f9b3b57e22ab047b8f95bcb552289a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

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

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 891ae650cdb2a6a438a2fd1bbb520db2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,26 @@
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);
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 2fe01a752f991734aa307cc7b7665015
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: e0c8f7012e4cce54bb00c3edeac83c65
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,26 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class HouseBlueprint : BuildingBlueprint
{
public Material collisionMat;
public Material blueprintMat;
private Transform houseCube;
public override void Init()
{
houseCube = gameObject.transform.Find("HouseCube");
}
public override void WhileColliding()
{
houseCube.GetComponent<MeshRenderer>().material = collisionMat;
}
public override void WhileNotColliding()
{
houseCube.GetComponent<MeshRenderer>().material = blueprintMat;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 6d49e2868fa536c4fac8ec278501f38b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,18 @@
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;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 255558bfba6648641822c24b4555e7db
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,31 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class HouseConstruction : BuildingConstruction
{
private GameObject gameManager;
[Header("Needed Resources")]
[SerializeField] private int neededWood = 10;
[Header("Having Resources")]
[SerializeField] private int havingWood = 0;
public override void Init()
{
gameManager = GameObject.Find("GameManager");
gameManager.GetComponent<EventLog>().CreateEvent("Construction: House");
}
public override bool CheckForResources()
{
if (havingWood == neededWood)
{
gameManager.GetComponent<EventLog>().CreateEvent("Construction: House: finished");
return true;
}
return false;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: b49d2e0b5f1b960469b9dc34355fcc5f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,27 @@
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(parentBuilding.GetTitle());
Debug.Log("interact");
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 0b83755523bca294c8ebaacb9bfd6f02
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -7,11 +7,11 @@ public class EventLog : MonoBehaviour
[Header("Event Log")]
[SerializeField] private GameObject eventObject;
[SerializeField] private Transform parentEventObject;
Vector3 position = new Vector3 (Screen.width - 150, 134f, 0f);
Vector3 position = new Vector3 (Screen.width-200, 134f, 0f);
[SerializeField] GameObject[] events;
void Start()
{
events = GameObject.FindGameObjectsWithTag("Event");
}
@@ -19,8 +19,7 @@ public class EventLog : MonoBehaviour
void Update()
{
events = GameObject.FindGameObjectsWithTag("Event");
//Debug.Log(events.Length);
if(events.Length < 4)
if(events.Length <= 4)
{
switch (events.Length)
{
@@ -45,22 +44,22 @@ public class EventLog : MonoBehaviour
switch (events.Length)
{
case 1:
events[0].transform.position = new Vector3(Screen.width - 150, 134f, 0f);
events[0].transform.position = new Vector3(Screen.width - 200, 134f, 0f);
break;
case 2:
events[0].transform.position = new Vector3(Screen.width - 150, 134f, 0f);
events[1].transform.position = new Vector3(Screen.width - 150, 174f, 0f);
events[0].transform.position = new Vector3(Screen.width - 200, 134f, 0f);
events[1].transform.position = new Vector3(Screen.width - 200, 174f, 0f);
break;
case 3:
events[0].transform.position = new Vector3(Screen.width - 150, 134f, 0f);
events[1].transform.position = new Vector3(Screen.width - 150, 174f, 0f);
events[2].transform.position = new Vector3(Screen.width - 150, 214f, 0f);
events[0].transform.position = new Vector3(Screen.width - 200, 134f, 0f);
events[1].transform.position = new Vector3(Screen.width - 200, 174f, 0f);
events[2].transform.position = new Vector3(Screen.width - 200, 214f, 0f);
break;
case 4:
events[0].transform.position = new Vector3(Screen.width - 150, 134f, 0f);
events[1].transform.position = new Vector3(Screen.width - 150, 174f, 0f);
events[2].transform.position = new Vector3(Screen.width - 150, 214f, 0f);
events[3].transform.position = new Vector3(Screen.width - 150, 254f, 0f);
events[0].transform.position = new Vector3(Screen.width - 200, 134f, 0f);
events[1].transform.position = new Vector3(Screen.width - 200, 174f, 0f);
events[2].transform.position = new Vector3(Screen.width - 200, 214f, 0f);
events[3].transform.position = new Vector3(Screen.width - 200, 254f, 0f);
break;
}
}
@@ -72,12 +71,8 @@ public class EventLog : MonoBehaviour
public void CreateEvent(string msg)
{
if(events.Length < 4)
{
Instantiate(eventObject, position, Quaternion.identity, parentEventObject);
eventObject.GetComponent<EventScript>().ChangeText(msg);
}
Instantiate(eventObject, position, Quaternion.identity, parentEventObject);
eventObject.GetComponent<EventScript>().ChangeText(msg);
}
}