mirror of
https://github.com/RHeavenStudio/HeavenStudio.git
synced 2025-06-12 13:27:41 +02:00
Fork Lifter fully functional again + more progress on dynamic event caller
This commit is contained in:
@ -4,7 +4,7 @@ MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
executionOrder: 50
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
@ -38,11 +39,13 @@ namespace RhythmHeavenMania
|
||||
{
|
||||
public string actionName;
|
||||
public EventCallback function;
|
||||
public bool playerAction = false;
|
||||
|
||||
public GameAction(string actionName, EventCallback function)
|
||||
public GameAction(string actionName, EventCallback function, bool playerAction = false)
|
||||
{
|
||||
this.actionName = actionName;
|
||||
this.function = function;
|
||||
this.playerAction = playerAction;
|
||||
}
|
||||
}
|
||||
|
||||
@ -50,22 +53,42 @@ namespace RhythmHeavenMania
|
||||
{
|
||||
minigames = new List<MiniGame>()
|
||||
{
|
||||
new MiniGame("gameManager", new List<GameAction>()
|
||||
{
|
||||
new GameAction("end", delegate { Debug.Log("end"); })
|
||||
}),
|
||||
new MiniGame("forkLifter", new List<GameAction>()
|
||||
{
|
||||
new GameAction("pea", delegate { ForkLifter.instance.Flick(currentBeat, 0); } ),
|
||||
new GameAction("topbun", delegate { ForkLifter.instance.Flick(currentBeat, 1); } ),
|
||||
new GameAction("burger", delegate { ForkLifter.instance.Flick(currentBeat, 2); } ),
|
||||
new GameAction("bottombun", delegate { ForkLifter.instance.Flick(currentBeat, 3); } ),
|
||||
new GameAction("pea", delegate { ForkLifter.instance.Flick(currentBeat, 0); }, true ),
|
||||
new GameAction("topbun", delegate { ForkLifter.instance.Flick(currentBeat, 1); }, true ),
|
||||
new GameAction("burger", delegate { ForkLifter.instance.Flick(currentBeat, 2); }, true ),
|
||||
new GameAction("bottombun", delegate { ForkLifter.instance.Flick(currentBeat, 3); }, true ),
|
||||
new GameAction("prepare", delegate { ForkLifter.instance.ForkLifterHand.Prepare(); }),
|
||||
new GameAction("gulp", delegate { ForkLifterPlayer.instance.Eat(); }),
|
||||
new GameAction("sigh", delegate { Jukebox.PlayOneShot("sigh"); })
|
||||
})
|
||||
};
|
||||
|
||||
for (int i = 0; i < minigames.Count; i++)
|
||||
for (int i = 1; i < minigames.Count; i++)
|
||||
{
|
||||
minigames[i].holder = GamesHolder.Find(minigames[i].name).gameObject;
|
||||
}
|
||||
|
||||
for (int i = 0; i < GameManager.instance.Beatmap.entities.Count; i++)
|
||||
{
|
||||
string[] e = GameManager.instance.Beatmap.entities[i].datamodel.Split('/');
|
||||
try
|
||||
{
|
||||
if (minigames.Find(c => c.name == e[0]).actions.Find(c => c.actionName == e[1]).playerAction == true)
|
||||
{
|
||||
GameManager.instance.playerEntities.Add(GameManager.instance.Beatmap.entities[i]);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.LogWarning(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void Update()
|
||||
@ -74,7 +97,7 @@ namespace RhythmHeavenMania
|
||||
currentBeat = GameManager.instance.Beatmap.entities[GameManager.instance.currentEvent].beat;
|
||||
}
|
||||
|
||||
public void CallEvent(string event_, float beat)
|
||||
public void CallEvent(string event_)
|
||||
{
|
||||
string[] details = event_.Split('/');
|
||||
MiniGame game = minigames.Find(c => c.name == details[0]);
|
||||
@ -83,11 +106,28 @@ namespace RhythmHeavenMania
|
||||
{
|
||||
GameAction action = game.actions.Find(c => c.actionName == details[1]);
|
||||
action.function.Invoke();
|
||||
|
||||
if (action.playerAction == true)
|
||||
GameManager.instance.currentPlayerEvent++;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.LogWarning("Event not found! May be spelled wrong or it is not implemented.");
|
||||
}
|
||||
}
|
||||
|
||||
public static List<Beatmap.Entity> GetAllInGameManagerListExcept(string gameName, string[] exclude)
|
||||
{
|
||||
List<Beatmap.Entity> temp1 = GameManager.instance.Beatmap.entities.FindAll(c => c.datamodel.Split('/')[0] == gameName);
|
||||
List<Beatmap.Entity> temp2 = new List<Beatmap.Entity>();
|
||||
for (int i = 0; i < temp1.Count; i++)
|
||||
{
|
||||
if (!exclude.Any(temp1[i].datamodel.Split('/')[1].Contains))
|
||||
{
|
||||
temp2.Add(temp1[i]);
|
||||
}
|
||||
}
|
||||
return temp2;
|
||||
}
|
||||
}
|
||||
}
|
@ -15,8 +15,9 @@ namespace RhythmHeavenMania
|
||||
private EventCaller eventCaller;
|
||||
|
||||
public Beatmap Beatmap;
|
||||
[HideInInspector] public List<Beatmap.Entity> playerEntities;
|
||||
|
||||
public int currentEvent;
|
||||
public int currentEvent, currentPlayerEvent;
|
||||
|
||||
public TextAsset txt;
|
||||
|
||||
@ -62,7 +63,7 @@ namespace RhythmHeavenMania
|
||||
{
|
||||
if (Conductor.instance.songPositionInBeats >= entities[currentEvent])
|
||||
{
|
||||
eventCaller.CallEvent(Beatmap.entities[currentEvent].datamodel, Beatmap.entities[currentEvent].beat);
|
||||
eventCaller.CallEvent(Beatmap.entities[currentEvent].datamodel);
|
||||
|
||||
currentEvent++;
|
||||
}
|
||||
@ -79,7 +80,9 @@ namespace RhythmHeavenMania
|
||||
if (Beatmap.entities.Count > 0)
|
||||
{
|
||||
List<float> entities = Beatmap.entities.Select(c => c.beat).ToList();
|
||||
List<float> entities_p = playerEntities.Select(c => c.beat).ToList();
|
||||
currentEvent = entities.IndexOf(Mathp.GetClosestInList(entities, Conductor.instance.songPositionInBeats));
|
||||
currentPlayerEvent = entities_p.IndexOf(Mathp.GetClosestInList(entities_p, Conductor.instance.songPositionInBeats));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,7 @@ MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
executionOrder: 100
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
|
@ -13,15 +13,15 @@ namespace RhythmHeavenMania.Games.ForkLifter
|
||||
|
||||
public Sprite[] fastSprites;
|
||||
|
||||
// List<GameManager.Event> allPlayerActions;
|
||||
List<Beatmap.Entity> allPlayerActions;
|
||||
|
||||
public void CheckNextFlick()
|
||||
{
|
||||
// allPlayerActions = GameManager.instance.Events.FindAll(c => c.eventName != "gulp" && c.eventName != "sigh" && c.eventName != "prepare");
|
||||
allPlayerActions = EventCaller.GetAllInGameManagerListExcept("forkLifter", new string[] { "gulp", "sigh", "prepare" });
|
||||
|
||||
/*if (GameManager.instance.currentEventPlayer < allPlayerActions.Count)
|
||||
if (GameManager.instance.currentPlayerEvent < allPlayerActions.Count)
|
||||
{
|
||||
switch (allPlayerActions[GameManager.instance.currentEventPlayer].eventName)
|
||||
switch (allPlayerActions[GameManager.instance.currentPlayerEvent].datamodel.Split('/')[1])
|
||||
{
|
||||
case "pea":
|
||||
ForkLifter.instance.peaPreview.sprite = ForkLifter.instance.peaSprites[0];
|
||||
@ -44,7 +44,7 @@ namespace RhythmHeavenMania.Games.ForkLifter
|
||||
else
|
||||
{
|
||||
ForkLifter.instance.peaPreview.sprite = null;
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
public void Prepare()
|
||||
|
Reference in New Issue
Block a user