simple UI added
This commit is contained in:
39
Assets/Scripts/UI/DeathScreenController.cs
Normal file
39
Assets/Scripts/UI/DeathScreenController.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
using VContainer;
|
||||
|
||||
public class DeathScreenController
|
||||
{
|
||||
private DeathScreenView _view;
|
||||
|
||||
[Inject] private StartScreenController startScreenController;
|
||||
public DeathScreenController(DeathScreenView view)
|
||||
{
|
||||
_view = view;
|
||||
_view.backButton.onClick.AddListener(OnBackBtnClicked);
|
||||
_view.rePlayButton.onClick.AddListener(OnReplayBtnClicked);
|
||||
}
|
||||
public void HideDeathScreen()
|
||||
{
|
||||
_view.Hide();
|
||||
}
|
||||
|
||||
private void OnReplayBtnClicked()
|
||||
{
|
||||
HideDeathScreen();
|
||||
SceneManager.LoadScene(0);
|
||||
Debug.Log("Game Replayed");
|
||||
}
|
||||
|
||||
private void OnBackBtnClicked()
|
||||
{
|
||||
HideDeathScreen();
|
||||
SceneManager.LoadScene(0);
|
||||
}
|
||||
|
||||
public void ShowDeathScreen(int score, int highscore)
|
||||
{
|
||||
_view.Show(score,highscore);
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/UI/DeathScreenController.cs.meta
Normal file
2
Assets/Scripts/UI/DeathScreenController.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c6c7a99a1277b874084999ad0cdce5aa
|
||||
28
Assets/Scripts/UI/DeathScreenView.cs
Normal file
28
Assets/Scripts/UI/DeathScreenView.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class DeathScreenView : MonoBehaviour
|
||||
{
|
||||
public GameObject deathScreen;
|
||||
public Button rePlayButton;
|
||||
public Button backButton;
|
||||
public TextMeshProUGUI highScoreText;
|
||||
public TextMeshProUGUI currentScoreText;
|
||||
private void Start()
|
||||
{
|
||||
deathScreen.SetActive(false);
|
||||
}
|
||||
|
||||
public void Show(int score, int highscore)
|
||||
{
|
||||
highScoreText.text = highscore.ToString();
|
||||
currentScoreText.text = score.ToString();
|
||||
deathScreen.SetActive(true);
|
||||
|
||||
}
|
||||
public void Hide()
|
||||
{
|
||||
deathScreen.SetActive(false);
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/UI/DeathScreenView.cs.meta
Normal file
2
Assets/Scripts/UI/DeathScreenView.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 89974c575158e4d4fb7be55470dc5150
|
||||
37
Assets/Scripts/UI/StartScreenController.cs
Normal file
37
Assets/Scripts/UI/StartScreenController.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using UnityEngine;
|
||||
using VContainer;
|
||||
|
||||
public class StartScreenController
|
||||
{
|
||||
private StartScreenView _view;
|
||||
public bool hasGameStarted = false;
|
||||
|
||||
public StartScreenController(StartScreenView view)
|
||||
{
|
||||
_view = view;
|
||||
_view.playBtn.onClick.AddListener(OnPlayBtnClicked);
|
||||
Debug.Log("Instance");
|
||||
}
|
||||
|
||||
|
||||
public void OnPlayBtnClicked()
|
||||
{
|
||||
_view.Hide();
|
||||
hasGameStarted = true;
|
||||
}
|
||||
|
||||
public void ShowStartScreen()
|
||||
{
|
||||
|
||||
_view.Show();
|
||||
hasGameStarted = false;
|
||||
|
||||
}
|
||||
|
||||
public void HideStartScreen()
|
||||
{
|
||||
_view.Hide();
|
||||
hasGameStarted = true;
|
||||
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/UI/StartScreenController.cs.meta
Normal file
2
Assets/Scripts/UI/StartScreenController.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e2f5bbd1e47302e45a2c3d3c60fedfcf
|
||||
19
Assets/Scripts/UI/StartScreenView.cs
Normal file
19
Assets/Scripts/UI/StartScreenView.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using VContainer;
|
||||
|
||||
public class StartScreenView : MonoBehaviour
|
||||
{
|
||||
public GameObject startScreen;
|
||||
public Button playBtn;
|
||||
|
||||
public void Hide()
|
||||
{
|
||||
startScreen.SetActive(false);
|
||||
}
|
||||
|
||||
public void Show()
|
||||
{
|
||||
startScreen.SetActive(true);
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/UI/StartScreenView.cs.meta
Normal file
2
Assets/Scripts/UI/StartScreenView.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7614619c0714a4e47804c3234d3398dc
|
||||
Reference in New Issue
Block a user