2023-01-13 22:24:26 +00:00
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using UnityEngine;
|
2023-04-22 19:20:01 +00:00
|
|
|
using Starpelly;
|
2023-01-13 22:24:26 +00:00
|
|
|
|
|
|
|
using HeavenStudio.Util;
|
|
|
|
|
|
|
|
namespace HeavenStudio.Games.Scripts_DoubleDate
|
|
|
|
{
|
2023-04-22 19:20:01 +00:00
|
|
|
public class SoccerBall : SuperCurveObject
|
2023-01-13 22:24:26 +00:00
|
|
|
{
|
2023-03-27 03:12:23 +00:00
|
|
|
private DoubleDate game;
|
2023-04-22 19:20:01 +00:00
|
|
|
private SuperCurveObject.Path path;
|
|
|
|
private float pathStartBeat = float.MinValue;
|
|
|
|
private Conductor conductor;
|
|
|
|
private GameObject shadow;
|
2023-03-27 03:12:23 +00:00
|
|
|
|
2023-01-13 22:24:26 +00:00
|
|
|
void Awake()
|
|
|
|
{
|
2023-03-27 03:12:23 +00:00
|
|
|
game = DoubleDate.instance;
|
2023-04-22 19:20:01 +00:00
|
|
|
conductor = Conductor.instance;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Update()
|
|
|
|
{
|
|
|
|
float beat = conductor.songPositionInBeats;
|
|
|
|
float height = 0f;
|
|
|
|
if (pathStartBeat > float.MinValue)
|
|
|
|
{
|
|
|
|
Vector3 pos = GetPathPositionFromBeat(path, Mathf.Max(beat, pathStartBeat), out height, pathStartBeat);
|
|
|
|
transform.position = pos;
|
|
|
|
float rot = GetPathValue("rot");
|
|
|
|
transform.rotation = Quaternion.Euler(0f, 0f, transform.rotation.eulerAngles.z - (rot * Time.deltaTime * (1f/conductor.pitchedSecPerBeat)));
|
|
|
|
}
|
|
|
|
shadow.transform.position = new Vector3(transform.position.x, Mathf.Min(transform.position.y - height, game.floorHeight), transform.position.z);
|
|
|
|
shadow.transform.localScale = Vector3.one * Mathf.Clamp(((transform.position.y) - game.shadowDepthScaleMin) / (game.shadowDepthScaleMax - game.shadowDepthScaleMin), 0f, 1f);
|
2023-03-27 03:12:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void Init(float beat)
|
|
|
|
{
|
|
|
|
game.ScheduleInput(beat, 1f, InputType.STANDARD_DOWN, Just, Miss, Empty);
|
2023-04-22 19:20:01 +00:00
|
|
|
path = game.GetPath("SoccerIn");
|
|
|
|
UpdateLastRealPos();
|
|
|
|
pathStartBeat = beat - 1f;
|
|
|
|
|
|
|
|
Vector3 pos = GetPathPositionFromBeat(path, pathStartBeat, pathStartBeat);
|
|
|
|
transform.position = pos;
|
|
|
|
|
|
|
|
gameObject.SetActive(true);
|
|
|
|
shadow = game.MakeDropShadow();
|
|
|
|
shadow.transform.position = new Vector3(transform.position.x, Mathf.Min(game.floorHeight, transform.position.y - offset.y), transform.position.z);
|
|
|
|
shadow.SetActive(true);
|
2023-01-13 22:24:26 +00:00
|
|
|
}
|
|
|
|
|
2023-03-27 03:12:23 +00:00
|
|
|
void Just(PlayerActionEvent caller, float state)
|
2023-01-13 22:24:26 +00:00
|
|
|
{
|
2023-04-22 19:20:01 +00:00
|
|
|
BeatAction.New(gameObject, new List<BeatAction.Action>()
|
|
|
|
{
|
|
|
|
new BeatAction.Action(conductor.songPositionInBeats + 3f, delegate
|
|
|
|
{
|
|
|
|
Destroy(gameObject);
|
|
|
|
}),
|
|
|
|
});
|
|
|
|
UpdateLastRealPos();
|
|
|
|
pathStartBeat = conductor.songPositionInBeats;
|
2023-03-27 03:12:23 +00:00
|
|
|
if (state >= 1f || state <= -1f)
|
|
|
|
{
|
2023-04-22 19:20:01 +00:00
|
|
|
path = game.GetPath("SoccerNg" + (state > 0 ? "Late" : "Early"));
|
2023-03-27 03:12:23 +00:00
|
|
|
Jukebox.PlayOneShot("miss");
|
|
|
|
game.Kick(false);
|
2023-04-22 19:20:01 +00:00
|
|
|
GetComponent<SpriteRenderer>().sortingOrder = 8;
|
2023-03-27 03:12:23 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
Hit();
|
2023-01-13 22:24:26 +00:00
|
|
|
}
|
2023-03-27 03:12:23 +00:00
|
|
|
|
|
|
|
void Hit()
|
|
|
|
{
|
2023-04-22 19:20:01 +00:00
|
|
|
UpdateLastRealPos();
|
|
|
|
pathStartBeat = conductor.songPositionInBeats;
|
|
|
|
path = game.GetPath("SoccerJust");
|
2023-03-27 03:12:23 +00:00
|
|
|
game.Kick();
|
|
|
|
Jukebox.PlayOneShotGame("doubleDate/kick");
|
|
|
|
}
|
|
|
|
|
|
|
|
void Miss(PlayerActionEvent caller)
|
|
|
|
{
|
|
|
|
Jukebox.PlayOneShotGame("doubleDate/weasel_hide");
|
2023-04-22 19:20:01 +00:00
|
|
|
game.MissKick(pathStartBeat + 2.25f);
|
|
|
|
|
|
|
|
BeatAction.New(gameObject, new List<BeatAction.Action>()
|
|
|
|
{
|
|
|
|
new BeatAction.Action(conductor.songPositionInBeats + 4f, delegate
|
|
|
|
{
|
|
|
|
Destroy(gameObject);
|
|
|
|
}),
|
|
|
|
});
|
2023-03-27 03:12:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Empty(PlayerActionEvent caller) { }
|
2023-04-22 19:20:01 +00:00
|
|
|
|
|
|
|
private void OnDestroy() {
|
|
|
|
if (shadow != null)
|
|
|
|
{
|
|
|
|
Destroy(shadow);
|
|
|
|
}
|
|
|
|
}
|
2023-01-13 22:24:26 +00:00
|
|
|
}
|
|
|
|
}
|