1
0
Fork 0

fixes to the notification system

This commit is contained in:
Jan 2018-04-22 20:10:05 +02:00
parent 7029f346e3
commit 2b8630b552
2 changed files with 51 additions and 18 deletions

View file

@ -32,19 +32,19 @@ public class NotificationManager : MonoBehaviour {
// Use this for initialization
void Start() {
delay = 0;
showingMessage = false;
messages = new List<Notification>();
text = GetComponent<Text>();
hide();
}
void Update() {
if ( showingMessage ) {
if ( Time.time > delay ) {
if ( messages.Count == 1 ) {
GetComponentInParent<Image>().enabled = false;
messages.Remove(messages[0]);
showingMessage = false;
if (messages.Count <= 1) {
messages.Remove(messages[0]);
hide();
} else {
messages.Remove(messages[0]);
text.text = messages[0].getText();
delay = Time.time + messages[0].getDuration();
}
@ -60,7 +60,19 @@ public class NotificationManager : MonoBehaviour {
GetComponent<Text>().text = text;
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;
}
}

View file

@ -2,53 +2,74 @@
using System.Collections.Generic;
using UnityEngine;
public class UIController : MonoBehaviour {
public class UIController : MonoBehaviour
{
GameObject score;
GameObject pauseMenu;
[SerializeField]
NotificationManager notifications;
[SerializeField]
GameObject gameOverPanel;
[SerializeField]
private HealthbarController healthcontroller;
HealthbarController healthcontroller;
public void ShowPauseMenu() {
public void ShowPauseMenu()
{
pauseMenu.SetActive(true);
}
public void ClosePauseMenu() {
public void ClosePauseMenu()
{
pauseMenu.SetActive(false);
}
public void LoadSceneByIndex(int index) {
public void LoadSceneByIndex(int index)
{
Debug.Log("Loaded scene " + index);
UnityEngine.SceneManagement.SceneManager.LoadScene(index);
}
public void QuitGame() {
public void QuitGame()
{
Debug.Log("Quit game");
Application.Quit();
}
public void ShowGameOverUI() {
if ( gameOverPanel != null ) {
public void ShowGameOverUI()
{
if (gameOverPanel != null)
{
Canvas gameOverCanvas = gameOverPanel.GetComponent<Canvas>();
Debug.Log("Loading Canvas");
if ( gameOverCanvas != null ) {
if (gameOverCanvas != null)
{
Debug.Log("Loaded Canvas");
gameOverCanvas.enabled = true;
} else {
}
else
{
Debug.Log("Gameover panel has no Canvas");
}
} else {
}
else
{
Debug.Log("No game over panel assigned");
}
}
public void InitHealthController(Player ply) {
public void InitHealthController(Player ply)
{
healthcontroller.SetPlayer(ply);
}
public NotificationManager GetNotificationManager() {
return notifications;
}
}