2023-06-10 19:17:06 +00:00
|
|
|
using System;
|
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;
|
2023-06-10 19:17:06 +00:00
|
|
|
private double pathStartBeat = double.MinValue;
|
2023-04-22 19:20:01 +00:00
|
|
|
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()
|
|
|
|
{
|
2023-06-10 19:17:06 +00:00
|
|
|
double beat = conductor.songPositionInBeatsAsDouble;
|
|
|
|
double height = 0f;
|
|
|
|
if (pathStartBeat > double.MinValue)
|
2023-04-22 19:20:01 +00:00
|
|
|
{
|
2023-06-10 19:17:06 +00:00
|
|
|
Vector3 pos = GetPathPositionFromBeat(path, Math.Max(beat, pathStartBeat), out height, pathStartBeat);
|
2023-04-22 19:20:01 +00:00
|
|
|
transform.position = pos;
|
|
|
|
float rot = GetPathValue("rot");
|
|
|
|
transform.rotation = Quaternion.Euler(0f, 0f, transform.rotation.eulerAngles.z - (rot * Time.deltaTime * (1f/conductor.pitchedSecPerBeat)));
|
|
|
|
}
|
2023-06-10 19:17:06 +00:00
|
|
|
shadow.transform.position = new Vector3(transform.position.x, (float) Math.Min(transform.position.y - height, game.floorHeight), transform.position.z);
|
2023-04-22 19:20:01 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2023-06-10 19:17:06 +00:00
|
|
|
public void Init(double beat)
|
2023-03-27 03:12:23 +00:00
|
|
|
{
|
|
|
|
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>()
|
|
|
|
{
|
2023-06-10 19:17:06 +00:00
|
|
|
new BeatAction.Action(conductor.songPositionInBeatsAsDouble + 3f, delegate
|
2023-04-22 19:20:01 +00:00
|
|
|
{
|
|
|
|
Destroy(gameObject);
|
|
|
|
}),
|
|
|
|
});
|
|
|
|
UpdateLastRealPos();
|
2023-06-10 19:17:06 +00:00
|
|
|
pathStartBeat = conductor.songPositionInBeatsAsDouble;
|
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-06-10 19:17:06 +00:00
|
|
|
SoundByte.PlayOneShot("miss");
|
2023-03-27 03:12:23 +00:00
|
|
|
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();
|
2023-06-10 19:17:06 +00:00
|
|
|
pathStartBeat = conductor.songPositionInBeatsAsDouble;
|
2023-04-22 19:20:01 +00:00
|
|
|
path = game.GetPath("SoccerJust");
|
2023-03-27 03:12:23 +00:00
|
|
|
game.Kick();
|
2023-06-10 19:17:06 +00:00
|
|
|
SoundByte.PlayOneShotGame("doubleDate/kick");
|
2023-03-27 03:12:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Miss(PlayerActionEvent caller)
|
|
|
|
{
|
2023-06-10 19:17:06 +00:00
|
|
|
SoundByte.PlayOneShotGame("doubleDate/weasel_hide");
|
2023-04-22 19:20:01 +00:00
|
|
|
game.MissKick(pathStartBeat + 2.25f);
|
|
|
|
|
|
|
|
BeatAction.New(gameObject, new List<BeatAction.Action>()
|
|
|
|
{
|
2023-06-10 19:17:06 +00:00
|
|
|
new BeatAction.Action(conductor.songPositionInBeatsAsDouble + 4f, delegate
|
2023-04-22 19:20:01 +00:00
|
|
|
{
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|