Trick on the Class: update 2mo old code

This commit is contained in:
minenice55 2022-06-19 22:29:21 -04:00
parent 5735de548d
commit 3a9af801ec
3 changed files with 79 additions and 86 deletions

View file

@ -891,7 +891,7 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3418795074043480354}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -3.51, y: -7.09, z: -4.6045647}
m_LocalPosition: {x: -4.1600003, y: -7.09, z: -4.6045647}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 2005696115261101270}
@ -1758,6 +1758,9 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: c32cb0e1f34c12c4f9440880fee8ff29, type: 3}
m_Name:
m_EditorClassIdentifier:
EligibleHits: []
scheduledInputs: []
firstEnable: 0
ballPrefab: {fileID: 7208854294000353610}
planePrefab: {fileID: 6092229326248261130}
shockPrefab: {fileID: 7208854294000353610}
@ -1984,7 +1987,7 @@ Transform:
m_GameObject: {fileID: 7310611812045732801}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: -1.4372144, y: -0.0925674, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_LocalScale: {x: 1, y: 1, z: 1.25}
m_Children:
- {fileID: 1420343226113066666}
- {fileID: 1376113234299623101}
@ -2017,7 +2020,7 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7716535561277334307}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 7.69, y: 3.3324628, z: -2.448287}
m_LocalPosition: {x: 7.04, y: 3.3324628, z: -2.448287}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 2005696115261101270}

View file

@ -12,8 +12,6 @@ namespace HeavenStudio.Games.Scripts_TrickClass
{
public bool flyType;
public float startBeat;
bool flying = true;
bool dodged = false;
bool miss = false;
float flyBeats;
@ -21,6 +19,7 @@ namespace HeavenStudio.Games.Scripts_TrickClass
public int type;
[NonSerialized] public BezierCurve3D curve;
PlayerActionEvent hitProg;
private TrickClass game;
@ -34,98 +33,52 @@ namespace HeavenStudio.Games.Scripts_TrickClass
float flyPos = cond.GetPositionFromBeat(startBeat, flyBeats);
transform.position = curve.GetPoint(flyPos);
hitProg = game.ScheduleInput(startBeat, dodgeBeats, InputType.STANDARD_ALT_DOWN, DodgeJustOrNg, DodgeMiss, DodgeThrough);
}
// Update is called once per frame
void Update()
{
if (flying)
var cond = Conductor.instance;
float flyPos = cond.GetPositionFromBeat(startBeat, flyBeats);
if (flyPos <= 1f)
{
var cond = Conductor.instance;
float flyPos = cond.GetPositionFromBeat(startBeat, flyBeats);
if (flyPos <= 1f)
if (!miss)
{
if (!miss)
{
flyPos *= 0.9f;
}
Vector3 lastPos = transform.position;
Vector3 nextPos = curve.GetPoint(flyPos);
flyPos *= 0.9f;
}
Vector3 lastPos = transform.position;
Vector3 nextPos = curve.GetPoint(flyPos);
if (flyType)
{
Vector3 direction = (nextPos - lastPos).normalized;
float rotation = Mathf.Atan2(direction.y, direction.x) * Mathf.Rad2Deg;
this.transform.eulerAngles = new Vector3(0, 0, rotation);
}
else
{
transform.rotation = Quaternion.Euler(0, 0, transform.rotation.eulerAngles.z + (360f * Time.deltaTime));
}
transform.position = nextPos;
if (flyType)
{
Vector3 direction = (nextPos - lastPos).normalized;
float rotation = Mathf.Atan2(direction.y, direction.x) * Mathf.Rad2Deg;
this.transform.eulerAngles = new Vector3(0, 0, rotation);
}
else
{
transform.position = curve.GetPoint(1f);
transform.rotation = Quaternion.Euler(0, 0, transform.rotation.eulerAngles.z + (360f * Time.deltaTime));
}
if (flyPos > 1f)
{
if (Conductor.instance.GetPositionFromBeat(startBeat, flyBeats + 1f) >= 1f)
{
GameObject.Destroy(gameObject);
return;
}
}
transform.position = nextPos;
}
else
{
transform.position = curve.GetPoint(miss ? 1f : 0.9f);
}
if (!(dodged || miss))
if (flyPos > 1f)
{
if (Conductor.instance.GetPositionFromBeat(startBeat, flyBeats + 1f) >= 1f)
{
float normalizedBeat = cond.GetPositionFromMargin(startBeat + dodgeBeats, 1f);
StateCheck(normalizedBeat);
if (PlayerInput.Pressed())
{
if (state.perfect)
{
dodged = true;
MultiSound.Play(new MultiSound.Sound[] {
new MultiSound.Sound("trickClass/ball_impact", startBeat + flyBeats, volume: 0.75f),
});
}
}
// no input?
if (Conductor.instance.GetPositionFromBeat(startBeat, dodgeBeats) >= Minigame.EndTime())
{
Jukebox.PlayOneShotGame(GetDodgeSound());
miss = true;
switch (type)
{
case (int) TrickClass.TrickObjType.Plane:
curve = TrickClass.instance.planeMissCurve;
flyBeats = 4f;
break;
default:
curve = TrickClass.instance.ballMissCurve;
flyBeats = 1.25f;
break;
}
startBeat += dodgeBeats;
}
GameObject.Destroy(gameObject);
return;
}
}
}
public override void OnAce()
{
TrickClass.instance.PlayerDodge();
dodged = true;
MultiSound.Play(new MultiSound.Sound[] {
new MultiSound.Sound(GetDodgeSound(), startBeat + flyBeats, volume: 0.5f),
});
}
public string GetDodgeSound()
{
switch (type)
@ -134,5 +87,45 @@ namespace HeavenStudio.Games.Scripts_TrickClass
return "trickClass/ball_impact";
}
}
public void DodgeJustOrNg(PlayerActionEvent caller, float state)
{
if (state <= -1f || state >= 1f)
{
//NG
game.PlayerDodge();
MultiSound.Play(new MultiSound.Sound[] {
new MultiSound.Sound("trickClass/ball_impact", startBeat + flyBeats, volume: 0.75f),
});
}
else
{
//just
game.PlayerDodge();
MultiSound.Play(new MultiSound.Sound[] {
new MultiSound.Sound("trickClass/ball_impact", startBeat + flyBeats, volume: 0.75f),
});
}
}
public void DodgeMiss(PlayerActionEvent caller)
{
Jukebox.PlayOneShotGame(GetDodgeSound());
miss = true;
switch (type)
{
case (int) TrickClass.TrickObjType.Plane:
curve = game.planeMissCurve;
flyBeats = 4f;
break;
default:
curve = game.ballMissCurve;
flyBeats = 1.25f;
break;
}
startBeat += dodgeBeats;
}
public void DodgeThrough(PlayerActionEvent caller) {}
}
}

