Force Prepare

This commit is contained in:
fu-majime 2024-03-11 13:00:36 +09:00
parent 824f421f67
commit 2ccc7f5396

View file

@ -131,6 +131,7 @@ namespace HeavenStudio.Games
public int type; public int type;
} }
double gameStartBeat;
public static PowerCalligraphy instance = null; public static PowerCalligraphy instance = null;
// Start is called before the first frame update // Start is called before the first frame update
@ -138,6 +139,14 @@ namespace HeavenStudio.Games
{ {
instance = this; instance = this;
} }
public override void OnGameSwitch(double beat)
{
gameStartBeat = beat;
}
public override void OnPlay(double beat)
{
OnGameSwitch(beat);
}
Writing nowPaper; Writing nowPaper;
bool isPrepare = false; bool isPrepare = false;
@ -152,7 +161,7 @@ namespace HeavenStudio.Games
if (queuedPaper is not null) if (queuedPaper is not null)
{ {
Prepare(queuedPaper.Value.beat, queuedPaper.Value.type); Prepare(queuedPaper.Value.type);
queuedPaper = null; queuedPaper = null;
} }
@ -174,10 +183,9 @@ namespace HeavenStudio.Games
} }
} }
private void SpawnPaper(double beat, int type) private void SpawnPaper(int type)
{ {
nowPaper = Instantiate(basePapers[type], paperHolder).GetComponent<Writing>(); nowPaper = Instantiate(basePapers[type], paperHolder).GetComponent<Writing>();
nowPaper.startBeat = beat;
nowPaper.scrollSpeed = scrollSpeed; nowPaper.scrollSpeed = scrollSpeed;
nowPaper.gameObject.SetActive(true); nowPaper.gameObject.SetActive(true);
nowPaper.Init(); nowPaper.Init();
@ -186,7 +194,8 @@ namespace HeavenStudio.Games
public void Write(double beat, int type) public void Write(double beat, int type)
{ {
Prepare(beat, type); Prepare(type);
nowPaper.startBeat = beat;
nowPaper.Play(); nowPaper.Play();
isPrepare=false; isPrepare=false;
} }
@ -197,28 +206,53 @@ namespace HeavenStudio.Games
{ {
queuedPaper = new QueuedPaper() queuedPaper = new QueuedPaper()
{ {
beat = beat, beat = 0,
type = type, type = type,
}; };
} }
else if(Conductor.instance.songPositionInBeats < beat) else if(Conductor.instance.songPositionInBeats < beat)
{ {
BeatAction.New(instance, new List<BeatAction.Action>(){ BeatAction.New(instance, new List<BeatAction.Action>(){
new BeatAction.Action(beat-1, delegate{ Prepare(beat, type);}) new BeatAction.Action(beat-1, delegate{ Prepare(type);})
}); });
} }
} }
public void Prepare(double beat, int type) public void Prepare(int type)
{ {
if (!isPrepare) if (!isPrepare)
{ {
SpawnPaper(beat, type); SpawnPaper(type);
isPrepare = true; isPrepare = true;
} }
} }
public void ForcePrepare(double beat) public void ForcePrepare(double beat)
{ {
double endBeat = double.MaxValue;
var entities = gameManager.Beatmap.Entities;
RiqEntity firstEnd = entities.Find(c => (c.datamodel.StartsWith("gameManager/switchGame") || c.datamodel.Equals("gameManager/end")) && c.beat > gameStartBeat);
endBeat = firstEnd?.beat ?? endBeat;
RiqEntity nextPaper = entities.Find(v =>
(v.datamodel is "powerCalligraphy/re" or "powerCalligraphy/comma" or "powerCalligraphy/chikara" or "powerCalligraphy/onore" or "powerCalligraphy/sun" or "powerCalligraphy/kokoro" or "powerCalligraphy/face")
&& v.beat >= beat && v.beat < endBeat);
if (nextPaper is not null)
{
int type = nextPaper.datamodel switch
{
"powerCalligraphy/re" => (int)CharacterType.re,
"powerCalligraphy/comma" => (int)CharacterType.comma,
"powerCalligraphy/chikara" => (int)CharacterType.chikara,
"powerCalligraphy/onore" => (int)CharacterType.onore,
"powerCalligraphy/sun" => (int)CharacterType.sun,
"powerCalligraphy/kokoro" => (int)CharacterType.kokoro,
"powerCalligraphy/face" => nextPaper["korean"] ? (int)PowerCalligraphy.CharacterType.face_kr : (int)PowerCalligraphy.CharacterType.face,
_ => throw new NotImplementedException()
};
Prepare(type);
}
} }
public void ChangeScrollSpeed(float x, float y) public void ChangeScrollSpeed(float x, float y)