mirror of
https://github.com/DerTyp7/fps-citybuild-unity.git
synced 2025-10-29 20:22:08 +01:00
added minimap
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 41974f676d374a946813f4863f75f978
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9be9743e89535f6429f5773fd772d746
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -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();
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user