Some clean up

This commit is contained in:
Slaith
2022-02-26 15:38:27 -08:00
parent 52cee6f511
commit 93448a018f
2 changed files with 10 additions and 9 deletions

View File

@ -27,7 +27,7 @@ namespace RhythmHeavenMania.Games.SpaceSoccer
public float nextAnimBeat; public float nextAnimBeat;
public float highKickSwing = 0f; public float highKickSwing = 0f;
private float lastSpriteRot; private float lastSpriteRot;
public bool canKick; public bool canKick; //unused
private bool lastKickLeft; private bool lastKickLeft;
public void Init(Kicker kicker, float dispensedBeat) public void Init(Kicker kicker, float dispensedBeat)
@ -39,7 +39,7 @@ namespace RhythmHeavenMania.Games.SpaceSoccer
if(currentBeat - dispensedBeat < 2f) //check if ball is currently being dispensed (should only be false if starting in the middle of the remix) if(currentBeat - dispensedBeat < 2f) //check if ball is currently being dispensed (should only be false if starting in the middle of the remix)
{ {
Debug.Log("Dispensing"); //Debug.Log("Dispensing");
state = State.Dispensing; state = State.Dispensing;
startBeat = dispensedBeat; startBeat = dispensedBeat;
nextAnimBeat = startBeat + GetAnimLength(State.Dispensing); nextAnimBeat = startBeat + GetAnimLength(State.Dispensing);
@ -74,7 +74,7 @@ namespace RhythmHeavenMania.Games.SpaceSoccer
} }
if (highKicks[i].beat > currentBeat) if (highKicks[i].beat > currentBeat)
{ {
Debug.Log("Setting state to kicked"); //Debug.Log("Setting state to kicked");
state = State.Kicked; state = State.Kicked;
float relativeBeat = currentBeat - dispensedBeat; float relativeBeat = currentBeat - dispensedBeat;
startBeat = dispensedBeat + (int)(relativeBeat - 0.1); //this makes the startBeat be for the kick that is currently in progress, but it won't play the kicker's animation for that kick. the -0.1 makes it so that if playback is started right when the kicker kicks, it still plays the kicker's animation. startBeat = dispensedBeat + (int)(relativeBeat - 0.1); //this makes the startBeat be for the kick that is currently in progress, but it won't play the kicker's animation for that kick. the -0.1 makes it so that if playback is started right when the kicker kicks, it still plays the kicker's animation.
@ -87,7 +87,7 @@ namespace RhythmHeavenMania.Games.SpaceSoccer
highKickSwing = highKicks[i].swing; highKickSwing = highKicks[i].swing;
if (highKicks[i].beat + GetAnimLength(State.HighKicked) > currentBeat) if (highKicks[i].beat + GetAnimLength(State.HighKicked) > currentBeat)
{ {
Debug.Log("Setting state to high kick"); //Debug.Log("Setting state to high kick");
state = State.HighKicked; state = State.HighKicked;
float relativeBeat = highKicks[i].beat - dispensedBeat; float relativeBeat = highKicks[i].beat - dispensedBeat;
startBeat = dispensedBeat + Mathf.Ceil(relativeBeat); //there is a chance this makes startBeat later than the current beat, but it shouldn't matter too much. It would only happen if the user places the high kicks incorrectly. startBeat = dispensedBeat + Mathf.Ceil(relativeBeat); //there is a chance this makes startBeat later than the current beat, but it shouldn't matter too much. It would only happen if the user places the high kicks incorrectly.
@ -97,7 +97,7 @@ namespace RhythmHeavenMania.Games.SpaceSoccer
} }
else else
{ {
Debug.Log("Setting state to toe"); //Debug.Log("Setting state to toe");
state = State.Toe; state = State.Toe;
float relativeBeat = Mathf.Ceil(highKicks[i].beat - dispensedBeat) + GetAnimLength(State.HighKicked); //there is a chance this makes startBeat later than the current beat, but it shouldn't matter too much. It would only happen if the user places the high kicks incorrectly. float relativeBeat = Mathf.Ceil(highKicks[i].beat - dispensedBeat) + GetAnimLength(State.HighKicked); //there is a chance this makes startBeat later than the current beat, but it shouldn't matter too much. It would only happen if the user places the high kicks incorrectly.
startBeat = dispensedBeat + relativeBeat; startBeat = dispensedBeat + relativeBeat;
@ -107,15 +107,16 @@ namespace RhythmHeavenMania.Games.SpaceSoccer
} }
} }
} }
if(state == State.Dispensing) //if the for loop didn't set the state if(state == 0) //if the for loop didn't set the state
{ {
Debug.Log("Defaulting to kicked state"); //Debug.Log("Defaulting to kicked state");
state = State.Kicked; state = State.Kicked;
float relativeBeat = currentBeat - dispensedBeat; float relativeBeat = currentBeat - dispensedBeat;
startBeat = dispensedBeat + (int)(relativeBeat - 0.1); //this makes the startBeat be for the kick that is currently in progress, but it won't play the kicker's animation for that kick. the -0.1 makes it so that if playback is started right when the kicker kicks, it still plays the kicker's animation. startBeat = dispensedBeat + (int)(relativeBeat - 0.1); //this makes the startBeat be for the kick that is currently in progress, but it won't play the kicker's animation for that kick. the -0.1 makes it so that if playback is started right when the kicker kicks, it still plays the kicker's animation.
nextAnimBeat = startBeat + GetAnimLength(State.Kicked); nextAnimBeat = startBeat + GetAnimLength(State.Kicked);
kicker.kickTimes = (int)(relativeBeat - 0.1) - numHighKicks - 1; kicker.kickTimes = (int)(relativeBeat - 0.1) - numHighKicks - 1;
} }
Update(); //make sure the ball is in the right place
} }
public void Kick(bool player) public void Kick(bool player)
@ -177,7 +178,7 @@ namespace RhythmHeavenMania.Games.SpaceSoccer
private void Update() private void Update()
{ {
switch (state) switch (state) //handle animations
{ {
case State.Dispensing: case State.Dispensing:
{ {

View File

@ -15,7 +15,7 @@ namespace RhythmHeavenMania.Games.SpaceSoccer
[SerializeField] private Sprite[] backgroundSprite; [SerializeField] private Sprite[] backgroundSprite;
[Header("Properties")] [Header("Properties")]
[SerializeField] private bool ballDispensed; [SerializeField] private bool ballDispensed; //unused
public static SpaceSoccer instance { get; private set; } public static SpaceSoccer instance { get; private set; }