fixes to the notification system
This commit is contained in:
parent
7029f346e3
commit
2b8630b552
2 changed files with 51 additions and 18 deletions
|
@ -32,19 +32,19 @@ public class NotificationManager : MonoBehaviour {
|
||||||
// Use this for initialization
|
// Use this for initialization
|
||||||
void Start() {
|
void Start() {
|
||||||
delay = 0;
|
delay = 0;
|
||||||
showingMessage = false;
|
|
||||||
messages = new List<Notification>();
|
messages = new List<Notification>();
|
||||||
text = GetComponent<Text>();
|
text = GetComponent<Text>();
|
||||||
|
hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Update() {
|
void Update() {
|
||||||
if ( showingMessage ) {
|
if ( showingMessage ) {
|
||||||
if ( Time.time > delay ) {
|
if ( Time.time > delay ) {
|
||||||
if ( messages.Count == 1 ) {
|
if (messages.Count <= 1) {
|
||||||
GetComponentInParent<Image>().enabled = false;
|
messages.Remove(messages[0]);
|
||||||
messages.Remove(messages[0]);
|
hide();
|
||||||
showingMessage = false;
|
|
||||||
} else {
|
} else {
|
||||||
|
messages.Remove(messages[0]);
|
||||||
text.text = messages[0].getText();
|
text.text = messages[0].getText();
|
||||||
delay = Time.time + messages[0].getDuration();
|
delay = Time.time + messages[0].getDuration();
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,19 @@ public class NotificationManager : MonoBehaviour {
|
||||||
|
|
||||||
GetComponent<Text>().text = text;
|
GetComponent<Text>().text = text;
|
||||||
delay = Time.time + duration;
|
delay = Time.time + duration;
|
||||||
GetComponentInParent<Image>().enabled = true;
|
show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void show() {
|
||||||
|
GetComponentInParent<Image>().enabled = true;
|
||||||
|
text.enabled = true;
|
||||||
|
showingMessage = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void hide() {
|
||||||
|
GetComponentInParent<Image>().enabled = false;
|
||||||
|
text.enabled = false;
|
||||||
|
showingMessage = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,53 +2,74 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
public class UIController : MonoBehaviour {
|
public class UIController : MonoBehaviour
|
||||||
|
{
|
||||||
|
|
||||||
GameObject score;
|
GameObject score;
|
||||||
GameObject pauseMenu;
|
GameObject pauseMenu;
|
||||||
|
|
||||||
|
[SerializeField]
|
||||||
|
NotificationManager notifications;
|
||||||
|
|
||||||
[SerializeField]
|
[SerializeField]
|
||||||
GameObject gameOverPanel;
|
GameObject gameOverPanel;
|
||||||
|
|
||||||
[SerializeField]
|
[SerializeField]
|
||||||
private HealthbarController healthcontroller;
|
HealthbarController healthcontroller;
|
||||||
|
|
||||||
public void ShowPauseMenu() {
|
|
||||||
|
public void ShowPauseMenu()
|
||||||
|
{
|
||||||
pauseMenu.SetActive(true);
|
pauseMenu.SetActive(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ClosePauseMenu() {
|
public void ClosePauseMenu()
|
||||||
|
{
|
||||||
pauseMenu.SetActive(false);
|
pauseMenu.SetActive(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void LoadSceneByIndex(int index) {
|
public void LoadSceneByIndex(int index)
|
||||||
|
{
|
||||||
Debug.Log("Loaded scene " + index);
|
Debug.Log("Loaded scene " + index);
|
||||||
UnityEngine.SceneManagement.SceneManager.LoadScene(index);
|
UnityEngine.SceneManagement.SceneManager.LoadScene(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void QuitGame() {
|
public void QuitGame()
|
||||||
|
{
|
||||||
Debug.Log("Quit game");
|
Debug.Log("Quit game");
|
||||||
Application.Quit();
|
Application.Quit();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ShowGameOverUI() {
|
public void ShowGameOverUI()
|
||||||
if ( gameOverPanel != null ) {
|
{
|
||||||
|
if (gameOverPanel != null)
|
||||||
|
{
|
||||||
Canvas gameOverCanvas = gameOverPanel.GetComponent<Canvas>();
|
Canvas gameOverCanvas = gameOverPanel.GetComponent<Canvas>();
|
||||||
Debug.Log("Loading Canvas");
|
Debug.Log("Loading Canvas");
|
||||||
|
|
||||||
if ( gameOverCanvas != null ) {
|
if (gameOverCanvas != null)
|
||||||
|
{
|
||||||
Debug.Log("Loaded Canvas");
|
Debug.Log("Loaded Canvas");
|
||||||
gameOverCanvas.enabled = true;
|
gameOverCanvas.enabled = true;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
Debug.Log("Gameover panel has no Canvas");
|
Debug.Log("Gameover panel has no Canvas");
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
Debug.Log("No game over panel assigned");
|
Debug.Log("No game over panel assigned");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void InitHealthController(Player ply) {
|
public void InitHealthController(Player ply)
|
||||||
|
{
|
||||||
healthcontroller.SetPlayer(ply);
|
healthcontroller.SetPlayer(ply);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public NotificationManager GetNotificationManager() {
|
||||||
|
return notifications;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue