feature: Added menu functionality

This commit is contained in:
Gerard Gascón 2024-01-28 12:36:32 +01:00
parent 3b730311fc
commit 38c0bcaef4
9 changed files with 134 additions and 247 deletions

View file

@ -0,0 +1,10 @@
using UnityEngine;
using UnityEngine.SceneManagement;
namespace Flow {
public class MainMenu : MonoBehaviour {
public void LoadGame() {
SceneManager.LoadScene(sceneBuildIndex: 1);
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 7398bc374b9e57e4fb95861c2fb07f2b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -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() {

View 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();
}
}
}
}

View file

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 3ab69031478b416bb744d340062beae1
timeCreated: 1706439699

View file

@ -73,12 +73,15 @@ namespace Messaging {
if (message == _currentJoke.AnswerMessage.Key) {
_sendButton.Lock();
bool isCorrect = _currentJokeIndex != 0;
Coroutine routine = StartCoroutine(ShowRealTexts(isCorrect));
StartCoroutine(SendRandomJoke(routine, sendJokeDelay));
if (isCorrect) {
FindObjectOfType<ProgressBar>().AddProgress();
if (FindObjectOfType<ProgressBar>().AddProgress())
return;
}
Coroutine routine = StartCoroutine(ShowRealTexts(isCorrect));
StartCoroutine(SendRandomJoke(routine, sendJokeDelay));
_lives.ResetLives();
} else {
_lives.Wrong();
if (_lives.CurrentLives == 0) {