mirror of
https://github.com/RHeavenStudio/HeavenStudio.git
synced 2025-06-13 17:47:38 +02:00
Power Calligraphy fixed (#778)
* Power Calligraphy (WIP) * modified: Assets/Scripts/Games/PowerCalligraphy/Writing.cs * comma * onore * sweep * sun * kokoro * Power Calligraphy (WIP) * Changed object to prefab * Force Prepare * Changed so that the next paper is set correctly. * updated controllers
This commit is contained in:
@ -20,74 +20,49 @@ namespace HeavenStudio.Games.Loaders
|
||||
{
|
||||
new GameAction("re", "Re (レ)")
|
||||
{
|
||||
preFunction = delegate {var e = eventCaller.currentEntity; PowerCalligraphy.instance.QueuePaper(e.beat, (int)PowerCalligraphy.CharacterType.re, e["prepare"]); },
|
||||
preFunction = delegate {var e = eventCaller.currentEntity; PowerCalligraphy.instance.QueuePaper(e.beat, (int)PowerCalligraphy.CharacterType.re); },
|
||||
function = delegate {var e = eventCaller.currentEntity; PowerCalligraphy.instance.Write(e.beat, (int)PowerCalligraphy.CharacterType.re); },
|
||||
parameters = new List<Param>()
|
||||
{
|
||||
new Param("prepare", false, "Force Prepare", "Toggle if the cue should be prepared."),
|
||||
},
|
||||
defaultLength = 8f,
|
||||
},
|
||||
new GameAction("comma", "Comma (、)")
|
||||
{
|
||||
preFunction = delegate {var e = eventCaller.currentEntity; PowerCalligraphy.instance.QueuePaper(e.beat, (int)PowerCalligraphy.CharacterType.comma, e["prepare"]); },
|
||||
preFunction = delegate {var e = eventCaller.currentEntity; PowerCalligraphy.instance.QueuePaper(e.beat, (int)PowerCalligraphy.CharacterType.comma); },
|
||||
function = delegate {var e = eventCaller.currentEntity; PowerCalligraphy.instance.Write(e.beat, (int)PowerCalligraphy.CharacterType.comma); },
|
||||
parameters = new List<Param>()
|
||||
{
|
||||
new Param("prepare", false, "Force Prepare", "Toggle if the cue should be prepared."),
|
||||
},
|
||||
defaultLength = 8f,
|
||||
},
|
||||
new GameAction("chikara", "Chikara (力)")
|
||||
{
|
||||
preFunction = delegate {var e = eventCaller.currentEntity; PowerCalligraphy.instance.QueuePaper(e.beat, (int)PowerCalligraphy.CharacterType.chikara, e["prepare"]); },
|
||||
preFunction = delegate {var e = eventCaller.currentEntity; PowerCalligraphy.instance.QueuePaper(e.beat, (int)PowerCalligraphy.CharacterType.chikara); },
|
||||
function = delegate {var e = eventCaller.currentEntity; PowerCalligraphy.instance.Write(e.beat, (int)PowerCalligraphy.CharacterType.chikara); },
|
||||
parameters = new List<Param>()
|
||||
{
|
||||
new Param("prepare", false, "Force Prepare", "Toggle if the cue should be prepared."),
|
||||
},
|
||||
defaultLength = 8f,
|
||||
},
|
||||
new GameAction("onore", "Onore (己)")
|
||||
{
|
||||
preFunction = delegate {var e = eventCaller.currentEntity; PowerCalligraphy.instance.QueuePaper(e.beat, (int)PowerCalligraphy.CharacterType.onore, e["prepare"]); },
|
||||
preFunction = delegate {var e = eventCaller.currentEntity; PowerCalligraphy.instance.QueuePaper(e.beat, (int)PowerCalligraphy.CharacterType.onore); },
|
||||
function = delegate {var e = eventCaller.currentEntity; PowerCalligraphy.instance.Write(e.beat, (int)PowerCalligraphy.CharacterType.onore); },
|
||||
parameters = new List<Param>()
|
||||
{
|
||||
new Param("prepare", false, "Force Prepare", "Toggle if the cue should be prepared."),
|
||||
},
|
||||
defaultLength = 8f,
|
||||
},
|
||||
new GameAction("sun", "Sun (寸)")
|
||||
{
|
||||
preFunction = delegate {var e = eventCaller.currentEntity; PowerCalligraphy.instance.QueuePaper(e.beat, (int)PowerCalligraphy.CharacterType.sun, e["prepare"]); },
|
||||
preFunction = delegate {var e = eventCaller.currentEntity; PowerCalligraphy.instance.QueuePaper(e.beat, (int)PowerCalligraphy.CharacterType.sun); },
|
||||
function = delegate {var e = eventCaller.currentEntity; PowerCalligraphy.instance.Write(e.beat, (int)PowerCalligraphy.CharacterType.sun); },
|
||||
parameters = new List<Param>()
|
||||
{
|
||||
new Param("prepare", false, "Force Prepare", "Toggle if the cue should be prepared."),
|
||||
},
|
||||
defaultLength = 8f,
|
||||
},
|
||||
new GameAction("kokoro", "Kokoro (心)")
|
||||
{
|
||||
preFunction = delegate {var e = eventCaller.currentEntity; PowerCalligraphy.instance.QueuePaper(e.beat, (int)PowerCalligraphy.CharacterType.kokoro, e["prepare"]); },
|
||||
preFunction = delegate {var e = eventCaller.currentEntity; PowerCalligraphy.instance.QueuePaper(e.beat, (int)PowerCalligraphy.CharacterType.kokoro); },
|
||||
function = delegate {var e = eventCaller.currentEntity; PowerCalligraphy.instance.Write(e.beat, (int)PowerCalligraphy.CharacterType.kokoro); },
|
||||
parameters = new List<Param>()
|
||||
{
|
||||
new Param("prepare", false, "Force Prepare", "Toggle if the cue should be prepared."),
|
||||
},
|
||||
defaultLength = 8f,
|
||||
},
|
||||
new GameAction("face", "Face (つるニハ○○ムし)")
|
||||
{
|
||||
preFunction = delegate {var e = eventCaller.currentEntity; PowerCalligraphy.instance.QueuePaper(e.beat,
|
||||
e["korean"] ? (int)PowerCalligraphy.CharacterType.face_kr : (int)PowerCalligraphy.CharacterType.face, e["prepare"]); },
|
||||
e["korean"] ? (int)PowerCalligraphy.CharacterType.face_kr : (int)PowerCalligraphy.CharacterType.face); },
|
||||
function = delegate {var e = eventCaller.currentEntity; PowerCalligraphy.instance.Write(e.beat,
|
||||
e["korean"] ? (int)PowerCalligraphy.CharacterType.face_kr : (int)PowerCalligraphy.CharacterType.face); },
|
||||
parameters = new List<Param>()
|
||||
{
|
||||
new Param("korean", false, "Korean Version", "Change the character to Korean version. (つ3ニハ○○ムし)"),
|
||||
new Param("prepare", false, "Force Prepare", "Toggle if the cue should be prepared."),
|
||||
},
|
||||
defaultLength = 12f,
|
||||
},
|
||||
@ -119,14 +94,20 @@ namespace HeavenStudio.Games
|
||||
using Scripts_PowerCalligraphy;
|
||||
public class PowerCalligraphy : Minigame
|
||||
{
|
||||
[Header("References")]
|
||||
[SerializeField] List<GameObject> basePapers = new List<GameObject>();
|
||||
[SerializeField] List<RuntimeAnimatorController> fudePosCntls = new List<RuntimeAnimatorController>();
|
||||
public Transform paperHolder;
|
||||
public Writing endPaper;
|
||||
public Animator endPaper;
|
||||
|
||||
public Animator fudePosAnim;
|
||||
public Animator fudeAnim;
|
||||
|
||||
public static int queuedType;
|
||||
|
||||
[Header("Variables")]
|
||||
public Vector3 scrollSpeed = new Vector3();
|
||||
|
||||
public static Nullable<QueuedPaper> queuedPaper = null;
|
||||
|
||||
public enum CharacterType
|
||||
{
|
||||
re,
|
||||
@ -139,12 +120,8 @@ namespace HeavenStudio.Games
|
||||
face_kr,
|
||||
NONE,
|
||||
}
|
||||
public struct QueuedPaper
|
||||
{
|
||||
public double beat;
|
||||
public int type;
|
||||
}
|
||||
|
||||
double gameStartBeat;
|
||||
public static PowerCalligraphy instance = null;
|
||||
|
||||
// Start is called before the first frame update
|
||||
@ -152,23 +129,36 @@ namespace HeavenStudio.Games
|
||||
{
|
||||
instance = this;
|
||||
}
|
||||
public override void OnGameSwitch(double beat)
|
||||
{
|
||||
gameStartBeat = beat;
|
||||
NextPrepare(beat);
|
||||
}
|
||||
public override void OnPlay(double beat)
|
||||
{
|
||||
OnGameSwitch(beat);
|
||||
}
|
||||
|
||||
Writing nowPaper;
|
||||
bool isPrepare = false;
|
||||
void Update()
|
||||
{
|
||||
var cond = Conductor.instance;
|
||||
if (!cond.isPlaying || cond.isPaused) return;
|
||||
|
||||
if (queuedPaper is not null)
|
||||
if (!cond.isPlaying || cond.isPaused)
|
||||
{
|
||||
Prepare(queuedPaper.Value.beat, queuedPaper.Value.type);
|
||||
queuedPaper = null;
|
||||
if (!cond.isPaused) queuedType = (int)CharacterType.NONE;
|
||||
return;
|
||||
}
|
||||
|
||||
if (queuedType != (int)CharacterType.NONE)
|
||||
{
|
||||
Prepare(queuedType);
|
||||
queuedType = (int)CharacterType.NONE;
|
||||
}
|
||||
|
||||
if (PlayerInput.GetIsAction(InputAction_BasicPress) && !IsExpectingInputNow(InputAction_BasicPress))
|
||||
{
|
||||
if (nowPaper.onGoing && nowPaper.Stroke == 0)
|
||||
if (nowPaper.onGoing && nowPaper.Stroke == 1)
|
||||
{
|
||||
nowPaper.ProcessInput("fast");
|
||||
ScoreMiss();
|
||||
@ -176,7 +166,7 @@ namespace HeavenStudio.Games
|
||||
}
|
||||
if (PlayerInput.GetIsAction(InputAction_FlickPress) && !IsExpectingInputNow(InputAction_FlickPress))
|
||||
{
|
||||
if (nowPaper.onGoing && nowPaper.Stroke != 0)
|
||||
if (nowPaper.onGoing && nowPaper.Stroke != 1)
|
||||
{
|
||||
nowPaper.ProcessInput("fast");
|
||||
ScoreMiss();
|
||||
@ -184,43 +174,76 @@ namespace HeavenStudio.Games
|
||||
}
|
||||
}
|
||||
|
||||
private void SpawnPaper(double beat, int type)
|
||||
private void SpawnPaper(int type)
|
||||
{
|
||||
nowPaper = Instantiate(basePapers[type], paperHolder).GetComponent<Writing>();
|
||||
nowPaper.targetBeat = beat;
|
||||
nowPaper.scrollSpeed = scrollSpeed;
|
||||
nowPaper.gameObject.SetActive(true);
|
||||
nowPaper.Init();
|
||||
fudePosAnim.runtimeAnimatorController = fudePosCntls[type];
|
||||
}
|
||||
|
||||
public void Write(double beat, int type)
|
||||
{
|
||||
if (!isPrepare) Prepare(beat, type);
|
||||
Prepare(type);
|
||||
nowPaper.startBeat = beat;
|
||||
nowPaper.Play();
|
||||
isPrepare=false;
|
||||
double nextBeat = beat + nowPaper.nextBeat;
|
||||
BeatAction.New(instance, new List<BeatAction.Action>(){
|
||||
new BeatAction.Action(nextBeat, delegate{ NextPrepare(nextBeat);})
|
||||
});
|
||||
}
|
||||
|
||||
public void QueuePaper(double beat, int type, bool prepare)
|
||||
public void QueuePaper(double beat, int type)
|
||||
{
|
||||
if (GameManager.instance.currentGame != "powerCalligraphy" || prepare)
|
||||
if (GameManager.instance.currentGame != "powerCalligraphy")
|
||||
{
|
||||
queuedPaper = new QueuedPaper()
|
||||
{
|
||||
beat = beat,
|
||||
type = type,
|
||||
};
|
||||
queuedType = type;
|
||||
}
|
||||
else if(Conductor.instance.songPositionInBeats < beat)
|
||||
{
|
||||
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)
|
||||
{
|
||||
SpawnPaper(beat, type);
|
||||
isPrepare = true;
|
||||
if (!isPrepare)
|
||||
{
|
||||
SpawnPaper(type);
|
||||
isPrepare = true;
|
||||
}
|
||||
}
|
||||
public void NextPrepare(double beat) // Prepare next paper
|
||||
{
|
||||
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)
|
||||
@ -231,7 +254,9 @@ namespace HeavenStudio.Games
|
||||
|
||||
public void TheEnd()
|
||||
{
|
||||
endPaper.TheEnd();
|
||||
fudePosAnim.runtimeAnimatorController = fudePosCntls[(int)CharacterType.NONE];
|
||||
fudePosAnim.Play("fudePos-end");
|
||||
endPaper.Play("paper-end");
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user