HeavenStudioPlus/Assets/Scripts/Games/TossBoys/TossBoysBall.cs
minenice55 8fa4d74096 Alternate Control Styles Support (#554)
* add mouse controller

* support different control styles in options

deprecate old input check methods

* fully functional input actions system

* btsds InputAction

* blue bear InputAction

* more games

fix bugs with some input related systems

* coin toss re-toss

* cheer readers touch

* dog ninja touch

* multiple games

* last of the easy games' touch

* more specialized games

* specialized games 2

* finish ktb games

* remove legacy settings disclaimer

* "only" two games left

* karate man touch

* rockers touch

still needs fixes and bad judge strum

* DSGuy flicking animation

* playstyle chart property

* improve performance of minigame preloading

* improve look of cursor

make assetbundles use chunk-based compression
refactor assetbundle loading methods a bit

* prime conductor stream playback to stabilize seeking operations

* fix air rally swing on pad release

* use virtual mouse pointer

* add UniTask

* make BeatAction use UniTask

* implement UniTask to replace some coroutines

* add touch style UI elements and effects

games now support the ability to define two cursor colours if they need split screen touch inputs

* update plugins and buildscript

* implement thresholded pointer position clipping

* fix clamping

* instant show / hide

fix discord game SDK crashes
2023-10-29 19:44:47 +00:00

124 lines
4.3 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using HeavenStudio.Util;
using System;
namespace HeavenStudio.Games.Scripts_TossBoys
{
public class TossBoysBall : SuperCurveObject
{
public enum State
{
None,
RedDispense,
BlueDispense,
YellowDispense,
RedBlue,
RedYellow,
BlueRed,
BlueYellow,
YellowRed,
YellowBlue,
RedBlueDual,
RedYellowDual,
BlueRedDual,
BlueYellowDual,
YellowRedDual,
YellowBlueDual,
RedBlueHigh,
RedYellowHigh,
BlueRedHigh,
BlueYellowHigh,
YellowRedHigh,
YellowBlueHigh,
RedBlur,
RedKeep,
BlueBlur,
BlueKeep,
YellowBlur,
YellowKeep
}
public State BallState { get { return currentState; } }
public bool willBePopped;
private State currentState;
private double startBeat;
private Path currentPath;
private TossBoys game;
[NonSerialized] public Animator anim;
private void Awake()
{
game = TossBoys.instance;
anim = GetComponent<Animator>();
}
private void Update()
{
if (Conductor.instance.isPlaying && !Conductor.instance.isPaused)
{
switch (currentState)
{
case State.None:
//Do Jackshit
break;
default:
transform.position = GetPathPositionFromBeat(currentPath, Math.Max(startBeat, Conductor.instance.songPositionInBeatsAsDouble), startBeat);
float rot = GetPathValue("rot");
transform.rotation = Quaternion.Euler(0f, 0f, transform.rotation.eulerAngles.z - (rot * Time.deltaTime * (1f / Conductor.instance.pitchedSecPerBeat)));
break;
}
}
}
public void SetState(State state, double beat, float length = 0)
{
UpdateLastRealPos();
startBeat = beat;
currentState = state;
currentPath = currentState switch
{
State.None => new Path(),
State.RedDispense => game.GetPath("RedDispense"),
State.BlueDispense => game.GetPath("BlueDispense"),
State.YellowDispense => game.GetPath("YellowDispense"),
State.RedBlue => game.GetPath("RedBlue"),
State.RedYellow => game.GetPath("RedYellow"),
State.BlueRed => game.GetPath("BlueRed"),
State.BlueYellow => game.GetPath("BlueYellow"),
State.YellowRed => game.GetPath("YellowRed"),
State.YellowBlue => game.GetPath("YellowBlue"),
State.RedBlueDual => game.GetPath("RedBlueDual"),
State.RedYellowDual => game.GetPath("RedYellowDual"),
State.BlueRedDual => game.GetPath("BlueRedDual"),
State.BlueYellowDual => game.GetPath("BlueYellowDual"),
State.YellowRedDual => game.GetPath("YellowRedDual"),
State.YellowBlueDual => game.GetPath("YellowBlueDual"),
State.RedBlueHigh => game.GetPath("RedBlueHigh"),
State.RedYellowHigh => game.GetPath("RedYellowHigh"),
State.BlueRedHigh => game.GetPath("BlueRedHigh"),
State.BlueYellowHigh => game.GetPath("BlueYellowHigh"),
State.YellowRedHigh => game.GetPath("YellowRedHigh"),
State.YellowBlueHigh => game.GetPath("YellowBlueHigh"),
State.RedBlur => game.GetPath("RedBlur"),
State.RedKeep => game.GetPath("RedKeep"),
State.BlueBlur => game.GetPath("BlueBlur"),
State.BlueKeep => game.GetPath("BlueKeep"),
State.YellowBlur => game.GetPath("YellowBlur"),
State.YellowKeep => game.GetPath("YellowKeep"),
_ => throw new System.NotImplementedException()
};
if (length != 0)
{
currentPath.positions[0].duration = length;
}
}
}
}