mirror of
https://github.com/RHeavenStudio/HeavenStudio.git
synced 2025-06-12 12:17:37 +02:00
Fixed ForkLifter hand grab bug
This commit is contained in:
@ -15,6 +15,7 @@ namespace RhythmHeavenMania
|
||||
public Transform GamesHolder;
|
||||
private float currentBeat;
|
||||
private float currentLength;
|
||||
private string currentSwitchGame;
|
||||
|
||||
public delegate void EventCallback();
|
||||
|
||||
@ -56,7 +57,8 @@ namespace RhythmHeavenMania
|
||||
{
|
||||
new MiniGame("gameManager", new List<GameAction>()
|
||||
{
|
||||
new GameAction("end", delegate { Debug.Log("end"); })
|
||||
new GameAction("end", delegate { Debug.Log("end"); }),
|
||||
new GameAction("switchGame", delegate { GameManager.instance.SwitchGame(currentSwitchGame); })
|
||||
}),
|
||||
new MiniGame("forkLifter", new List<GameAction>()
|
||||
{
|
||||
@ -73,10 +75,10 @@ namespace RhythmHeavenMania
|
||||
// Claps
|
||||
new GameAction("clap", delegate { ClappyTrio.instance.Clap(currentBeat, currentLength); }, true ),
|
||||
|
||||
new GameAction("bop", delegate { ClappyTrio.instance.Bop(); }, true ),
|
||||
new GameAction("bop", delegate { ClappyTrio.instance.Bop(); } ),
|
||||
|
||||
new GameAction("prepare", delegate { ClappyTrio.instance.Prepare(0); }, true ),
|
||||
new GameAction("prepare_alt", delegate { ClappyTrio.instance.Prepare(3); }, true ),
|
||||
new GameAction("prepare", delegate { ClappyTrio.instance.Prepare(0); } ),
|
||||
new GameAction("prepare_alt", delegate { ClappyTrio.instance.Prepare(3); } ),
|
||||
})
|
||||
};
|
||||
|
||||
@ -117,6 +119,8 @@ namespace RhythmHeavenMania
|
||||
{
|
||||
currentLength = GameManager.instance.Beatmap.entities[GameManager.instance.currentEvent].length;
|
||||
|
||||
if (details.Length > 2) currentSwitchGame = details[2];
|
||||
|
||||
GameAction action = game.actions.Find(c => c.actionName == details[1]);
|
||||
action.function.Invoke();
|
||||
|
||||
@ -130,7 +134,7 @@ namespace RhythmHeavenMania
|
||||
}
|
||||
}
|
||||
|
||||
public static List<Beatmap.Entity> GetAllInGameManagerListExcept(string gameName, string[] exclude)
|
||||
public static List<Beatmap.Entity> GetAllInGameManagerList(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>();
|
||||
@ -143,5 +147,21 @@ namespace RhythmHeavenMania
|
||||
}
|
||||
return temp2;
|
||||
}
|
||||
|
||||
public static List<Beatmap.Entity> GetAllPlayerEntities(string gameName)
|
||||
{
|
||||
return GameManager.instance.playerEntities.FindAll(c => c.datamodel.Split('/')[0] == gameName);
|
||||
}
|
||||
|
||||
public static List<Beatmap.Entity> GetAllPlayerEntitiesExcept(string gameName)
|
||||
{
|
||||
return GameManager.instance.playerEntities.FindAll(c => c.datamodel.Split('/')[0] != gameName);
|
||||
}
|
||||
|
||||
// elaborate as fuck, boy
|
||||
public static List<Beatmap.Entity> GetAllPlayerEntitiesExceptBeforeBeat(string gameName, float beat)
|
||||
{
|
||||
return GameManager.instance.playerEntities.FindAll(c => c.datamodel.Split('/')[0] != gameName && c.beat < beat);
|
||||
}
|
||||
}
|
||||
}
|
@ -6,6 +6,7 @@ using UnityEngine;
|
||||
|
||||
using Starpelly;
|
||||
using Newtonsoft.Json;
|
||||
using RhythmHeavenMania.Games;
|
||||
|
||||
namespace RhythmHeavenMania
|
||||
{
|
||||
@ -23,6 +24,9 @@ namespace RhythmHeavenMania
|
||||
|
||||
public float startOffset;
|
||||
|
||||
[Header("Games")]
|
||||
Coroutine currentGameSwitchIE;
|
||||
private string currentGame;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
@ -45,6 +49,8 @@ namespace RhythmHeavenMania
|
||||
Conductor.instance.SetBpm(Beatmap.bpm);
|
||||
|
||||
StartCoroutine(Begin());
|
||||
|
||||
currentGame = eventCaller.GamesHolder.GetComponentsInChildren<Transform>()[1].name;
|
||||
}
|
||||
|
||||
private IEnumerator Begin()
|
||||
@ -97,6 +103,26 @@ namespace RhythmHeavenMania
|
||||
}
|
||||
}
|
||||
|
||||
public void SwitchGame(string game)
|
||||
{
|
||||
if (currentGameSwitchIE != null) StopCoroutine(currentGameSwitchIE);
|
||||
currentGameSwitchIE = StartCoroutine(SwitchGameIE(game));
|
||||
}
|
||||
|
||||
IEnumerator SwitchGameIE(string game)
|
||||
{
|
||||
this.GetComponent<SpriteRenderer>().enabled = true;
|
||||
|
||||
eventCaller.minigames.Find(c => c.name == currentGame).holder.SetActive(false);
|
||||
eventCaller.minigames.Find(c => c.name == game).holder.SetActive(true);
|
||||
eventCaller.minigames.Find(c => c.name == game).holder.GetComponent<Minigame>().OnGameSwitch();
|
||||
currentGame = game;
|
||||
|
||||
yield return new WaitForSeconds(0.1666f);
|
||||
|
||||
|
||||
this.GetComponent<SpriteRenderer>().enabled = false;
|
||||
}
|
||||
|
||||
private void OnGUI()
|
||||
{
|
||||
|
@ -6,7 +6,7 @@ using RhythmHeavenMania.Util;
|
||||
|
||||
namespace RhythmHeavenMania.Games.ClappyTrio
|
||||
{
|
||||
public class ClappyTrio : MonoBehaviour
|
||||
public class ClappyTrio : Minigame
|
||||
{
|
||||
[SerializeField] private GameObject LionLeft;
|
||||
private GameObject LionMiddle;
|
||||
@ -24,7 +24,6 @@ namespace RhythmHeavenMania.Games.ClappyTrio
|
||||
|
||||
public bool playerHitLast = false;
|
||||
|
||||
|
||||
public static ClappyTrio instance { get; set; }
|
||||
|
||||
private void Awake()
|
||||
@ -32,6 +31,14 @@ namespace RhythmHeavenMania.Games.ClappyTrio
|
||||
instance = this;
|
||||
}
|
||||
|
||||
public override void OnGameSwitch()
|
||||
{
|
||||
SetFace(0, 0);
|
||||
SetFace(1, 0);
|
||||
SetFace(2, 0);
|
||||
PlayAnimationAll("Idle");
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
LionMiddle = Instantiate(LionLeft, LionLeft.transform.parent);
|
||||
@ -76,12 +83,16 @@ namespace RhythmHeavenMania.Games.ClappyTrio
|
||||
clapIndex = 0;
|
||||
isClapping = false;
|
||||
currentClappingLength = 0;
|
||||
ClappyTrioPlayer.clapStarted = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Clap(float beat, float length)
|
||||
{
|
||||
ClappyTrioPlayer.clapStarted = true;
|
||||
ClappyTrioPlayer.canHit = true; // this is technically a lie, this just restores the ability to hit
|
||||
|
||||
playerHitLast = false;
|
||||
isClapping = true;
|
||||
lastClapStart = beat;
|
||||
@ -105,14 +116,20 @@ namespace RhythmHeavenMania.Games.ClappyTrio
|
||||
SetFace(1, 1);
|
||||
SetFace(2, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetFace(0, 2);
|
||||
SetFace(1, 2);
|
||||
SetFace(2, 0);
|
||||
}
|
||||
PlayAnimationAll("Bop");
|
||||
}
|
||||
|
||||
private void PlayAnimationAll(string anim)
|
||||
{
|
||||
LionLeft.GetComponent<Animator>().Play(anim, 0, 0);
|
||||
LionMiddle.GetComponent<Animator>().Play(anim, 0, 0);
|
||||
LionPlayer.GetComponent<Animator>().Play(anim, 0, 0);
|
||||
LionLeft.GetComponent<Animator>().Play(anim, -1, 0);
|
||||
LionMiddle.GetComponent<Animator>().Play(anim, -1, 0);
|
||||
LionPlayer.GetComponent<Animator>().Play(anim, -1, 0);
|
||||
}
|
||||
|
||||
public void SetFace(int lion, int type)
|
||||
|
@ -17,10 +17,20 @@ namespace RhythmHeavenMania.Games.ClappyTrio
|
||||
|
||||
private int lastIndex;
|
||||
|
||||
private float perfectTime = 0.25f, lateTime = 0.46f;
|
||||
private float perfectTime = 0.25f, lateTime = 0.43f;
|
||||
|
||||
private bool hit;
|
||||
|
||||
public bool clapStarted = false;
|
||||
public bool canHit;
|
||||
|
||||
private GameObject clapEffect;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
clapEffect = transform.GetChild(4).GetChild(3).gameObject;
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (PlayerInput.Pressed())
|
||||
@ -79,13 +89,20 @@ namespace RhythmHeavenMania.Games.ClappyTrio
|
||||
|
||||
if (canHit)
|
||||
{
|
||||
clapEffect.SetActive(true);
|
||||
Jukebox.PlayOneShotGame("clappyTrio/rightClap");
|
||||
ClappyTrio.instance.playerHitLast = true;
|
||||
|
||||
if (this.canHit)
|
||||
ClappyTrio.instance.playerHitLast = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
clapEffect.SetActive(false);
|
||||
Jukebox.PlayOneShot("miss");
|
||||
ClappyTrio.instance.playerHitLast = false;
|
||||
|
||||
if (clapStarted)
|
||||
this.canHit = false;
|
||||
}
|
||||
|
||||
ClappyTrio.instance.SetFace(2, 4);
|
||||
|
@ -8,7 +8,7 @@ using DG.Tweening;
|
||||
|
||||
namespace RhythmHeavenMania.Games.ForkLifter
|
||||
{
|
||||
public class ForkLifter : MonoBehaviour
|
||||
public class ForkLifter : Minigame
|
||||
{
|
||||
public static ForkLifter instance;
|
||||
|
||||
@ -33,6 +33,12 @@ namespace RhythmHeavenMania.Games.ForkLifter
|
||||
instance = this;
|
||||
}
|
||||
|
||||
public override void OnGameSwitch()
|
||||
{
|
||||
ForkLifterHand.CheckNextFlick();
|
||||
ForkLifterPlayer.instance.RemoveObjFromFork();
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
GameManager = GameManager.instance;
|
||||
|
@ -17,27 +17,29 @@ namespace RhythmHeavenMania.Games.ForkLifter
|
||||
|
||||
public void CheckNextFlick()
|
||||
{
|
||||
allPlayerActions = EventCaller.GetAllInGameManagerListExcept("forkLifter", new string[] { "gulp", "sigh", "prepare" });
|
||||
// allPlayerActions = EventCaller.GetAllInGameManagerList("forkLifter", new string[] { "gulp", "sigh", "prepare" });
|
||||
allPlayerActions = EventCaller.GetAllPlayerEntities("forkLifter");
|
||||
int currentPlayerEvent = GameManager.instance.currentPlayerEvent - EventCaller.GetAllPlayerEntitiesExceptBeforeBeat("forkLifter", Conductor.instance.songPositionInBeats).Count;
|
||||
|
||||
if (GameManager.instance.currentPlayerEvent < allPlayerActions.Count)
|
||||
if (currentPlayerEvent < allPlayerActions.Count)
|
||||
{
|
||||
switch (allPlayerActions[GameManager.instance.currentPlayerEvent].datamodel.Split('/')[1])
|
||||
switch (allPlayerActions[currentPlayerEvent].datamodel.Split('/')[1])
|
||||
{
|
||||
case "pea":
|
||||
ForkLifter.instance.peaPreview.sprite = ForkLifter.instance.peaSprites[0];
|
||||
fastSprite.sprite = fastSprites[0];
|
||||
break;
|
||||
case "topbun":
|
||||
fastSprite.sprite = fastSprites[0];
|
||||
ForkLifter.instance.peaPreview.sprite = ForkLifter.instance.peaSprites[1];
|
||||
fastSprite.sprite = fastSprites[0];
|
||||
break;
|
||||
case "burger":
|
||||
fastSprite.sprite = fastSprites[1];
|
||||
ForkLifter.instance.peaPreview.sprite = ForkLifter.instance.peaSprites[2];
|
||||
fastSprite.sprite = fastSprites[1];
|
||||
break;
|
||||
case "bottombun":
|
||||
fastSprite.sprite = fastSprites[0];
|
||||
ForkLifter.instance.peaPreview.sprite = ForkLifter.instance.peaSprites[3];
|
||||
fastSprite.sprite = fastSprites[0];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -105,6 +105,11 @@ namespace RhythmHeavenMania.Games.ForkLifter
|
||||
}
|
||||
}
|
||||
|
||||
RemoveObjFromFork();
|
||||
}
|
||||
|
||||
public void RemoveObjFromFork()
|
||||
{
|
||||
for (int i = 0; i < early.transform.childCount; i++)
|
||||
{
|
||||
Destroy(early.transform.GetChild(i).gameObject);
|
||||
@ -220,7 +225,7 @@ namespace RhythmHeavenMania.Games.ForkLifter
|
||||
|
||||
FastEffectHit(EligibleHits[currentHitInList].pea.type);
|
||||
|
||||
Jukebox.PlayOneShotGame("miss");
|
||||
Jukebox.PlayOneShot("miss");
|
||||
|
||||
currentEarlyPeasOnFork++;
|
||||
|
||||
@ -249,7 +254,7 @@ namespace RhythmHeavenMania.Games.ForkLifter
|
||||
|
||||
FastEffectHit(EligibleHits[currentHitInList].pea.type);
|
||||
|
||||
Jukebox.PlayOneShotGame("miss");
|
||||
Jukebox.PlayOneShot("miss");
|
||||
|
||||
currentLatePeasOnFork++;
|
||||
|
||||
|
@ -73,7 +73,7 @@ namespace RhythmHeavenMania.Games.ForkLifter
|
||||
if (normalizedBeat > endTime && endstate <= 1)
|
||||
{
|
||||
endstate++;
|
||||
Jukebox.PlayOneShotGame("audience/disappointed");
|
||||
Jukebox.PlayOneShot("audience/disappointed");
|
||||
}
|
||||
|
||||
if (normalizedBeat > 1.35f)
|
||||
|
16
Assets/Scripts/Games/Minigame.cs
Normal file
16
Assets/Scripts/Games/Minigame.cs
Normal file
@ -0,0 +1,16 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace RhythmHeavenMania.Games
|
||||
{
|
||||
public class Minigame : MonoBehaviour
|
||||
{
|
||||
public int firstEnable = 0;
|
||||
|
||||
public virtual void OnGameSwitch()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/Games/Minigame.cs.meta
Normal file
11
Assets/Scripts/Games/Minigame.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c59cddacfd5c42547b00e692560a8312
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user