feature: Added menu functionality
This commit is contained in:
parent
3b730311fc
commit
38c0bcaef4
9 changed files with 134 additions and 247 deletions
10
Assets/Scripts/Flow/MainMenu.cs
Normal file
10
Assets/Scripts/Flow/MainMenu.cs
Normal file
|
@ -0,0 +1,10 @@
|
|||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
namespace Flow {
|
||||
public class MainMenu : MonoBehaviour {
|
||||
public void LoadGame() {
|
||||
SceneManager.LoadScene(sceneBuildIndex: 1);
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/Flow/MainMenu.cs.meta
Normal file
11
Assets/Scripts/Flow/MainMenu.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 7398bc374b9e57e4fb95861c2fb07f2b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -14,12 +14,19 @@ namespace Flow {
|
|||
UpdateFill();
|
||||
}
|
||||
|
||||
public void AddProgress() {
|
||||
public bool AddProgress() {
|
||||
_progressDone++;
|
||||
|
||||
if (_progressDone <= numberToWin) {
|
||||
UpdateFill();
|
||||
}
|
||||
|
||||
if (_progressDone >= numberToWin) {
|
||||
FindObjectOfType<WinScreen>().Win();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private void UpdateFill() {
|
||||
|
|
33
Assets/Scripts/Flow/WinScreen.cs
Normal file
33
Assets/Scripts/Flow/WinScreen.cs
Normal file
|
@ -0,0 +1,33 @@
|
|||
using System;
|
||||
using DG.Tweening;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Serialization;
|
||||
|
||||
namespace Flow {
|
||||
public class WinScreen : MonoBehaviour {
|
||||
[SerializeField] private CanvasGroup canvasGroup;
|
||||
|
||||
[SerializeField] private RectTransform winBackground;
|
||||
[SerializeField] private RectTransform winText;
|
||||
|
||||
private bool _hasWon;
|
||||
|
||||
public void Win() {
|
||||
_hasWon = true;
|
||||
|
||||
canvasGroup.blocksRaycasts = true;
|
||||
canvasGroup.DOFade(1f, .5f);
|
||||
|
||||
winBackground.localScale = new Vector3(0, 0, 1);
|
||||
winText.localScale = new Vector3(0, 0, 1);
|
||||
winBackground.DOScale(1f, .25f).SetDelay(.5f).SetEase(Ease.OutBack);
|
||||
winText.DOScale(1f, .25f).SetDelay(.55f).SetEase(Ease.OutBack);
|
||||
}
|
||||
|
||||
private void Update() {
|
||||
if (_hasWon && Input.anyKeyDown) {
|
||||
Application.Quit();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
3
Assets/Scripts/Flow/WinScreen.cs.meta
Normal file
3
Assets/Scripts/Flow/WinScreen.cs.meta
Normal file
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 3ab69031478b416bb744d340062beae1
|
||||
timeCreated: 1706439699
|
Loading…
Add table
Add a link
Reference in a new issue