Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 51 additions & 18 deletions Assets/Scripts/RedRunner/UI/UIScreen/UIScreen.cs
Original file line number Diff line number Diff line change
@@ -1,30 +1,63 @@
using System.Collections;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;
using UnityEngine.EventSystems;

namespace RedRunner.UI
{
public class UIScreen : MonoBehaviour
{
public class EndScreen : UIScreen
{
[SerializeField]
internal UIScreenInfo ScreenInfo;
[SerializeField]
protected Animator m_Animator;
[SerializeField]
protected CanvasGroup m_CanvasGroup;
protected Button ResetButton = null;
[SerializeField]
protected Button HomeButton = null;
[SerializeField]
protected Button ExitButton = null;

// The Continue button
[SerializeField]
Button ContinueButton = null;

private void Start()
{
ResetButton.SetButtonAction(() =>
{
GameManager.Singleton.Reset();
var ingameScreen = UIManager.Singleton.GetUIScreen(UIScreenInfo.IN_GAME_SCREEN);
UIManager.Singleton.OpenScreen(ingameScreen);
GameManager.Singleton.StartGame();
});

// Add a function to the continue button
ContinueButton.SetButtonAction(() =>
{
// Remove 50 gold when the player clicks the button
GameManager.Singleton.m_Coin.Value -= 50;
GameManager.Singleton.RespawnMainCharacter();
var ingameScreen = UIManager.Singleton.GetUIScreen(UIScreenInfo.IN_GAME_SCREEN);
UIManager.Singleton.OpenScreen(ingameScreen);
GameManager.Singleton.StartGame();
}
);
}

public bool IsOpen { get; set; }
// Check for if the player has enough coins. If so, enable the button. Otherwise, disable it
private void Update()
{
if (GameManager.Singleton.m_Coin.Value >= 50)
{
ContinueButton.gameObject.SetActive(true);
}
else
{
ContinueButton.gameObject.SetActive(false);
}
}

public virtual void UpdateScreenStatus(bool open)
public override void UpdateScreenStatus(bool open)
{
m_Animator.SetBool("Open", open);
m_CanvasGroup.interactable = open;
m_CanvasGroup.blocksRaycasts = open;
IsOpen = open;
base.UpdateScreenStatus(open);
}
}
}

}
}