mirror of
https://github.com/RHeavenStudioPlus/HeavenStudioPlus.git
synced 2024-11-10 03:35:10 +00:00
4c4d0a7a7a
* add pause menu assets * layout and animation for pause * make play mode prefab function re-assign unused class inheritance * remove filepath * don't init medals twice * remove PlayerActionObject * initial attempt at anti-note lock TODO: circumvent inputs clearing themselves making the functionality not work * properly implement input lock prevention * fix error on editor open * functional pause menu * bugfix * make unpausing not reset current play statistics * serialize initializer components in inspector instead of procedurally generating * sanity check * note for fade * make flashes in the camera prefabs instead of in world space remove / reorganize script files address issue #411 * fix bug with perfect campaign make minigame transitions hide the game canvas adjust animation of the song credits textbox * fully functional intro scene (placeholder for future title screen) refactored entire game loading procedure re-organized some files * add interaction query to disclaimer text * reword legal * anchor section medals to section display more tempo change placement controls * operation order bugfix * prep for future ratings and stats * loading text * autoload opening scene * splash screen adjustments added setting to force enable splash screen * adjust setting entry
136 lines
No EOL
5 KiB
C#
136 lines
No EOL
5 KiB
C#
using System;
|
|
using System.Linq;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.Events;
|
|
|
|
namespace HeavenStudio
|
|
{
|
|
public class EventCaller : MonoBehaviour
|
|
{
|
|
public Transform GamesHolder;
|
|
public DynamicBeatmap.DynamicEntity currentEntity = new DynamicBeatmap.DynamicEntity();
|
|
public string currentSwitchGame;
|
|
|
|
public delegate void EventCallback();
|
|
|
|
public static EventCaller instance { get; private set; }
|
|
|
|
public List<Minigames.Minigame> minigames = new List<Minigames.Minigame>();
|
|
|
|
public Minigames.Minigame GetMinigame(string gameName)
|
|
{
|
|
return minigames.Find(c => c.name == gameName);
|
|
}
|
|
|
|
public Minigames.GameAction GetGameAction(Minigames.Minigame game, string action)
|
|
{
|
|
return game.actions.Find(c => c.actionName == action);
|
|
}
|
|
|
|
public Minigames.Param GetGameParam(Minigames.Minigame game, string action, string param)
|
|
{
|
|
return GetGameAction(game, action).parameters.Find(c => c.propertyName == param);
|
|
}
|
|
|
|
public void Init()
|
|
{
|
|
instance = this;
|
|
|
|
currentEntity = new DynamicBeatmap.DynamicEntity();
|
|
|
|
Minigames.Init(this);
|
|
|
|
List<Minigames.Minigame> minigamesInBeatmap = new List<Minigames.Minigame>();
|
|
for (int i = 0; i < GameManager.instance.Beatmap.entities.Count; i++)
|
|
{
|
|
//go through every entity in the timeline and add the game that they're from to the minigamesInBeatmap list (ignore entities from FX only categories, i.e. Game Manager and Count-Ins)
|
|
Minigames.Minigame game = GetMinigame(GameManager.instance.Beatmap.entities[i].datamodel.Split('/')[0]);
|
|
if (!minigamesInBeatmap.Contains(game) && !FXOnlyGames().Contains(game))
|
|
{
|
|
minigamesInBeatmap.Add(game);
|
|
}
|
|
}
|
|
|
|
for (int i = 0; i < minigamesInBeatmap.Count; i++)
|
|
{
|
|
// minigames[minigames.FindIndex(c => c.name == minigamesInBeatmap[i].name)].holder = Resources.Load<GameObject>($"Games/{minigamesInBeatmap[i].name}");
|
|
}
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
|
|
}
|
|
|
|
public void CallEvent(DynamicBeatmap.DynamicEntity entity, bool gameActive)
|
|
{
|
|
string[] details = entity.datamodel.Split('/');
|
|
Minigames.Minigame game = minigames.Find(c => c.name == details[0]);
|
|
try
|
|
{
|
|
currentEntity = entity;
|
|
|
|
if (details.Length > 2) currentSwitchGame = details[2];
|
|
|
|
Minigames.GameAction action = game.actions.Find(c => c.actionName == details[1]);
|
|
if (gameActive)
|
|
{
|
|
action.function.Invoke();
|
|
}
|
|
else
|
|
{
|
|
action.inactiveFunction.Invoke();
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Debug.LogWarning("Event not found! May be spelled wrong or it is not implemented.\n" + ex);
|
|
}
|
|
}
|
|
|
|
public void CallPreEvent(DynamicBeatmap.DynamicEntity entity)
|
|
{
|
|
string[] details = entity.datamodel.Split('/');
|
|
Minigames.Minigame game = minigames.Find(c => c.name == details[0]);
|
|
try
|
|
{
|
|
currentEntity = entity;
|
|
|
|
Minigames.GameAction action = game.actions.Find(c => c.actionName == details[1]);
|
|
action.preFunction.Invoke();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Debug.LogWarning("Event not found! May be spelled wrong or it is not implemented.\n" + ex);
|
|
}
|
|
}
|
|
|
|
public static List<DynamicBeatmap.DynamicEntity> GetAllInGameManagerList(string gameName, string[] include)
|
|
{
|
|
List<DynamicBeatmap.DynamicEntity> temp1 = GameManager.instance.Beatmap.entities.FindAll(c => c.datamodel.Split('/')[0] == gameName);
|
|
List<DynamicBeatmap.DynamicEntity> temp2 = new List<DynamicBeatmap.DynamicEntity>();
|
|
foreach (string s in include)
|
|
{
|
|
temp2.AddRange(temp1.FindAll(c => c.datamodel.Split('/')[1].Equals(s)));
|
|
}
|
|
return temp2;
|
|
}
|
|
|
|
public static List<DynamicBeatmap.DynamicEntity> GetAllInGameManagerListExclude(string gameName, string[] exclude)
|
|
{
|
|
List<DynamicBeatmap.DynamicEntity> temp1 = GameManager.instance.Beatmap.entities.FindAll(c => c.datamodel.Split('/')[0] == gameName);
|
|
List<DynamicBeatmap.DynamicEntity> temp2 = new List<DynamicBeatmap.DynamicEntity>();
|
|
foreach (string s in exclude)
|
|
{
|
|
temp2.AddRange(temp1.FindAll(c => !c.datamodel.Split('/')[1].Equals(s)));
|
|
}
|
|
return temp2;
|
|
}
|
|
|
|
public static List<Minigames.Minigame> FXOnlyGames()
|
|
{
|
|
return instance.minigames.FindAll(c => c.fxOnly == true).ToList();
|
|
}
|
|
}
|
|
} |