mirror of
https://github.com/RHeavenStudioPlus/HeavenStudioPlus.git
synced 2024-11-08 18:55:07 +00:00
Added inactive functions
I'm going to flesh it out more in the next commit
This commit is contained in:
parent
273608ea6e
commit
d2bc7d9871
7 changed files with 101 additions and 39 deletions
|
@ -60,7 +60,7 @@ namespace RhythmHeavenMania
|
|||
|
||||
}
|
||||
|
||||
public void CallEvent(Beatmap.Entity entity)
|
||||
public void CallEvent(Beatmap.Entity entity, bool gameActive)
|
||||
{
|
||||
string[] details = entity.datamodel.Split('/');
|
||||
Minigames.Minigame game = minigames.Find(c => c.name == details[0]);
|
||||
|
@ -71,8 +71,14 @@ namespace RhythmHeavenMania
|
|||
if (details.Length > 2) currentSwitchGame = details[2];
|
||||
|
||||
Minigames.GameAction action = game.actions.Find(c => c.actionName == details[1]);
|
||||
action.function.Invoke();
|
||||
|
||||
if (gameActive)
|
||||
{
|
||||
action.function.Invoke();
|
||||
}
|
||||
else
|
||||
{
|
||||
action.inactiveFunction.Invoke();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
|
@ -26,7 +26,7 @@ namespace RhythmHeavenMania
|
|||
public Games.Global.Flash fade;
|
||||
|
||||
[Header("Games")]
|
||||
public string currentGame;
|
||||
public Minigame currentGame;
|
||||
Coroutine currentGameSwitchIE;
|
||||
|
||||
[Header("Properties")]
|
||||
|
@ -157,25 +157,29 @@ namespace RhythmHeavenMania
|
|||
if (Conductor.instance.songPositionInBeats >= entities[currentEvent] /*&& SongPosLessThanClipLength(Conductor.instance.songPositionInBeats)*/)
|
||||
{
|
||||
// allows for multiple events on the same beat to be executed on the same frame, so no more 1-frame delay
|
||||
var entitesAtSameBeat = Beatmap.entities.FindAll(c => c.beat == Beatmap.entities[currentEvent].beat && !EventCaller.FXOnlyGames().Contains(EventCaller.instance.GetMinigame(c.datamodel.Split('/')[0])));
|
||||
var entitiesAtSameBeat = Beatmap.entities.FindAll(c => c.beat == Beatmap.entities[currentEvent].beat && !EventCaller.FXOnlyGames().Contains(EventCaller.instance.GetMinigame(c.datamodel.Split('/')[0])));
|
||||
var fxEntities = Beatmap.entities.FindAll(c => c.beat == Beatmap.entities[currentEvent].beat && EventCaller.FXOnlyGames().Contains(EventCaller.instance.GetMinigame(c.datamodel.Split('/')[0])));
|
||||
|
||||
// FX entities should ALWAYS execute before gameplay entities
|
||||
for (int i = 0; i < fxEntities.Count; i++)
|
||||
{
|
||||
eventCaller.CallEvent(fxEntities[i]);
|
||||
eventCaller.CallEvent(fxEntities[i], true);
|
||||
currentEvent++;
|
||||
}
|
||||
|
||||
for (int i = 0; i < entitesAtSameBeat.Count; i++)
|
||||
for (int i = 0; i < entitiesAtSameBeat.Count; i++)
|
||||
{
|
||||
var entity = entitesAtSameBeat[i];
|
||||
var entity = entitiesAtSameBeat[i];
|
||||
// if game isn't loaded, preload game so whatever event that would be called will still run outside if needed
|
||||
if (entitesAtSameBeat[i].datamodel.Split('/')[0] != currentGame && !preloadedGames.Contains(preloadedGames.Find(c => c.name == entitesAtSameBeat[i].datamodel.Split('/')[0])))
|
||||
if (entitiesAtSameBeat[i].datamodel.Split('/')[0] != currentGame && !preloadedGames.Contains(preloadedGames.Find(c => c.name == entitiesAtSameBeat[i].datamodel.Split('/')[0])))
|
||||
{
|
||||
PreloadGame(entitesAtSameBeat[i].datamodel.Split('/')[0]);
|
||||
//PreloadGame(entitesAtSameBeat[i].datamodel.Split('/')[0]);
|
||||
eventCaller.CallEvent(entitiesAtSameBeat[i], false);
|
||||
}
|
||||
else
|
||||
{
|
||||
eventCaller.CallEvent(entitiesAtSameBeat[i], true);
|
||||
}
|
||||
eventCaller.CallEvent(entitesAtSameBeat[i]);
|
||||
|
||||
// Thank you to @shshwdr for bring this to my attention
|
||||
currentEvent++;
|
||||
|
@ -362,7 +366,6 @@ namespace RhythmHeavenMania
|
|||
currentGameO.transform.parent = eventCaller.GamesHolder.transform;
|
||||
currentGameO.name = game;
|
||||
}
|
||||
|
||||
/*if (onGameSwitch)
|
||||
{
|
||||
if (GetGame(currentGame).GetComponent<Minigame>() != null)
|
||||
|
@ -370,6 +373,9 @@ namespace RhythmHeavenMania
|
|||
}*/
|
||||
|
||||
SetCurrentGame(game);
|
||||
Minigame miniGame = currentGameO.GetComponent<Minigame>();
|
||||
if (miniGame != null)
|
||||
miniGame.OnGameSwitch();
|
||||
|
||||
ResetCamera();
|
||||
}
|
||||
|
@ -411,13 +417,23 @@ namespace RhythmHeavenMania
|
|||
return EventCaller.instance.minigames.Find(c => c.name == name);
|
||||
}
|
||||
|
||||
// never gonna use this
|
||||
public Minigames.Minigame GetCurrentGame()
|
||||
public Minigames.Minigame GetGameInfo(Minigame game)
|
||||
{
|
||||
return eventCaller.minigames.Find(c => c.name == transform.GetComponentsInChildren<Transform>()[1].name);
|
||||
if (game == null)
|
||||
return null;
|
||||
return GetGameInfo(game.name);
|
||||
}
|
||||
|
||||
public string GetCurrentGameName()
|
||||
{
|
||||
if(currentGame == null)
|
||||
{
|
||||
return "noGame";
|
||||
}
|
||||
return currentGame.name;
|
||||
}
|
||||
|
||||
public void SetCurrentGame(string game)
|
||||
public void SetCurrentGame(Minigame game)
|
||||
{
|
||||
currentGame = game;
|
||||
if (GetGameInfo(currentGame) != null) CircleCursor.InnerCircle.GetComponent<SpriteRenderer>().color = Colors.Hex2RGB(GetGameInfo(currentGame).color);
|
||||
|
|
|
@ -39,6 +39,7 @@ namespace RhythmHeavenMania.Games.ForkLifter
|
|||
|
||||
public override void OnGameSwitch()
|
||||
{
|
||||
base.OnGameSwitch();
|
||||
ForkLifterHand.CheckNextFlick();
|
||||
}
|
||||
|
||||
|
|
|
@ -44,9 +44,24 @@ namespace RhythmHeavenMania.Games
|
|||
|
||||
public int firstEnable = 0;
|
||||
|
||||
public string name = "";
|
||||
|
||||
public virtual void OnGameSwitch()
|
||||
{
|
||||
//Below is a template that can be used for handling previous entities. There are multiple sections that have different functions, you don't need to use all of them
|
||||
|
||||
float beat = Conductor.instance.songPositionInBeats;
|
||||
List<Beatmap.Entity> prevEntities = GameManager.instance.Beatmap.entities.FindAll(c => c.beat <= beat && c.datamodel.Split(0) == name);
|
||||
|
||||
//section below is if you only want to look at entities that overlap the game switch
|
||||
foreach(Beatmap.Entity entity in prevEntities)
|
||||
{
|
||||
if(entity.beat + entity.length >= beat)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public virtual void OnTimeChange()
|
||||
|
|
|
@ -44,21 +44,6 @@ namespace RhythmHeavenMania.Games.SpaceSoccer
|
|||
startBeat = dispensedBeat;
|
||||
nextAnimBeat = startBeat + GetAnimLength(State.Dispensing);
|
||||
kicker.kickTimes = 0;
|
||||
if (kicker.player)
|
||||
{
|
||||
MultiSound.Play(new MultiSound.Sound[]
|
||||
{
|
||||
new MultiSound.Sound("spaceSoccer/dispenseNoise", dispensedBeat),
|
||||
new MultiSound.Sound("spaceSoccer/dispenseTumble1", dispensedBeat + 0.25f),
|
||||
new MultiSound.Sound("spaceSoccer/dispenseTumble2", dispensedBeat + 0.5f),
|
||||
new MultiSound.Sound("spaceSoccer/dispenseTumble2B",dispensedBeat + 0.5f),
|
||||
new MultiSound.Sound("spaceSoccer/dispenseTumble3", dispensedBeat + 0.75f),
|
||||
new MultiSound.Sound("spaceSoccer/dispenseTumble4", dispensedBeat + 1f),
|
||||
new MultiSound.Sound("spaceSoccer/dispenseTumble5", dispensedBeat + 1.25f),
|
||||
new MultiSound.Sound("spaceSoccer/dispenseTumble6", dispensedBeat + 1.5f),
|
||||
new MultiSound.Sound("spaceSoccer/dispenseTumble6B",dispensedBeat + 1.75f),
|
||||
});
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -44,23 +44,44 @@ namespace RhythmHeavenMania.Games.SpaceSoccer
|
|||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void Dispense(float beat)
|
||||
{
|
||||
ballDispensed = true;
|
||||
for (int i = 0; i < kickers.Count; i++)
|
||||
{
|
||||
Kicker kicker = kickers[i];
|
||||
if (i == 0) kicker.player = true;
|
||||
|
||||
if (kicker.ball != null) return;
|
||||
ballDispensed = true;
|
||||
|
||||
GameObject ball = Instantiate(ballRef, transform);
|
||||
ball.SetActive(true);
|
||||
Ball ball_ = ball.GetComponent<Ball>();
|
||||
ball_.Init(kicker, beat);
|
||||
if (kicker.player)
|
||||
{
|
||||
DispenseSound(beat);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void DispenseSound(float beat)
|
||||
{
|
||||
MultiSound.Play(new MultiSound.Sound[]
|
||||
{
|
||||
new MultiSound.Sound("games/spaceSoccer/dispenseNoise", beat),
|
||||
new MultiSound.Sound("games/spaceSoccer/dispenseTumble1", beat + 0.25f),
|
||||
new MultiSound.Sound("games/spaceSoccer/dispenseTumble2", beat + 0.5f),
|
||||
new MultiSound.Sound("games/spaceSoccer/dispenseTumble2B",beat + 0.5f),
|
||||
new MultiSound.Sound("games/spaceSoccer/dispenseTumble3", beat + 0.75f),
|
||||
new MultiSound.Sound("games/spaceSoccer/dispenseTumble4", beat + 1f),
|
||||
new MultiSound.Sound("games/spaceSoccer/dispenseTumble5", beat + 1.25f),
|
||||
new MultiSound.Sound("games/spaceSoccer/dispenseTumble6", beat + 1.5f),
|
||||
new MultiSound.Sound("games/spaceSoccer/dispenseTumble6B",beat + 1.75f),
|
||||
}, false);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -50,12 +50,21 @@ namespace RhythmHeavenMania
|
|||
public bool resizable;
|
||||
public List<Param> parameters;
|
||||
public bool hidden;
|
||||
public EventCallback inactiveFunction;
|
||||
|
||||
/* If you want to add additional arguments to GameAction, leave `bool hidden = false` as the last parameter
|
||||
* You can specify an action as hidden by adding `hidden: value` as the final parameter in your call
|
||||
* (Even if you haven't used all prior arguments)
|
||||
*/
|
||||
public GameAction(string actionName, EventCallback function, float defaultLength = 1, bool resizable = false, List<Param> parameters = null, bool hidden = false)
|
||||
/// <summary>
|
||||
/// <para>Creates a block that can be used in the editor. The block's function and attributes are defined in the parentheses.</para>
|
||||
/// <para>Note: Every parameter after the second one is an optional parameter. You can change optional parameters by adding (name): (value) after the second parameter.</para>
|
||||
/// </summary>
|
||||
/// <param name="actionName">Name of the block</param>
|
||||
/// <param name="function"><para>What the block does when read during playback</para>
|
||||
/// <para>Only does this if the game that it is associated with is loaded.</para></param>
|
||||
/// <param name="defaultLength">How long the block appears in the editor</param>
|
||||
/// <param name="resizable">Allows the user to resize the block</param>
|
||||
/// <param name="parameters">Extra parameters for this block that change how it functions.</param>
|
||||
/// <param name="hidden">Prevents the block from being shown in the game list. Block will still function normally if it is in the timeline.</param>
|
||||
/// <param name="inactiveFunction">What the block does when read while the game it's associated with isn't loaded.</param>
|
||||
public GameAction(string actionName, EventCallback function, float defaultLength = 1, bool resizable = false, List<Param> parameters = null, bool hidden = false, EventCallback inactiveFunction = null)
|
||||
{
|
||||
this.actionName = actionName;
|
||||
this.function = function;
|
||||
|
@ -63,6 +72,8 @@ namespace RhythmHeavenMania
|
|||
this.resizable = resizable;
|
||||
this.parameters = parameters;
|
||||
this.hidden = hidden;
|
||||
if(inactiveFunction == null) inactiveFunction = delegate { };
|
||||
this.inactiveFunction = inactiveFunction;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -74,6 +85,12 @@ namespace RhythmHeavenMania
|
|||
public string propertyCaption;
|
||||
public string tooltip;
|
||||
|
||||
/// <summary>
|
||||
/// A parameter that changes the function of a GameAction.
|
||||
/// </summary>
|
||||
/// <param name="propertyName">The name of the variable that's being changed. Must be one of the variables in <see cref="Beatmap.Entity"/></param>
|
||||
/// <param name="parameter">The value of the parameter</param>
|
||||
/// <param name="propertyCaption">The name shown in the editor. Can be anything you want.</param>
|
||||
public Param(string propertyName, object parameter, string propertyCaption, string tooltip = "")
|
||||
{
|
||||
this.propertyName = propertyName;
|
||||
|
@ -91,7 +108,7 @@ namespace RhythmHeavenMania
|
|||
{
|
||||
new Minigame("gameManager", "Game Manager", "", false, true, new List<GameAction>()
|
||||
{
|
||||
new GameAction("switchGame", delegate { GameManager.instance.SwitchGame(eventCaller.currentSwitchGame); }, 0.5f),
|
||||
new GameAction("switchGame", delegate { GameManager.instance.SwitchGame(eventCaller.currentSwitchGame); }, 0.5f, inactiveFunction: delegate { GameManager.instance.SwitchGame(eventCaller.currentSwitchGame); }),
|
||||
new GameAction("end", delegate { Debug.Log("end"); }),
|
||||
new GameAction("skill star", delegate { }, 1f, true),
|
||||
new GameAction("flash", delegate
|
||||
|
@ -271,7 +288,8 @@ namespace RhythmHeavenMania
|
|||
}),
|
||||
new Minigame("spaceSoccer", "Space Soccer", "B888F8", false, false, new List<GameAction>()
|
||||
{
|
||||
new GameAction("ball dispense", delegate { SpaceSoccer.instance.Dispense(eventCaller.currentEntity.beat); }, 2f),
|
||||
new GameAction("ball dispense", delegate { SpaceSoccer.instance.Dispense(eventCaller.currentEntity.beat); }, 2f,
|
||||
inactiveFunction: delegate { SpaceSoccer.DispenseSound(eventCaller.currentEntity.beat); }),
|
||||
new GameAction("keep-up", delegate { }, 4f, true),
|
||||
new GameAction("high kick-toe!", delegate { }, 3f, false, new List<Param>()
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue