Merge branch 'sprechtl' into develop
# Conflicts: # Assets/Scenes/MainScene.unity
This commit is contained in:
commit
9fcc02ae3e
2 changed files with 92 additions and 174 deletions
|
|
@ -6,28 +6,45 @@ using UnityEngine;
|
|||
using UnityEngine.Events;
|
||||
|
||||
public class HouseController : MonoBehaviour {
|
||||
private int dayCount = 1;
|
||||
private static UnityEvent newDayEvent;
|
||||
public static UnityEvent NewDayEvent => newDayEvent;
|
||||
private int _dayCount = 1;
|
||||
private static UnityEvent _newDayEvent;
|
||||
public static UnityEvent NewDayEvent => _newDayEvent;
|
||||
|
||||
public Canvas menu;
|
||||
public TextMeshProUGUI dayCountTextMeshProUGUI;
|
||||
public GameObject menuPanel;
|
||||
|
||||
private void OnMouseDown() {
|
||||
toggleMenu();
|
||||
ToggleMenu();
|
||||
}
|
||||
|
||||
void Start() {
|
||||
newDayEvent ??= new UnityEvent();
|
||||
_newDayEvent ??= new UnityEvent();
|
||||
ToggleMenu();
|
||||
}
|
||||
|
||||
public void newDay() {
|
||||
dayCount++;
|
||||
dayCountTextMeshProUGUI.text = dayCount.ToString();
|
||||
newDayEvent?.Invoke();
|
||||
public void NewDay() {
|
||||
_dayCount++;
|
||||
dayCountTextMeshProUGUI.text = _dayCount.ToString();
|
||||
_newDayEvent?.Invoke();
|
||||
}
|
||||
|
||||
public void toggleMenu() {
|
||||
public void ToggleMenu() {
|
||||
menu.gameObject.SetActive(!menu.gameObject.activeSelf);
|
||||
float newPosY;
|
||||
if (Camera.main != null) {
|
||||
|
||||
Vector3 pos = Camera.main.WorldToScreenPoint(transform.position);
|
||||
|
||||
if (pos.y - 50 - ((RectTransform)menuPanel.transform).rect.height >= 0) { //check if bottom of panel is in screen
|
||||
newPosY = pos.y - ((RectTransform)menuPanel.transform).rect.height;
|
||||
} else {
|
||||
newPosY = pos.y + ((RectTransform)menuPanel.transform).rect.height;
|
||||
}
|
||||
|
||||
menuPanel.transform.position = new Vector3(pos.x, newPosY);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue