init
This commit is contained in:
commit
78b901484a
323 changed files with 109774 additions and 0 deletions
78
Assets/Scripts/UI/CanvasManager.cs
Normal file
78
Assets/Scripts/UI/CanvasManager.cs
Normal file
|
@ -0,0 +1,78 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
|
||||
[System.Serializable] public class OnHardMoveIn : UnityEvent { }
|
||||
|
||||
[System.Serializable] public class OnHardMoveOut : UnityEvent { }
|
||||
|
||||
[System.Serializable] public class OnWind : UnityEvent { }
|
||||
public class CanvasManager : MonoBehaviour{
|
||||
|
||||
[HideInInspector] public OnWind onWind;
|
||||
[HideInInspector] public OnHardMoveIn onHardMoveIn;
|
||||
[HideInInspector] public OnHardMoveOut onHardMoveOut;
|
||||
|
||||
[SerializeField] GameObject prefab;
|
||||
|
||||
[SerializeField] int turnsToWind = 5;
|
||||
int currentOne;
|
||||
[HideInInspector] public bool stopped;
|
||||
[HideInInspector] public bool dead;
|
||||
|
||||
[SerializeField] RythmBarController[] initialRythmBars;
|
||||
|
||||
[System.Serializable] public enum CanvasDifficulty {Easy, Hard}
|
||||
public CanvasDifficulty difficulty;
|
||||
|
||||
void Start(){
|
||||
if(SceneLoader.instance.difficultySelected == SceneLoader.DifficultySelected.Easy){
|
||||
difficulty = CanvasDifficulty.Easy;
|
||||
}else{
|
||||
difficulty = CanvasDifficulty.Hard;
|
||||
}
|
||||
FindObjectOfType<PlayerController>().SetDifficulty();
|
||||
foreach(RythmBarController r in initialRythmBars){
|
||||
r.SetDifficulty();
|
||||
}
|
||||
}
|
||||
|
||||
void Update(){
|
||||
if(dead && !stopped){
|
||||
stopped = true;
|
||||
}
|
||||
}
|
||||
|
||||
public GameObject SpawnFromPool(Vector3 position, Quaternion rotation){
|
||||
GameObject objectToSpawn = Instantiate(prefab, position, rotation, transform);
|
||||
if(difficulty == CanvasDifficulty.Easy){
|
||||
objectToSpawn.GetComponent<RythmBarController>().difficulty = RythmBarController.Difficulty.Easy;
|
||||
}
|
||||
if (difficulty == CanvasDifficulty.Hard){
|
||||
objectToSpawn.GetComponent<RythmBarController>().difficulty = RythmBarController.Difficulty.Hard;
|
||||
}
|
||||
|
||||
if(currentOne == 0){
|
||||
objectToSpawn.GetComponent<RythmBarController>().IsWind();
|
||||
currentOne = turnsToWind - 1;
|
||||
}else{
|
||||
objectToSpawn.GetComponent<RythmBarController>().IsNotWind();
|
||||
currentOne--;
|
||||
}
|
||||
|
||||
return objectToSpawn;
|
||||
}
|
||||
|
||||
public void WindStart(){
|
||||
if (!dead){
|
||||
stopped = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void WindStop(){
|
||||
if (!dead){
|
||||
stopped = false;
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/UI/CanvasManager.cs.meta
Normal file
11
Assets/Scripts/UI/CanvasManager.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 148fe82a0ed1550428d95f34f5e8b142
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
46
Assets/Scripts/UI/CutsceneTextManager.cs
Normal file
46
Assets/Scripts/UI/CutsceneTextManager.cs
Normal file
|
@ -0,0 +1,46 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
|
||||
public class CutsceneTextManager : MonoBehaviour{
|
||||
|
||||
[SerializeField] Animator cutscene;
|
||||
[SerializeField] TextMeshProUGUI text;
|
||||
|
||||
[Space]
|
||||
[TextArea] [SerializeField] string[] texts;
|
||||
int currentText;
|
||||
|
||||
Animator anim;
|
||||
|
||||
void Awake(){
|
||||
anim = GetComponent<Animator>();
|
||||
}
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start(){
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update(){
|
||||
if (Input.anyKeyDown){
|
||||
anim.SetTrigger("Change");
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateText(){
|
||||
if((texts.Length - 1) >= currentText){
|
||||
if(currentText == 1){
|
||||
cutscene.SetTrigger("Start");
|
||||
}
|
||||
AudioManager.instance.Play("Cutscene" + (currentText + 1), false);
|
||||
text.text = texts[currentText];
|
||||
currentText++;
|
||||
}else{
|
||||
text.gameObject.SetActive(false);
|
||||
SceneLoader.instance.LoadScene(1, SceneLoader.DifficultySelected.Easy);
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/UI/CutsceneTextManager.cs.meta
Normal file
11
Assets/Scripts/UI/CutsceneTextManager.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 1ca4f242fd439d840bfd4c9f08c05c6e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
102
Assets/Scripts/UI/MainMenu.cs
Normal file
102
Assets/Scripts/UI/MainMenu.cs
Normal file
|
@ -0,0 +1,102 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using TMPro;
|
||||
using System.Linq;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class MainMenu : MonoBehaviour{
|
||||
|
||||
[SerializeField] Button settingsButton;
|
||||
|
||||
[Space]
|
||||
Resolution[] resolutions;
|
||||
[SerializeField] TMP_Dropdown resolutionDropdown;
|
||||
int currentResolutionIndex;
|
||||
|
||||
[SerializeField] GameObject cutsceneText;
|
||||
Animator anim;
|
||||
bool onSettingsMenu;
|
||||
|
||||
void Start(){
|
||||
anim = GetComponent<Animator>();
|
||||
|
||||
resolutions = Screen.resolutions.Select(resolution => new Resolution { width = resolution.width, height = resolution.height }).Distinct().ToArray();
|
||||
resolutionDropdown.ClearOptions();
|
||||
|
||||
List<string> options = new List<string>();
|
||||
for (int i = 0; i < resolutions.Length; i++){
|
||||
string option = resolutions[i].width + " x " + resolutions[i].height;
|
||||
options.Add(option);
|
||||
|
||||
if(resolutions[i].width == Screen.currentResolution.width && resolutions[i].height == Screen.currentResolution.height){
|
||||
currentResolutionIndex = i;
|
||||
}
|
||||
}
|
||||
|
||||
resolutionDropdown.AddOptions(options);
|
||||
resolutionDropdown.value = currentResolutionIndex;
|
||||
resolutionDropdown.RefreshShownValue();
|
||||
}
|
||||
|
||||
void Update(){
|
||||
if (Input.GetKeyDown(KeyCode.Escape) && onSettingsMenu){
|
||||
anim.SetTrigger("SettingsMenuExit");
|
||||
settingsButton.enabled = true;
|
||||
onSettingsMenu = false;
|
||||
}
|
||||
}
|
||||
|
||||
public void SetQuality(int qualityIndex){
|
||||
QualitySettings.SetQualityLevel(qualityIndex);
|
||||
}
|
||||
|
||||
public void SetResolution(int resolutionIndex){
|
||||
Resolution resolution = resolutions[resolutionIndex];
|
||||
|
||||
Screen.SetResolution(resolution.width, resolution.height, Screen.fullScreen);
|
||||
}
|
||||
|
||||
public void SelectModeEnter(){
|
||||
if (PlayerPrefs.HasKey("AlreadyPlayed")){
|
||||
anim.SetTrigger("SelectModeEnter");
|
||||
}else{
|
||||
anim.SetTrigger("CutsceneFirstTime");
|
||||
StartCoroutine(CutscenePlay());
|
||||
PlayerPrefs.SetInt("AlreadyPlayed", 1);
|
||||
}
|
||||
}
|
||||
|
||||
public void CutsceneEnter(){
|
||||
anim.SetTrigger("CutsceneEnter");
|
||||
StartCoroutine(CutscenePlay());
|
||||
}
|
||||
|
||||
IEnumerator CutscenePlay(){
|
||||
yield return new WaitForSeconds(1f);
|
||||
cutsceneText.SetActive(true);
|
||||
}
|
||||
|
||||
public void SettingsMenuEnter(){
|
||||
anim.SetTrigger("SettingsMenuEnter");
|
||||
settingsButton.enabled = false;
|
||||
StartCoroutine(AccessSettingsMenu());
|
||||
}
|
||||
|
||||
public void Quit(){
|
||||
Application.Quit();
|
||||
}
|
||||
|
||||
IEnumerator AccessSettingsMenu(){
|
||||
yield return new WaitForSeconds(1f);
|
||||
onSettingsMenu = true;
|
||||
}
|
||||
|
||||
public void EasyPlay(){
|
||||
SceneLoader.instance.LoadScene(1, SceneLoader.DifficultySelected.Easy);
|
||||
}
|
||||
|
||||
public void HardPlay(){
|
||||
SceneLoader.instance.LoadScene(1, SceneLoader.DifficultySelected.Hard);
|
||||
}
|
||||
}
|
11
Assets/Scripts/UI/MainMenu.cs.meta
Normal file
11
Assets/Scripts/UI/MainMenu.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 643e147e7250b4543b65fb5627dcd51b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
144
Assets/Scripts/UI/RythmBarController.cs
Normal file
144
Assets/Scripts/UI/RythmBarController.cs
Normal file
|
@ -0,0 +1,144 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class RythmBarController : MonoBehaviour{
|
||||
|
||||
[SerializeField] bool canSpawn = true;
|
||||
bool hasMoved;
|
||||
Animator anim;
|
||||
bool destroyed;
|
||||
public bool difficlutySetted = true;
|
||||
bool hardTriggered;
|
||||
|
||||
[System.Serializable] public enum Difficulty {Easy, Hard}
|
||||
public Difficulty difficulty;
|
||||
|
||||
[Header("Hard Mode Speed")]
|
||||
[SerializeField] float speed;
|
||||
|
||||
[Header("Easy Mode PositionOffset")]
|
||||
[SerializeField] Vector3 offset = new Vector2(145, 0);
|
||||
Vector3 nextLeftPos;
|
||||
Vector3 nextRightPos;
|
||||
[Range(0, .3f)] [SerializeField] float timeToMove = .1f;
|
||||
Vector2 leftVelocity;
|
||||
Vector2 rightVelocity;
|
||||
|
||||
[Space]
|
||||
[SerializeField] GameObject defaultBar;
|
||||
[SerializeField] Transform leftBar;
|
||||
[SerializeField] Transform rightBar;
|
||||
|
||||
[Header("Wind")]
|
||||
[SerializeField] GameObject windBar;
|
||||
[SerializeField] Transform leftWindBar;
|
||||
[SerializeField] Transform rightWindBar;
|
||||
bool isWind;
|
||||
|
||||
CanvasManager canvas;
|
||||
|
||||
void Awake(){
|
||||
canvas = GetComponentInParent<CanvasManager>();
|
||||
}
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start(){
|
||||
anim = GetComponent<Animator>();
|
||||
FindObjectOfType<PlayerController>().onMove.AddListener(() => Move());
|
||||
|
||||
nextLeftPos = leftBar.localPosition;
|
||||
nextRightPos = rightBar.localPosition;
|
||||
|
||||
if (isWind){
|
||||
leftBar.gameObject.SetActive(false);
|
||||
rightBar.gameObject.SetActive(false);
|
||||
}else{
|
||||
leftWindBar.gameObject.SetActive(false);
|
||||
rightWindBar.gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
public void SetDifficulty(){
|
||||
if (canvas.difficulty == CanvasManager.CanvasDifficulty.Easy){
|
||||
difficulty = Difficulty.Easy;
|
||||
}else{
|
||||
difficulty = Difficulty.Hard;
|
||||
}
|
||||
|
||||
difficlutySetted = true;
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update(){
|
||||
if (!difficlutySetted)
|
||||
return;
|
||||
|
||||
if(difficulty == Difficulty.Hard){
|
||||
if (!canvas.stopped){
|
||||
if (isWind){
|
||||
leftWindBar.transform.Translate(Vector2.right * speed * Time.deltaTime);
|
||||
rightWindBar.transform.Translate(Vector2.left * speed * Time.deltaTime);
|
||||
}else{
|
||||
leftBar.transform.Translate(Vector2.right * speed * Time.deltaTime);
|
||||
rightBar.transform.Translate(Vector2.left * speed * Time.deltaTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (difficulty == Difficulty.Easy){
|
||||
if (isWind){
|
||||
leftWindBar.localPosition = Vector2.SmoothDamp(leftWindBar.localPosition, nextLeftPos, ref leftVelocity, timeToMove);
|
||||
rightWindBar.localPosition = Vector2.SmoothDamp(rightWindBar.localPosition, nextRightPos, ref rightVelocity, timeToMove);
|
||||
}else{
|
||||
leftBar.localPosition = Vector2.SmoothDamp(leftBar.localPosition, nextLeftPos, ref leftVelocity, timeToMove);
|
||||
rightBar.localPosition = Vector2.SmoothDamp(rightBar.localPosition, nextRightPos, ref rightVelocity, timeToMove);
|
||||
}
|
||||
}
|
||||
|
||||
if(Vector2.Distance(leftBar.localPosition, rightBar.localPosition) < 175 && !hardTriggered || Vector2.Distance(leftWindBar.localPosition, rightWindBar.localPosition) < 175 && !hardTriggered){
|
||||
if(difficulty == Difficulty.Hard){
|
||||
canvas.onHardMoveIn.Invoke();
|
||||
}
|
||||
hardTriggered = true;
|
||||
}
|
||||
|
||||
if(Vector2.Distance(leftBar.localPosition, rightBar.localPosition) < 10 && !destroyed || Vector2.Distance(leftWindBar.localPosition, rightWindBar.localPosition) < 10 && !destroyed){
|
||||
if(difficulty == Difficulty.Hard){
|
||||
canvas.onHardMoveOut.Invoke();
|
||||
}
|
||||
if (isWind){
|
||||
canvas.onWind.Invoke();
|
||||
}
|
||||
destroyed = true;
|
||||
anim.SetTrigger("Fade");
|
||||
}
|
||||
}
|
||||
|
||||
public void IsWind(){
|
||||
isWind = true;
|
||||
windBar.SetActive(true);
|
||||
}
|
||||
|
||||
public void Destroy(){
|
||||
if(difficulty == Difficulty.Hard){
|
||||
canvas.SpawnFromPool(transform.position, transform.rotation);
|
||||
}
|
||||
Destroy(gameObject);
|
||||
}
|
||||
|
||||
public void IsNotWind(){
|
||||
windBar.SetActive(false);
|
||||
}
|
||||
|
||||
void Move(){
|
||||
if (difficulty == Difficulty.Easy){
|
||||
nextLeftPos += offset;
|
||||
nextRightPos -= offset;
|
||||
if (!hasMoved && canvas != null && canSpawn){
|
||||
canvas.SpawnFromPool(transform.position, transform.rotation);
|
||||
hasMoved = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/UI/RythmBarController.cs.meta
Normal file
11
Assets/Scripts/UI/RythmBarController.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 5abb0ce817616204f957fbd91326d690
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Loading…
Add table
Add a link
Reference in a new issue