Merge branch 'main' into Buildings

This commit is contained in:
DerTyp187
2021-10-02 14:54:22 +02:00
20 changed files with 871 additions and 281 deletions

View File

@@ -14,15 +14,12 @@ public class HouseConstruction : BuildingConstruction
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

@@ -1,78 +0,0 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class EventLog : MonoBehaviour
{
[Header("Event Log")]
[SerializeField] private GameObject eventObject;
[SerializeField] private Transform parentEventObject;
Vector3 position = new Vector3 (Screen.width-200, 134f, 0f);
[SerializeField] GameObject[] events;
void Start()
{
}
// Update is called once per frame
void Update()
{
events = GameObject.FindGameObjectsWithTag("Event");
if(events.Length <= 4)
{
switch (events.Length)
{
case 0:
position.y = 134f;
break;
case 1:
position.y = 174f;
break;
case 2:
position.y = 214f;
break;
case 3:
position.y = 254f;
break;
}
//Relocate
for (int i = 0; i < events.Length; i++)
{
switch (events.Length)
{
case 1:
events[0].transform.position = new Vector3(Screen.width - 200, 134f, 0f);
break;
case 2:
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 - 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 - 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;
}
}
}
}
public void CreateEvent(string msg)
{
Instantiate(eventObject, position, Quaternion.identity, parentEventObject);
eventObject.GetComponent<EventScript>().ChangeText(msg);
}
}

View File

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

View File

@@ -1,31 +0,0 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class EventScript : MonoBehaviour
{
//[SerializeField] private Text text;
void Start()
{
Invoke("Delete", 5f);
}
// Update is called once per frame
void Update()
{
}
public void ChangeText(string msg)
{
Text t = GetComponentInChildren<Text>();
t.text = msg;
}
void Delete()
{
Destroy(this.gameObject);
}
}

View File

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

View File

@@ -4,7 +4,6 @@ using UnityEngine;
public class LightSwitch : Interactable
{
public GameObject GameManager;
public Light m_Light;
public bool isOn;
@@ -30,14 +29,6 @@ public class LightSwitch : Interactable
public override void Interact()
{
isOn = !isOn;
if (isOn) {
GameManager.GetComponent<EventLog>().CreateEvent("Licht2");
}
else
{
GameManager.GetComponent<EventLog>().CreateEvent("Licht1");
}
//Debug.Log("Click Light");
UpdateLight();

View File

@@ -4,9 +4,8 @@ using UnityEngine;
public class TimeSwitchBtn: Interactable
{
public GameObject GameManager;
public bool dark;
public GameObject GameManager;
public override string GetDescription()
{
@@ -30,12 +29,10 @@ public class TimeSwitchBtn: Interactable
if (dark)
{
GameManager.GetComponent<EventLog>().CreateEvent("Tag!");
GameManager.GetComponent<TimeManager>().secondsOfDay = 0;
}
else
{
GameManager.GetComponent<EventLog>().CreateEvent("Nacht!");
GameManager.GetComponent<TimeManager>().secondsOfDay = 30000;
}
}