mirror of
https://github.com/RHeavenStudio/HeavenStudio.git
synced 2025-06-13 11:47:40 +02:00
Trick on the Class: update 2mo old code
This commit is contained in:
@ -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) {}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user