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;
|
|
|
|
|
|
|
|
using HeavenStudio.Util;
|
|
|
|
|
|
|
|
namespace HeavenStudio.Games.Scripts_DoubleDate
|
|
|
|
{
|
2023-04-22 19:20:01 +00:00
|
|
|
public class Football : 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-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-01-13 22:24:26 +00:00
|
|
|
}
|
|
|
|
|
2023-06-10 19:17:06 +00:00
|
|
|
public void Init(double beat)
|
2023-01-13 22:24:26 +00:00
|
|
|
{
|
2023-03-27 03:12:23 +00:00
|
|
|
game.ScheduleInput(beat, 1.5f, InputType.STANDARD_DOWN, Just, Miss, Empty);
|
2023-04-22 19:20:01 +00:00
|
|
|
path = game.GetPath("FootBallInNoHit"); // there's a second path for footballs that hit the weasels, use that if the weasels haven't been hit recently
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
if (state >= 1f || state <= -1f)
|
|
|
|
{
|
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("FootBallNg" + (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;
|
|
|
|
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
|
|
|
return;
|
|
|
|
}
|
|
|
|
Hit();
|
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 + 1f, delegate
|
2023-04-22 19:20:01 +00:00
|
|
|
{
|
|
|
|
shadow.SetActive(false);
|
|
|
|
GetComponent<SpriteRenderer>().sortingOrder = -5;
|
|
|
|
transform.localScale *= 0.25f;
|
|
|
|
path = game.GetPath("FootBallFall");
|
|
|
|
UpdateLastRealPos();
|
2023-06-10 19:17:06 +00:00
|
|
|
pathStartBeat = conductor.songPositionInBeatsAsDouble + 1f;
|
2023-04-22 19:20:01 +00:00
|
|
|
}),
|
2023-06-10 19:17:06 +00:00
|
|
|
new BeatAction.Action(conductor.songPositionInBeatsAsDouble + 12f, delegate
|
2023-04-22 19:20:01 +00:00
|
|
|
{
|
|
|
|
Destroy(gameObject);
|
|
|
|
}),
|
|
|
|
});
|
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("FootBallJust");
|
|
|
|
game.Kick(true, true, jump: true);
|
2023-06-10 19:17:06 +00:00
|
|
|
SoundByte.PlayOneShotGame("doubleDate/footballKick");
|
2023-03-27 03:12:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Miss(PlayerActionEvent caller)
|
|
|
|
{
|
2023-06-10 19:17:06 +00:00
|
|
|
if (conductor.songPositionInBeatsAsDouble > game.lastHitWeasel + 2.25f)
|
2023-04-22 19:20:01 +00:00
|
|
|
{
|
|
|
|
path = game.GetPath("FootBallIn");
|
|
|
|
float impact = GetPointTimeByTag(path, "impact");
|
|
|
|
if (impact > 0)
|
|
|
|
{
|
|
|
|
GetComponent<SpriteRenderer>().sortingOrder = 8;
|
2023-06-10 19:17:06 +00:00
|
|
|
SoundByte.PlayOneShotGame("doubleDate/weasel_hit", pathStartBeat + impact);
|
|
|
|
SoundByte.PlayOneShotGame("doubleDate/weasel_scream", pathStartBeat + impact);
|
2023-04-22 19:20:01 +00:00
|
|
|
game.MissKick(pathStartBeat + impact, true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
BeatAction.New(gameObject, new List<BeatAction.Action>()
|
|
|
|
{
|
2023-06-10 19:17:06 +00:00
|
|
|
new BeatAction.Action(conductor.songPositionInBeatsAsDouble + 5f, 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
|
|
|
}
|
|
|
|
}
|