View file

@ -12,9 +12,8 @@ namespace HeavenStudio.Games.Loaders
public static class MobTrickLoader
{
public static Minigame AddGame(EventCaller eventCaller) {
return new Minigame("trickClass", "Trick on the Class\n<color=#eb5454>[WIP don't use]</color>", "C0171D", false, false, new List<GameAction>()
return new Minigame("trickClass", "Trick on the Class\n<color=#eb5454>[WIP]</color>", "C0171D", false, false, new List<GameAction>()
{
new GameAction("bop", delegate { var e = eventCaller.currentEntity; TrickClass.instance.Bop(e.beat, e.length); }, 1, true),
new GameAction("toss", delegate
{
TrickClass.instance.TossObject(eventCaller.currentEntity.beat, eventCaller.currentEntity.type);
@ -22,6 +21,7 @@ namespace HeavenStudio.Games.Loaders
{
new Param("type", TrickClass.TrickObjType.Ball, "Object", "The object to toss")
}),
new GameAction("bop", delegate { var e = eventCaller.currentEntity; TrickClass.instance.Bop(e.beat, e.length); }, 1, true, hidden: true),
});
}
}
@ -34,7 +34,7 @@ namespace HeavenStudio.Games
**/
using Scripts_TrickClass;
public class TrickClass : MonoBehaviour
public class TrickClass : Minigame
{
public enum TrickObjType {
Plane,
@ -70,13 +70,10 @@ namespace HeavenStudio.Games
var cond = Conductor.instance;
if (cond.ReportBeat(ref bop.lastReportedBeat, bop.startBeat % 1))
{
if (cond.songPositionInBeats >= bop.startBeat && cond.songPositionInBeats < bop.startBeat + bop.length)
{
//TODO: bop animation
}
//TODO: bop animation
}
if (PlayerInput.Pressed())
if (PlayerInput.Pressed() && !IsExpectingInputNow())
{
PlayerDodge();
}