mirror of
https://github.com/RHeavenStudio/HeavenStudio.git
synced 2025-06-13 11:57:37 +02:00
Trick on the Class Overhaul (#619)
* totc internal systems rework add chair, shock * shock near miss * phone * start optic blast switch phone variant * optic blast chrono sorting takes mobile into account
This commit is contained in:
@ -10,29 +10,39 @@ namespace HeavenStudio.Games.Scripts_TrickClass
|
||||
{
|
||||
public class MobTrickObj : MonoBehaviour
|
||||
{
|
||||
public bool flyType;
|
||||
public double startBeat;
|
||||
[NonSerialized] public double startBeat;
|
||||
bool miss = false;
|
||||
|
||||
float flyBeats;
|
||||
float dodgeBeats;
|
||||
public int type;
|
||||
[SerializeField] public byte flyType;
|
||||
[SerializeField] float flyBeats;
|
||||
[SerializeField] float dodgeBeats;
|
||||
[SerializeField] float gravity;
|
||||
[SerializeField] int hitLayer;
|
||||
[SerializeField] TrickClass.TrickObjType type;
|
||||
[SerializeField] string justSound;
|
||||
[SerializeField] string missSound;
|
||||
[SerializeField] SpriteRenderer spriteRenderer;
|
||||
|
||||
[NonSerialized] public BezierCurve3D curve;
|
||||
|
||||
private TrickClass game;
|
||||
private float grav;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
game = TrickClass.instance;
|
||||
flyBeats = flyType ? 4f : 2f;
|
||||
dodgeBeats = flyType ? 2f : 1f;
|
||||
|
||||
var cond = Conductor.instance;
|
||||
|
||||
float flyPos = cond.GetPositionFromBeat(startBeat, flyBeats);
|
||||
transform.position = curve.GetPoint(flyPos);
|
||||
game.ScheduleInput(startBeat, dodgeBeats, TrickClass.InputAction_FlickPress, DodgeJustOrNg, DodgeMiss, DodgeThrough, CanDodge);
|
||||
|
||||
if (type is not TrickClass.TrickObjType.Shock or TrickClass.TrickObjType.Plane)
|
||||
{
|
||||
transform.eulerAngles = new Vector3(0, 0, UnityEngine.Random.Range(0f, 360f));
|
||||
}
|
||||
Update();
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
@ -41,58 +51,72 @@ namespace HeavenStudio.Games.Scripts_TrickClass
|
||||
var cond = Conductor.instance;
|
||||
float flyPos = cond.GetPositionFromBeat(startBeat, flyBeats);
|
||||
|
||||
if (flyPos <= 1f)
|
||||
if (curve == null)
|
||||
{
|
||||
if (!miss)
|
||||
{
|
||||
flyPos *= 0.95f;
|
||||
}
|
||||
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;
|
||||
grav += gravity * Time.deltaTime * cond.SongPitch;
|
||||
transform.position += new Vector3(0, -grav * Time.deltaTime * cond.SongPitch, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
transform.position = curve.GetPoint(miss ? 1f : 0.95f);
|
||||
if (flyPos <= 1f)
|
||||
{
|
||||
if (!miss)
|
||||
{
|
||||
flyPos *= 0.95f;
|
||||
}
|
||||
Vector3 lastPos = transform.position;
|
||||
Vector3 nextPos = curve.GetPoint(flyPos);
|
||||
|
||||
switch (flyType)
|
||||
{
|
||||
case 1:
|
||||
Vector3 direction = (nextPos - lastPos).normalized;
|
||||
float rotation = Mathf.Atan2(direction.y, direction.x) * Mathf.Rad2Deg;
|
||||
transform.eulerAngles = new Vector3(0, 0, rotation);
|
||||
break;
|
||||
case 2:
|
||||
transform.rotation = Quaternion.identity;
|
||||
break;
|
||||
default:
|
||||
transform.eulerAngles = new Vector3(0, 0, transform.rotation.eulerAngles.z + (360f * Time.deltaTime * cond.SongPitch));
|
||||
break;
|
||||
}
|
||||
|
||||
transform.position = nextPos;
|
||||
}
|
||||
else
|
||||
{
|
||||
transform.position = curve.GetPoint(miss ? 1f : 0.95f);
|
||||
}
|
||||
}
|
||||
|
||||
if (flyPos > 1f)
|
||||
{
|
||||
if (Conductor.instance.GetPositionFromBeat(startBeat, flyBeats + 1f) >= 1f)
|
||||
{
|
||||
GameObject.Destroy(gameObject);
|
||||
Destroy(gameObject);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string GetDodgeSound()
|
||||
public string GetMissSound()
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
default:
|
||||
return "trickClass/ball_impact";
|
||||
}
|
||||
return $"trickClass/{missSound}";
|
||||
}
|
||||
|
||||
public void DoObjMiss()
|
||||
public string GetJustSound()
|
||||
{
|
||||
return $"trickClass/{justSound}";
|
||||
}
|
||||
|
||||
public void DoObjMiss(bool ng = false)
|
||||
{
|
||||
miss = true;
|
||||
switch (type)
|
||||
{
|
||||
case (int) TrickClass.TrickObjType.Plane:
|
||||
case TrickClass.TrickObjType.Plane:
|
||||
startBeat += dodgeBeats;
|
||||
curve = game.planeMissCurve;
|
||||
flyBeats = 4f;
|
||||
|
||||
@ -104,12 +128,15 @@ namespace HeavenStudio.Games.Scripts_TrickClass
|
||||
|
||||
transform.position = nextPos;
|
||||
break;
|
||||
case TrickClass.TrickObjType.Shock:
|
||||
Destroy(gameObject);
|
||||
break;
|
||||
default:
|
||||
startBeat += dodgeBeats;
|
||||
curve = game.ballMissCurve;
|
||||
flyBeats = 1.25f;
|
||||
break;
|
||||
}
|
||||
startBeat += dodgeBeats;
|
||||
}
|
||||
|
||||
public bool CanDodge()
|
||||
@ -122,32 +149,46 @@ namespace HeavenStudio.Games.Scripts_TrickClass
|
||||
if (state <= -1f || state >= 1f)
|
||||
{
|
||||
//NG
|
||||
game.PlayerDodgeNg();
|
||||
MultiSound.Play(new MultiSound.Sound[] {
|
||||
new MultiSound.Sound(GetDodgeSound(), startBeat + flyBeats, volume: 0.4f),
|
||||
});
|
||||
SoundByte.PlayOneShotGame(GetDodgeSound(), volume: 0.6f);
|
||||
game.PlayerDodgeNg(type is TrickClass.TrickObjType.Shock);
|
||||
if (type is not TrickClass.TrickObjType.Shock)
|
||||
{
|
||||
MultiSound.Play(new MultiSound.Sound[] {
|
||||
new MultiSound.Sound(GetMissSound(), startBeat + flyBeats, volume: 0.4f),
|
||||
});
|
||||
}
|
||||
SoundByte.PlayOneShotGame(GetMissSound(), volume: 0.6f);
|
||||
SoundByte.PlayOneShot("miss");
|
||||
DoObjMiss();
|
||||
DoObjMiss(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
//just
|
||||
game.PlayerDodge();
|
||||
SoundByte.PlayOneShotGame("trickClass/player_dodge_success", volume: 0.8f, pitch: UnityEngine.Random.Range(0.85f, 1.15f));
|
||||
MultiSound.Play(new MultiSound.Sound[] {
|
||||
new MultiSound.Sound(GetDodgeSound(), startBeat + flyBeats, volume: 0.4f),
|
||||
bool phone = type is TrickClass.TrickObjType.Phone;
|
||||
game.PlayerDodge(phone, phone);
|
||||
SoundByte.PlayOneShotGame(GetJustSound(), volume: 0.8f, pitch: UnityEngine.Random.Range(0.85f, 1.15f));
|
||||
MultiSound.Play(new MultiSound.Sound[] {
|
||||
new MultiSound.Sound(GetMissSound(), startBeat + flyBeats, volume: 0.4f),
|
||||
});
|
||||
|
||||
if (phone)
|
||||
{
|
||||
transform.position = curve.GetPoint(0.5f);
|
||||
curve = null;
|
||||
grav = 0f;
|
||||
startBeat = Conductor.instance.songPositionInBeatsAsDouble;
|
||||
flyBeats = 1f;
|
||||
spriteRenderer.sortingOrder = hitLayer;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void DodgeMiss(PlayerActionEvent caller)
|
||||
{
|
||||
SoundByte.PlayOneShotGame(GetDodgeSound());
|
||||
DoObjMiss();
|
||||
game.PlayerThrough();
|
||||
SoundByte.PlayOneShotGame(GetMissSound());
|
||||
DoObjMiss(false);
|
||||
game.PlayerThrough(type is TrickClass.TrickObjType.Shock);
|
||||
}
|
||||
|
||||
public void DodgeThrough(PlayerActionEvent caller) {}
|
||||
public void DodgeThrough(PlayerActionEvent caller) { }
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user