78 lines
2.3 KiB
C#
78 lines
2.3 KiB
C#
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;
|
|
}
|
|
}
|
|
}
|