2022-01-24 02:15:23 +00:00
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
using RhythmHeavenMania.Util;
|
|
|
|
|
|
|
|
namespace RhythmHeavenMania.Games.SpaceSoccer
|
|
|
|
{
|
2022-01-25 01:02:45 +00:00
|
|
|
public class Kicker : PlayerActionObject
|
2022-01-24 02:15:23 +00:00
|
|
|
{
|
|
|
|
[Header("Properties")]
|
|
|
|
public bool canKick;
|
|
|
|
public bool canHighKick;
|
2022-01-25 01:02:45 +00:00
|
|
|
private bool kickPrepare = false;
|
|
|
|
public bool kickLeft;
|
2022-02-26 07:27:51 +00:00
|
|
|
public float dispenserBeat; //unused
|
2022-01-25 01:02:45 +00:00
|
|
|
public int kickTimes = 0;
|
2022-02-02 08:36:20 +00:00
|
|
|
public bool player;
|
2022-01-24 02:15:23 +00:00
|
|
|
|
|
|
|
[Header("Components")]
|
|
|
|
private Animator anim;
|
2022-01-25 01:02:45 +00:00
|
|
|
public Ball ball;
|
2022-02-02 08:36:20 +00:00
|
|
|
public Transform rightLeg;
|
|
|
|
public Transform leftLeg;
|
2022-01-24 02:15:23 +00:00
|
|
|
|
|
|
|
private void Start()
|
|
|
|
{
|
|
|
|
anim = GetComponent<Animator>();
|
2022-02-02 08:36:20 +00:00
|
|
|
GameObject rightLeg = new GameObject();
|
|
|
|
rightLeg.transform.SetParent(this.transform);
|
|
|
|
rightLeg.transform.position = new Vector3(-0.67f, -1.48f);
|
|
|
|
|
|
|
|
GameObject leftLeg = new GameObject("leftLeg");
|
|
|
|
leftLeg.transform.SetParent(this.transform);
|
|
|
|
leftLeg.transform.position = new Vector3(0f, -1.48f);
|
|
|
|
|
|
|
|
this.rightLeg = rightLeg.transform;
|
|
|
|
this.leftLeg = leftLeg.transform;
|
2022-01-24 02:15:23 +00:00
|
|
|
}
|
|
|
|
|
2022-01-25 01:02:45 +00:00
|
|
|
public override void OnAce()
|
2022-01-24 02:15:23 +00:00
|
|
|
{
|
2022-02-26 07:27:51 +00:00
|
|
|
if (ball.state == Ball.State.HighKicked)
|
2022-01-25 01:02:45 +00:00
|
|
|
{
|
|
|
|
if (!kickPrepare)
|
|
|
|
{
|
|
|
|
Kick(false, true);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Toe(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (canHighKick)
|
|
|
|
{
|
|
|
|
HighKick(true);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Kick(true);
|
|
|
|
}
|
|
|
|
}
|
2022-01-24 02:15:23 +00:00
|
|
|
}
|
|
|
|
|
2022-01-25 01:02:45 +00:00
|
|
|
public void Kick(bool hit, bool highKick = false)
|
2022-01-24 02:15:23 +00:00
|
|
|
{
|
2022-01-25 01:02:45 +00:00
|
|
|
kickTimes++;
|
2022-01-26 05:38:12 +00:00
|
|
|
aceTimes = 0;
|
2022-01-25 01:02:45 +00:00
|
|
|
|
2022-02-02 08:36:20 +00:00
|
|
|
if (player)
|
|
|
|
Jukebox.PlayOneShotGame("spaceSoccer/kick");
|
2022-02-02 01:11:42 +00:00
|
|
|
|
2022-01-25 03:49:40 +00:00
|
|
|
if (highKick)
|
2022-01-25 01:02:45 +00:00
|
|
|
{
|
2022-01-25 03:49:40 +00:00
|
|
|
if (kickLeft)
|
|
|
|
{
|
|
|
|
anim.Play("HighKickLeft_0", 0, 0);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
anim.Play("HighKickRight_0", 0, 0);
|
|
|
|
}
|
2022-01-25 01:02:45 +00:00
|
|
|
}
|
2022-02-26 07:27:51 +00:00
|
|
|
else
|
2022-01-24 02:15:23 +00:00
|
|
|
{
|
2022-01-25 03:49:40 +00:00
|
|
|
if (kickLeft)
|
|
|
|
{
|
|
|
|
anim.Play("KickLeft", 0, 0);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
anim.Play("KickRight", 0, 0);
|
|
|
|
}
|
2022-01-24 02:15:23 +00:00
|
|
|
}
|
2022-02-02 01:11:42 +00:00
|
|
|
|
|
|
|
if (ball == null) return;
|
|
|
|
|
2022-01-25 01:02:45 +00:00
|
|
|
if (highKick == false)
|
|
|
|
{
|
2022-02-02 01:11:42 +00:00
|
|
|
if (ball != null && hit)
|
2022-02-02 08:36:20 +00:00
|
|
|
ball.Kick(player);
|
2022-01-25 01:02:45 +00:00
|
|
|
}
|
2022-01-24 02:15:23 +00:00
|
|
|
else
|
|
|
|
{
|
2022-01-25 01:02:45 +00:00
|
|
|
kickPrepare = true;
|
2022-01-24 02:15:23 +00:00
|
|
|
}
|
2022-02-02 01:11:42 +00:00
|
|
|
|
2022-01-25 01:02:45 +00:00
|
|
|
ResetState();
|
2022-01-24 02:15:23 +00:00
|
|
|
}
|
|
|
|
|
2022-01-25 01:02:45 +00:00
|
|
|
public void HighKick(bool hit)
|
2022-01-24 02:15:23 +00:00
|
|
|
{
|
2022-01-25 03:49:40 +00:00
|
|
|
kickTimes++;
|
|
|
|
|
2022-02-02 01:11:42 +00:00
|
|
|
if (kickLeft)
|
2022-01-25 01:02:45 +00:00
|
|
|
{
|
2022-02-02 01:11:42 +00:00
|
|
|
anim.Play("HighKickLeft_0", 0, 0);
|
2022-01-25 01:02:45 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-02-02 01:11:42 +00:00
|
|
|
anim.Play("HighKickRight_0", 0, 0);
|
2022-01-25 01:02:45 +00:00
|
|
|
}
|
|
|
|
|
2022-02-02 08:36:20 +00:00
|
|
|
if (hit && ball)
|
2022-01-25 03:49:40 +00:00
|
|
|
{
|
2022-02-02 01:11:42 +00:00
|
|
|
ball.HighKick();
|
2022-02-02 08:36:20 +00:00
|
|
|
|
|
|
|
if (player)
|
|
|
|
Jukebox.PlayOneShotGame("spaceSoccer/highkicktoe1_hit");
|
2022-01-25 03:49:40 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-02-02 08:36:20 +00:00
|
|
|
if (player)
|
|
|
|
Jukebox.PlayOneShotGame("spaceSoccer/highkicktoe1");
|
2022-01-25 03:49:40 +00:00
|
|
|
}
|
|
|
|
|
2022-01-25 01:02:45 +00:00
|
|
|
ResetState();
|
|
|
|
}
|
|
|
|
|
|
|
|
public void Toe(bool hit)
|
|
|
|
{
|
2022-02-02 01:11:42 +00:00
|
|
|
if (kickLeft)
|
2022-01-25 01:02:45 +00:00
|
|
|
{
|
2022-02-02 01:11:42 +00:00
|
|
|
anim.Play("ToeLeft", 0, 0);
|
2022-01-25 01:02:45 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-02-02 01:11:42 +00:00
|
|
|
anim.Play("ToeRight", 0, 0);
|
2022-01-25 01:02:45 +00:00
|
|
|
}
|
2022-01-25 03:49:40 +00:00
|
|
|
|
2022-02-02 08:36:20 +00:00
|
|
|
if (player)
|
2022-01-25 03:49:40 +00:00
|
|
|
{
|
2022-02-02 08:36:20 +00:00
|
|
|
if (hit && ball)
|
|
|
|
{
|
|
|
|
Jukebox.PlayOneShotGame("spaceSoccer/highkicktoe3_hit");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Jukebox.PlayOneShotGame("spaceSoccer/highkicktoe3");
|
|
|
|
}
|
2022-01-25 03:49:40 +00:00
|
|
|
}
|
|
|
|
|
2022-02-02 08:36:20 +00:00
|
|
|
if (hit && ball)
|
|
|
|
ball.Toe();
|
|
|
|
|
2022-01-25 01:02:45 +00:00
|
|
|
kickPrepare = false;
|
|
|
|
ResetState();
|
2022-01-24 02:15:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private void Update()
|
|
|
|
{
|
2022-01-25 01:02:45 +00:00
|
|
|
if (kickTimes % 2 == 0)
|
2022-01-24 02:15:23 +00:00
|
|
|
{
|
2022-01-25 01:02:45 +00:00
|
|
|
kickLeft = false;
|
2022-01-24 02:15:23 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-01-25 01:02:45 +00:00
|
|
|
kickLeft = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
List<Beatmap.Entity> keepUps = GameManager.instance.Beatmap.entities.FindAll(c => c.datamodel == "spaceSoccer/keep-up");
|
|
|
|
List<Beatmap.Entity> highKicks = GameManager.instance.Beatmap.entities.FindAll(c => c.datamodel == "spaceSoccer/high kick-toe!");
|
|
|
|
for (int i = 0; i < keepUps.Count; i++)
|
|
|
|
{
|
|
|
|
if ((keepUps[i].beat - 0.15f) <= Conductor.instance.songPositionInBeats && (keepUps[i].beat + keepUps[i].length) - 0.15f > Conductor.instance.songPositionInBeats)
|
|
|
|
{
|
|
|
|
canKick = true;
|
|
|
|
canHighKick = false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
canKick = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (int i = 0; i < highKicks.Count; i++)
|
|
|
|
{
|
|
|
|
if ((highKicks[i].beat - 0.15f) <= Conductor.instance.songPositionInBeats && highKicks[i].beat + 1f > Conductor.instance.songPositionInBeats)
|
|
|
|
{
|
|
|
|
canHighKick = true;
|
|
|
|
canKick = false;
|
2022-02-06 08:28:14 +00:00
|
|
|
|
|
|
|
if (ball)
|
2022-02-24 14:12:19 +00:00
|
|
|
ball.highKickSwing = highKicks[i].swing;
|
2022-01-25 01:02:45 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
canHighKick = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ball)
|
|
|
|
{
|
2022-02-26 07:27:51 +00:00
|
|
|
switch (ball.state)
|
2022-01-25 01:02:45 +00:00
|
|
|
{
|
2022-02-26 07:27:51 +00:00
|
|
|
case Ball.State.Dispensing:
|
2022-01-25 01:02:45 +00:00
|
|
|
{
|
2022-02-26 07:27:51 +00:00
|
|
|
float normalizedBeat = Conductor.instance.GetPositionFromBeat(ball.startBeat, ball.GetAnimLength(Ball.State.Dispensing));
|
|
|
|
StateCheck(normalizedBeat, !player);
|
|
|
|
CheckIfFall(normalizedBeat);
|
2022-01-25 01:02:45 +00:00
|
|
|
|
2022-02-26 07:27:51 +00:00
|
|
|
if (player)
|
2022-02-02 08:36:20 +00:00
|
|
|
{
|
2022-02-26 07:27:51 +00:00
|
|
|
if (PlayerInput.Pressed())
|
|
|
|
{
|
|
|
|
if (state.perfect)
|
|
|
|
{
|
|
|
|
KickCheck(true);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
KickCheck(false, true);
|
|
|
|
}
|
|
|
|
}
|
2022-02-02 08:36:20 +00:00
|
|
|
}
|
2022-02-26 07:27:51 +00:00
|
|
|
break;
|
2022-01-25 01:02:45 +00:00
|
|
|
}
|
2022-02-26 07:27:51 +00:00
|
|
|
case Ball.State.Kicked:
|
2022-01-25 01:02:45 +00:00
|
|
|
{
|
2022-02-26 07:27:51 +00:00
|
|
|
float normalizedBeat = Conductor.instance.GetPositionFromBeat(ball.startBeat, ball.GetAnimLength(Ball.State.Kicked));
|
|
|
|
StateCheck(normalizedBeat, !player);
|
|
|
|
CheckIfFall(normalizedBeat);
|
|
|
|
|
|
|
|
if (player)
|
2022-02-02 08:36:20 +00:00
|
|
|
{
|
2022-02-26 07:27:51 +00:00
|
|
|
if (PlayerInput.Pressed())
|
|
|
|
{
|
|
|
|
if (state.perfect)
|
|
|
|
{
|
|
|
|
KickCheck(true);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
KickCheck(false, true);
|
|
|
|
}
|
|
|
|
}
|
2022-02-02 08:36:20 +00:00
|
|
|
}
|
2022-02-26 07:27:51 +00:00
|
|
|
break;
|
2022-01-25 01:02:45 +00:00
|
|
|
}
|
2022-02-26 07:27:51 +00:00
|
|
|
case Ball.State.HighKicked:
|
2022-01-25 01:02:45 +00:00
|
|
|
{
|
2022-02-26 07:27:51 +00:00
|
|
|
float normalizedBeat = Conductor.instance.GetPositionFromMargin(ball.startBeat + ball.GetAnimLength(Ball.State.HighKicked), 1f);
|
|
|
|
if (!kickPrepare)
|
2022-02-02 01:11:42 +00:00
|
|
|
{
|
2022-02-26 07:27:51 +00:00
|
|
|
float normalizedBeatPrepare = Conductor.instance.GetPositionFromBeat(ball.startBeat, 1f);
|
|
|
|
StateCheck(normalizedBeatPrepare, !player);
|
|
|
|
CheckIfFall(normalizedBeat);
|
|
|
|
|
|
|
|
if (player)
|
2022-02-02 08:36:20 +00:00
|
|
|
{
|
2022-02-26 07:27:51 +00:00
|
|
|
if (PlayerInput.AltPressed())
|
|
|
|
{
|
|
|
|
Kick(false, true);
|
|
|
|
}
|
2022-02-02 08:36:20 +00:00
|
|
|
}
|
2022-02-26 07:27:51 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
StateCheck(normalizedBeat, !player);
|
|
|
|
CheckIfFall(normalizedBeat);
|
|
|
|
|
|
|
|
if (player)
|
2022-02-02 08:36:20 +00:00
|
|
|
{
|
2022-02-26 07:27:51 +00:00
|
|
|
if (PlayerInput.AltPressedUp())
|
|
|
|
{
|
|
|
|
if (state.perfect)
|
|
|
|
{
|
|
|
|
Toe(true);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Toe(false);
|
|
|
|
}
|
|
|
|
}
|
2022-02-02 08:36:20 +00:00
|
|
|
}
|
2022-02-02 01:11:42 +00:00
|
|
|
}
|
2022-02-26 07:27:51 +00:00
|
|
|
break;
|
2022-01-25 01:02:45 +00:00
|
|
|
}
|
2022-02-26 07:27:51 +00:00
|
|
|
case Ball.State.Toe:
|
2022-01-25 01:02:45 +00:00
|
|
|
{
|
2022-02-26 07:27:51 +00:00
|
|
|
float normalizedBeat = Conductor.instance.GetPositionFromMargin(ball.startBeat + ball.GetAnimLength(Ball.State.Toe), 1f);
|
|
|
|
StateCheck(normalizedBeat, !player);
|
|
|
|
CheckIfFall(normalizedBeat);
|
|
|
|
|
|
|
|
if (player)
|
2022-02-02 08:36:20 +00:00
|
|
|
{
|
2022-02-26 07:27:51 +00:00
|
|
|
if (PlayerInput.Pressed())
|
|
|
|
{
|
|
|
|
if (state.perfect)
|
|
|
|
{
|
|
|
|
KickCheck(true);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
KickCheck(false, true);
|
|
|
|
}
|
|
|
|
}
|
2022-02-02 08:36:20 +00:00
|
|
|
}
|
2022-02-26 07:27:51 +00:00
|
|
|
break;
|
2022-01-25 01:02:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-02-02 01:11:42 +00:00
|
|
|
else
|
2022-01-25 01:02:45 +00:00
|
|
|
{
|
2022-02-02 08:36:20 +00:00
|
|
|
if (player)
|
2022-02-02 01:11:42 +00:00
|
|
|
{
|
2022-02-02 08:36:20 +00:00
|
|
|
if (PlayerInput.Pressed())
|
|
|
|
{
|
|
|
|
KickCheck(false, true);
|
|
|
|
}
|
2022-02-02 01:11:42 +00:00
|
|
|
}
|
2022-01-25 01:02:45 +00:00
|
|
|
}
|
2022-02-26 07:27:51 +00:00
|
|
|
|
2022-01-25 01:02:45 +00:00
|
|
|
}
|
|
|
|
|
2022-02-02 01:11:42 +00:00
|
|
|
private void KickCheck(bool hit, bool overrideState = false)
|
2022-01-25 01:02:45 +00:00
|
|
|
{
|
|
|
|
if (canHighKick)
|
|
|
|
{
|
2022-02-02 01:11:42 +00:00
|
|
|
HighKick(hit);
|
2022-01-25 01:02:45 +00:00
|
|
|
}
|
|
|
|
else if (canKick)
|
|
|
|
{
|
2022-02-02 01:11:42 +00:00
|
|
|
Kick(hit);
|
|
|
|
}
|
|
|
|
else if (!canKick && !canHighKick && overrideState)
|
|
|
|
{
|
|
|
|
Kick(hit);
|
2022-01-25 01:02:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void CheckIfFall(float normalizedBeat)
|
|
|
|
{
|
2022-02-14 13:48:41 +00:00
|
|
|
if (normalizedBeat > Minigame.LateTime() && !GameManager.instance.autoplay)
|
2022-01-25 01:02:45 +00:00
|
|
|
{
|
2022-02-02 01:11:42 +00:00
|
|
|
Jukebox.PlayOneShotGame("spaceSoccer/missNeutral");
|
2022-01-25 01:02:45 +00:00
|
|
|
ball = null;
|
|
|
|
ResetState();
|
2022-01-24 02:15:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|