mirror of
https://github.com/RHeavenStudioPlus/HeavenStudioPlus.git
synced 2024-11-10 11:45:09 +00:00
Refactored Space Soccer scripts
most of the refactoring is in the ball script, and the changes for the kicker and space soccer scripts are mostly in response to the refactoring.
This commit is contained in:
parent
fd748e8309
commit
40dbb70bb5
6 changed files with 245 additions and 238 deletions
|
@ -1386,9 +1386,9 @@ MonoBehaviour:
|
|||
perfect: 0
|
||||
late: 0
|
||||
createBeat: 0
|
||||
isEligible: 0
|
||||
eligibleHitsList: []
|
||||
aceTimes: 0
|
||||
isEligible: 0
|
||||
canKick: 0
|
||||
canHighKick: 0
|
||||
kickLeft: 0
|
||||
|
@ -2004,7 +2004,7 @@ GameObject:
|
|||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
m_IsActive: 0
|
||||
--- !u!4 &6448989353494316845
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
|
@ -2044,9 +2044,10 @@ MonoBehaviour:
|
|||
kickCurve: {fileID: 1507665286932590801}
|
||||
highKickCurve: {fileID: 5471456891558289981}
|
||||
toeCurve: {fileID: 8336007186072323660}
|
||||
dispensedBeat: 0
|
||||
dispensing: 0
|
||||
hitTimes: 0
|
||||
startBeat: 0
|
||||
state: 0
|
||||
nextAnimBeat: 0
|
||||
highKickSwing: 0
|
||||
canKick: 0
|
||||
--- !u!1 &4365805729759623217
|
||||
GameObject:
|
||||
|
@ -3886,9 +3887,9 @@ MonoBehaviour:
|
|||
perfect: 0
|
||||
late: 0
|
||||
createBeat: 0
|
||||
isEligible: 0
|
||||
eligibleHitsList: []
|
||||
aceTimes: 0
|
||||
isEligible: 0
|
||||
canKick: 0
|
||||
canHighKick: 0
|
||||
kickLeft: 0
|
||||
|
|
|
@ -11,13 +11,13 @@ namespace RhythmHeavenMania.Games
|
|||
public bool inList = false;
|
||||
public int lastState;
|
||||
public Minigame.Eligible state = new Minigame.Eligible();
|
||||
public bool isEligible;
|
||||
|
||||
public List<Minigame.Eligible> eligibleHitsList = new List<Minigame.Eligible>();
|
||||
|
||||
public int aceTimes;
|
||||
|
||||
private bool autoPlayEnabledOnStart;
|
||||
//the variables below seem to be mostly unused (they are never used in any meaningful way)
|
||||
public int aceTimes; //always set to 0 no matter what (also, the one time it's used doesn't seem to make sense)
|
||||
public bool isEligible; //value never used for anything
|
||||
private bool autoPlayEnabledOnStart; //value never used for anything
|
||||
|
||||
public void PlayerActionInit(GameObject g, float createBeat)
|
||||
{
|
||||
|
@ -31,7 +31,7 @@ namespace RhythmHeavenMania.Games
|
|||
{
|
||||
if (aceTimes == 0)
|
||||
{
|
||||
if (GameManager.instance.autoplay && normalizedBeat > 0.99f || autoPlay && normalizedBeat > 0.99f)
|
||||
if ((GameManager.instance.autoplay || autoPlay) && normalizedBeat > 0.99f)
|
||||
{
|
||||
OnAce();
|
||||
if (!autoPlay)
|
||||
|
|
|
@ -9,6 +9,7 @@ namespace RhythmHeavenMania.Games.SpaceSoccer
|
|||
{
|
||||
public class Ball : MonoBehaviour
|
||||
{
|
||||
public enum State { Dispensing, Kicked, HighKicked, Toe };
|
||||
[Header("Components")]
|
||||
[HideInInspector] public Kicker kicker;
|
||||
[SerializeField] private GameObject holder;
|
||||
|
@ -21,19 +22,37 @@ namespace RhythmHeavenMania.Games.SpaceSoccer
|
|||
[SerializeField] private BezierCurve3D toeCurve;
|
||||
|
||||
[Header("Properties")]
|
||||
public float dispensedBeat = 0;
|
||||
public bool dispensing;
|
||||
public float hitTimes;
|
||||
public float startBeat;
|
||||
public State state;
|
||||
public float nextAnimBeat;
|
||||
public float highKickSwing = 0f;
|
||||
private float lastSpriteRot;
|
||||
public bool canKick;
|
||||
public GameEvent kicked = new GameEvent();
|
||||
public GameEvent highKicked = new GameEvent();
|
||||
public GameEvent toe = new GameEvent();
|
||||
private bool lastKickLeft;
|
||||
|
||||
private void Start()
|
||||
public void Init(Kicker kicker, float dispensedBeat)
|
||||
{
|
||||
this.kicker = kicker;
|
||||
kicker.ball = this;
|
||||
kicker.dispenserBeat = dispensedBeat;
|
||||
state = State.Dispensing;
|
||||
startBeat = dispensedBeat;
|
||||
kicker.kickTimes = 0;
|
||||
if (kicker.player)
|
||||
{
|
||||
MultiSound.Play(new MultiSound.Sound[]
|
||||
{
|
||||
new MultiSound.Sound("spaceSoccer/dispenseNoise", dispensedBeat),
|
||||
new MultiSound.Sound("spaceSoccer/dispenseTumble1", dispensedBeat + 0.25f),
|
||||
new MultiSound.Sound("spaceSoccer/dispenseTumble2", dispensedBeat + 0.5f),
|
||||
new MultiSound.Sound("spaceSoccer/dispenseTumble2B",dispensedBeat + 0.5f),
|
||||
new MultiSound.Sound("spaceSoccer/dispenseTumble3", dispensedBeat + 0.75f),
|
||||
new MultiSound.Sound("spaceSoccer/dispenseTumble4", dispensedBeat + 1f),
|
||||
new MultiSound.Sound("spaceSoccer/dispenseTumble5", dispensedBeat + 1.25f),
|
||||
new MultiSound.Sound("spaceSoccer/dispenseTumble6", dispensedBeat + 1.5f),
|
||||
new MultiSound.Sound("spaceSoccer/dispenseTumble6B",dispensedBeat + 1.75f),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public void Kick(bool player)
|
||||
|
@ -43,12 +62,7 @@ namespace RhythmHeavenMania.Games.SpaceSoccer
|
|||
|
||||
lastSpriteRot = spriteHolder.transform.eulerAngles.z;
|
||||
|
||||
dispensing = false;
|
||||
kicked.enabled = true;
|
||||
// kicked.startBeat = Conductor.instance.songPositionInBeats;
|
||||
kicked.startBeat = dispensedBeat + 2 + hitTimes;
|
||||
|
||||
hitTimes++;
|
||||
SetState(State.Kicked);
|
||||
|
||||
lastKickLeft = kicker.kickLeft;
|
||||
|
||||
|
@ -67,14 +81,9 @@ namespace RhythmHeavenMania.Games.SpaceSoccer
|
|||
|
||||
public void HighKick()
|
||||
{
|
||||
hitTimes += GetHighKickLength(false);
|
||||
|
||||
lastSpriteRot = spriteHolder.transform.eulerAngles.z;
|
||||
|
||||
dispensing = false;
|
||||
kicked.enabled = false;
|
||||
highKicked.enabled = true;
|
||||
highKicked.startBeat = Conductor.instance.songPositionInBeats;
|
||||
SetState(State.HighKicked);
|
||||
|
||||
highKickCurve.KeyPoints[0].transform.position = holder.transform.position;
|
||||
|
||||
|
@ -84,15 +93,10 @@ namespace RhythmHeavenMania.Games.SpaceSoccer
|
|||
|
||||
public void Toe()
|
||||
{
|
||||
hitTimes += GetHighKickLength(true);
|
||||
|
||||
lastSpriteRot = spriteHolder.transform.eulerAngles.z;
|
||||
|
||||
highKicked.enabled = false;
|
||||
kicked.enabled = false;
|
||||
|
||||
toe.enabled = true;
|
||||
toe.startBeat = Conductor.instance.songPositionInBeats;
|
||||
SetState(State.Toe);
|
||||
|
||||
toeCurve.KeyPoints[0].transform.position = holder.transform.position;
|
||||
if (lastKickLeft)
|
||||
|
@ -110,9 +114,11 @@ namespace RhythmHeavenMania.Games.SpaceSoccer
|
|||
|
||||
private void Update()
|
||||
{
|
||||
if (dispensing)
|
||||
switch (state)
|
||||
{
|
||||
float normalizedBeatAnim = Conductor.instance.GetPositionFromBeat(dispensedBeat, 2.35f);
|
||||
case State.Dispensing:
|
||||
{
|
||||
float normalizedBeatAnim = Conductor.instance.GetPositionFromBeat(startBeat, 2.35f);
|
||||
|
||||
dispenseCurve.KeyPoints[0].transform.position = new Vector3(kicker.transform.position.x - 6f, kicker.transform.position.y - 6f);
|
||||
dispenseCurve.KeyPoints[1].transform.position = new Vector3(kicker.transform.position.x - 1f, kicker.transform.position.y - 6f);
|
||||
|
@ -127,10 +133,11 @@ namespace RhythmHeavenMania.Games.SpaceSoccer
|
|||
Kick();
|
||||
}
|
||||
}*/
|
||||
break;
|
||||
}
|
||||
else if (kicked.enabled)
|
||||
case State.Kicked:
|
||||
{
|
||||
float normalizedBeatAnim = Conductor.instance.GetPositionFromBeat(kicked.startBeat, 1.5f);
|
||||
float normalizedBeatAnim = Conductor.instance.GetPositionFromBeat(startBeat, 1.5f);
|
||||
|
||||
if (!lastKickLeft)
|
||||
{
|
||||
|
@ -160,10 +167,11 @@ namespace RhythmHeavenMania.Games.SpaceSoccer
|
|||
// print(normalizedBeat);
|
||||
}
|
||||
}*/
|
||||
break;
|
||||
}
|
||||
else if (highKicked.enabled)
|
||||
case State.HighKicked:
|
||||
{
|
||||
float normalizedBeatAnim = Conductor.instance.GetPositionFromBeat(highKicked.startBeat, GetHighKickLength(false) + 0.3f);
|
||||
float normalizedBeatAnim = Conductor.instance.GetPositionFromBeat(startBeat, GetAnimLength(State.HighKicked) + 0.3f);
|
||||
|
||||
highKickCurve.KeyPoints[1].transform.position = new Vector3(kicker.transform.position.x - 3.5f, kicker.transform.position.y - 6f);
|
||||
|
||||
|
@ -187,10 +195,11 @@ namespace RhythmHeavenMania.Games.SpaceSoccer
|
|||
}
|
||||
}
|
||||
}*/
|
||||
break;
|
||||
}
|
||||
else if (toe.enabled)
|
||||
case State.Toe:
|
||||
{
|
||||
float normalizedBeatAnim = Conductor.instance.GetPositionFromBeat(toe.startBeat, GetHighKickLength(true) + 0.35f);
|
||||
float normalizedBeatAnim = Conductor.instance.GetPositionFromBeat(startBeat, GetAnimLength(State.Toe) + 0.35f);
|
||||
|
||||
if (!lastKickLeft)
|
||||
{
|
||||
|
@ -203,6 +212,8 @@ namespace RhythmHeavenMania.Games.SpaceSoccer
|
|||
|
||||
holder.transform.localPosition = toeCurve.GetPoint(normalizedBeatAnim);
|
||||
spriteHolder.transform.eulerAngles = new Vector3(0, 0, Mathf.Lerp(lastSpriteRot, -860f, normalizedBeatAnim));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
holder.transform.position = new Vector3(holder.transform.position.x, holder.transform.position.y, kicker.transform.localPosition.z);
|
||||
|
@ -215,22 +226,28 @@ namespace RhythmHeavenMania.Games.SpaceSoccer
|
|||
kickfx.transform.position = holder.transform.position;
|
||||
}
|
||||
|
||||
public float GetHighKickLength(bool fromToe)
|
||||
private void SetState(State newState)
|
||||
{
|
||||
if (highKickSwing == 0f)
|
||||
{
|
||||
return 1.5f;
|
||||
state = newState;
|
||||
startBeat = nextAnimBeat;
|
||||
nextAnimBeat += GetAnimLength(newState);
|
||||
}
|
||||
else
|
||||
|
||||
public float GetAnimLength(State anim)
|
||||
{
|
||||
if (fromToe)
|
||||
{
|
||||
return 2f - (1f - highKickSwing);
|
||||
}
|
||||
else
|
||||
switch(anim)
|
||||
{
|
||||
case State.Dispensing:
|
||||
return 2f;
|
||||
case State.Kicked:
|
||||
return 1f;
|
||||
case State.HighKicked:
|
||||
return 2f - highKickSwing;
|
||||
}
|
||||
case State.Toe:
|
||||
return 2f - (1f - highKickSwing);
|
||||
default:
|
||||
Debug.LogError("Ball has invalid state. State number: " + (int)anim);
|
||||
return 0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ namespace RhythmHeavenMania.Games.SpaceSoccer
|
|||
public bool canHighKick;
|
||||
private bool kickPrepare = false;
|
||||
public bool kickLeft;
|
||||
public float dispenserBeat;
|
||||
public float dispenserBeat; //unused
|
||||
public int kickTimes = 0;
|
||||
public bool player;
|
||||
|
||||
|
@ -40,7 +40,7 @@ namespace RhythmHeavenMania.Games.SpaceSoccer
|
|||
|
||||
public override void OnAce()
|
||||
{
|
||||
if (ball.highKicked.enabled)
|
||||
if (ball.state == Ball.State.HighKicked)
|
||||
{
|
||||
if (!kickPrepare)
|
||||
{
|
||||
|
@ -83,7 +83,7 @@ namespace RhythmHeavenMania.Games.SpaceSoccer
|
|||
anim.Play("HighKickRight_0", 0, 0);
|
||||
}
|
||||
}
|
||||
else if (!highKick)
|
||||
else
|
||||
{
|
||||
if (kickLeft)
|
||||
{
|
||||
|
@ -214,9 +214,11 @@ namespace RhythmHeavenMania.Games.SpaceSoccer
|
|||
|
||||
if (ball)
|
||||
{
|
||||
if (ball.dispensing)
|
||||
switch (ball.state)
|
||||
{
|
||||
float normalizedBeat = Conductor.instance.GetPositionFromBeat(ball.dispensedBeat, 2f);
|
||||
case Ball.State.Dispensing:
|
||||
{
|
||||
float normalizedBeat = Conductor.instance.GetPositionFromBeat(ball.startBeat, ball.GetAnimLength(Ball.State.Dispensing));
|
||||
StateCheck(normalizedBeat, !player);
|
||||
CheckIfFall(normalizedBeat);
|
||||
|
||||
|
@ -234,10 +236,11 @@ namespace RhythmHeavenMania.Games.SpaceSoccer
|
|||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
else if (ball.kicked.enabled)
|
||||
case Ball.State.Kicked:
|
||||
{
|
||||
float normalizedBeat = Conductor.instance.GetPositionFromBeat(ball.kicked.startBeat, 1f);
|
||||
float normalizedBeat = Conductor.instance.GetPositionFromBeat(ball.startBeat, ball.GetAnimLength(Ball.State.Kicked));
|
||||
StateCheck(normalizedBeat, !player);
|
||||
CheckIfFall(normalizedBeat);
|
||||
|
||||
|
@ -255,13 +258,14 @@ namespace RhythmHeavenMania.Games.SpaceSoccer
|
|||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
else if (ball.highKicked.enabled)
|
||||
case Ball.State.HighKicked:
|
||||
{
|
||||
float normalizedBeat = Conductor.instance.GetPositionFromMargin(ball.highKicked.startBeat + ball.GetHighKickLength(false), 1f);
|
||||
float normalizedBeat = Conductor.instance.GetPositionFromMargin(ball.startBeat + ball.GetAnimLength(Ball.State.HighKicked), 1f);
|
||||
if (!kickPrepare)
|
||||
{
|
||||
float normalizedBeatPrepare = Conductor.instance.GetPositionFromBeat(ball.highKicked.startBeat, 1f);
|
||||
float normalizedBeatPrepare = Conductor.instance.GetPositionFromBeat(ball.startBeat, 1f);
|
||||
StateCheck(normalizedBeatPrepare, !player);
|
||||
CheckIfFall(normalizedBeat);
|
||||
|
||||
|
@ -293,10 +297,11 @@ namespace RhythmHeavenMania.Games.SpaceSoccer
|
|||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
else if (ball.toe.enabled)
|
||||
case Ball.State.Toe:
|
||||
{
|
||||
float normalizedBeat = Conductor.instance.GetPositionFromMargin(ball.toe.startBeat + ball.GetHighKickLength(true), 1f);
|
||||
float normalizedBeat = Conductor.instance.GetPositionFromMargin(ball.startBeat + ball.GetAnimLength(Ball.State.Toe), 1f);
|
||||
StateCheck(normalizedBeat, !player);
|
||||
CheckIfFall(normalizedBeat);
|
||||
|
||||
|
@ -314,6 +319,8 @@ namespace RhythmHeavenMania.Games.SpaceSoccer
|
|||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -326,6 +333,7 @@ namespace RhythmHeavenMania.Games.SpaceSoccer
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void KickCheck(bool hit, bool overrideState = false)
|
||||
|
|
|
@ -42,9 +42,7 @@ namespace RhythmHeavenMania.Games.SpaceSoccer
|
|||
|
||||
private void Update()
|
||||
{
|
||||
if (ballDispensed)
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void Dispense(float beat)
|
||||
|
@ -58,27 +56,10 @@ namespace RhythmHeavenMania.Games.SpaceSoccer
|
|||
ballDispensed = true;
|
||||
|
||||
GameObject ball = Instantiate(ballRef, transform);
|
||||
ball.SetActive(true);
|
||||
Ball ball_ = ball.GetComponent<Ball>();
|
||||
ball_.kicker = kicker;
|
||||
ball_.dispensedBeat = beat;
|
||||
ball_.dispensing = true;
|
||||
kicker.ball = ball_;
|
||||
kicker.dispenserBeat = beat;
|
||||
kicker.kickTimes = 0;
|
||||
ball_.Init(kicker, beat);
|
||||
}
|
||||
|
||||
MultiSound.Play(new MultiSound.Sound[]
|
||||
{
|
||||
new MultiSound.Sound("spaceSoccer/dispenseNoise", beat),
|
||||
new MultiSound.Sound("spaceSoccer/dispenseTumble1", beat + 0.25f),
|
||||
new MultiSound.Sound("spaceSoccer/dispenseTumble2", beat + 0.5f),
|
||||
new MultiSound.Sound("spaceSoccer/dispenseTumble2B",beat + 0.5f),
|
||||
new MultiSound.Sound("spaceSoccer/dispenseTumble3", beat + 0.75f),
|
||||
new MultiSound.Sound("spaceSoccer/dispenseTumble4", beat + 1f),
|
||||
new MultiSound.Sound("spaceSoccer/dispenseTumble5", beat + 1.25f),
|
||||
new MultiSound.Sound("spaceSoccer/dispenseTumble6", beat + 1.5f),
|
||||
new MultiSound.Sound("spaceSoccer/dispenseTumble6B",beat + 1.75f),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -248,7 +248,7 @@ namespace RhythmHeavenMania
|
|||
new GameAction("keep-up", delegate { }, 4f, true),
|
||||
new GameAction("high kick-toe!", delegate { }, 3f, false, new List<Param>()
|
||||
{
|
||||
new Param("swing", new EntityTypes.Float(0, 1), "Swing")
|
||||
new Param("swing", new EntityTypes.Float(0, 1, 0.5f), "Swing")
|
||||
}),
|
||||
}),
|
||||
new Minigame("djSchool", "DJ School", "008c97", false, false, new List<GameAction>()
|
||||
|
|
Loading…
Reference in a new issue