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;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue