2022-02-03 02:09:50 +00:00
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using UnityEngine;
|
|
|
|
|
2022-02-12 08:12:12 +00:00
|
|
|
using RhythmHeavenMania.Util;
|
2022-02-03 02:09:50 +00:00
|
|
|
namespace RhythmHeavenMania.Games.RhythmRally
|
|
|
|
{
|
2022-02-12 08:12:12 +00:00
|
|
|
public class RhythmRally : Minigame
|
2022-02-03 02:09:50 +00:00
|
|
|
{
|
|
|
|
public Transform cameraPos;
|
|
|
|
|
2022-02-04 18:15:28 +00:00
|
|
|
public GameObject ball;
|
|
|
|
public NaughtyBezierCurves.BezierCurve3D curve3D;
|
|
|
|
|
2022-02-12 08:12:12 +00:00
|
|
|
public Animator playerAnim;
|
|
|
|
public Animator opponentAnim;
|
|
|
|
|
|
|
|
public GameEvent bop = new GameEvent();
|
|
|
|
|
|
|
|
public static RhythmRally instance;
|
|
|
|
|
|
|
|
private void Awake()
|
|
|
|
{
|
|
|
|
instance = this;
|
|
|
|
}
|
|
|
|
|
2022-02-03 02:09:50 +00:00
|
|
|
// Start is called before the first frame update
|
|
|
|
void Start()
|
|
|
|
{
|
|
|
|
GameCamera.instance.camera.transform.position = cameraPos.position;
|
|
|
|
GameCamera.instance.camera.transform.rotation = cameraPos.rotation;
|
|
|
|
GameCamera.instance.camera.fieldOfView = 41f;
|
|
|
|
GameCamera.instance.camera.backgroundColor = Color.white;
|
2022-02-12 08:12:12 +00:00
|
|
|
|
|
|
|
playerAnim.Play("Idle", 0, 0);
|
|
|
|
opponentAnim.Play("Idle", 0, 0);
|
2022-02-03 02:09:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Update is called once per frame
|
|
|
|
void Update()
|
|
|
|
{
|
2022-02-12 08:12:12 +00:00
|
|
|
var cond = Conductor.instance;
|
|
|
|
|
|
|
|
ball.transform.position = curve3D.GetPoint(Mathf.Clamp(cond.GetPositionFromBeat(0, 2f), 0, 1));
|
2022-02-04 18:15:28 +00:00
|
|
|
ball.transform.GetChild(0).transform.position = new Vector3(ball.transform.position.x, -0.399f, ball.transform.position.z);
|
2022-02-12 08:12:12 +00:00
|
|
|
|
|
|
|
if (cond.ReportBeat(ref bop.lastReportedBeat, bop.startBeat % 1))
|
|
|
|
{
|
|
|
|
if (cond.songPositionInBeats >= bop.startBeat && cond.songPositionInBeats < bop.startBeat + bop.length)
|
|
|
|
{
|
|
|
|
var playerState = playerAnim.GetCurrentAnimatorStateInfo(0);
|
|
|
|
if (playerAnim.IsAnimationNotPlaying() || playerState.IsName("Idle") || playerState.IsName("Beat"))
|
|
|
|
playerAnim.Play("Beat", 0, 0);
|
|
|
|
|
|
|
|
var opponentState = opponentAnim.GetCurrentAnimatorStateInfo(0);
|
|
|
|
if (opponentAnim.IsAnimationNotPlaying() || opponentState.IsName("Idle") || opponentState.IsName("Beat"))
|
|
|
|
opponentAnim.Play("Beat", 0, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void Bop(float beat, float length)
|
|
|
|
{
|
|
|
|
bop.length = length;
|
|
|
|
bop.startBeat = beat;
|
2022-02-03 02:09:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|