fully functional input actions system

This commit is contained in:
minenice55 2023-09-18 14:55:37 -04:00
parent 4f264ef4cb
commit df5c1ddf93
12 changed files with 311 additions and 82 deletions

View file

@ -28,6 +28,7 @@ Transform:
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 285182280367868644}
m_RootOrder: 1
@ -98,6 +99,7 @@ Transform:
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 285182279538923132}
m_Father: {fileID: 285182280367868644}
@ -148,6 +150,7 @@ Transform:
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 0, y: 0, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 285182280031512482}
m_RootOrder: 0
@ -163,6 +166,7 @@ SpriteRenderer:
m_CastShadows: 0
m_ReceiveShadows: 0
m_DynamicOccludee: 1
m_StaticShadowCaster: 0
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
@ -230,6 +234,7 @@ Transform:
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 0.65, y: 0.65, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 285182280031512482}
- {fileID: 285182279897966107}
@ -275,6 +280,7 @@ Transform:
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 285182279842109878}
m_RootOrder: 0
@ -290,6 +296,7 @@ SpriteRenderer:
m_CastShadows: 0
m_ReceiveShadows: 0
m_DynamicOccludee: 1
m_StaticShadowCaster: 0
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
@ -359,6 +366,7 @@ Transform:
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: -0.66, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 285182280031512482}
m_RootOrder: 2
@ -374,6 +382,7 @@ SpriteRenderer:
m_CastShadows: 0
m_ReceiveShadows: 0
m_DynamicOccludee: 1
m_StaticShadowCaster: 0
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
@ -467,6 +476,7 @@ Transform:
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 285182279419378161}
m_Father: {fileID: 285182279137842937}
@ -479,7 +489,7 @@ MonoBehaviour:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 285182279538923131}
m_Enabled: 1
m_Enabled: 0
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 5421f511c7f44364cb7a8b3c23a9cf19, type: 3}
m_Name:
@ -496,7 +506,7 @@ MonoBehaviour:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 285182279538923131}
m_Enabled: 1
m_Enabled: 0
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 141a2c65793e39943a8304c67905de70, type: 3}
m_Name:
@ -530,6 +540,7 @@ Transform:
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 285182279492467814}
m_Father: {fileID: 285182280031512482}
@ -546,6 +557,7 @@ SpriteRenderer:
m_CastShadows: 0
m_ReceiveShadows: 0
m_DynamicOccludee: 1
m_StaticShadowCaster: 0
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
@ -614,6 +626,7 @@ Transform:
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 0.2, y: 0.2, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 285182279419378161}
m_RootOrder: 1
@ -629,6 +642,7 @@ SpriteRenderer:
m_CastShadows: 0
m_ReceiveShadows: 0
m_DynamicOccludee: 1
m_StaticShadowCaster: 0
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
@ -708,6 +722,7 @@ Transform:
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 285182279354310576}
- {fileID: 285182279842109878}
@ -741,6 +756,7 @@ Transform:
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 285182279137842937}
- {fileID: 285182279131759465}

View file

@ -3,6 +3,7 @@ using System.Collections.Generic;
using UnityEngine;
using DG.Tweening;
using HeavenStudio.Games;
namespace HeavenStudio
{
@ -25,7 +26,7 @@ namespace HeavenStudio
private void Update()
{
Vector3 pos = GameManager.instance.CursorCam.ScreenToWorldPoint(Input.mousePosition);
Vector3 pos = PlayerInput.GetInputController(1).GetPointer();
if (follow)
{
@ -36,9 +37,8 @@ namespace HeavenStudio
{
this.gameObject.transform.position = new Vector3(pos.x, pos.y, 0);
if (PlayerInput.Pressed())
if (PlayerInput.GetIsAction(Minigame.InputAction_BasicPress, out _))
{
// Cursor.visible = false;
Circle.transform.DOScale(0, 0.5f).SetEase(Ease.OutExpo);
InnerCircle.SetActive(true);
outerCircleTween.Kill();
@ -48,7 +48,7 @@ namespace HeavenStudio
eyesTween.Kill();
eyesTween = Eyes.transform.DOLocalMoveY(0.15f, 0.15f).SetEase(Ease.OutExpo);
}
else if (PlayerInput.PressedUp())
else if (PlayerInput.GetIsAction(Minigame.InputAction_BasicRelease, out _))
{
Circle.transform.DOScale(0.2f, 0.5f).SetEase(Ease.OutExpo);
InnerCircle.SetActive(false);
@ -61,5 +61,4 @@ namespace HeavenStudio
}
}
}
}

View file

@ -45,7 +45,7 @@ namespace HeavenStudio.Games.Scripts_ForkLifter
private void LateUpdate()
{
if (PlayerInput.Pressed() && !ForkLifter.instance.IsExpectingInputNow(InputType.STANDARD_DOWN))
if (PlayerInput.GetIsAction(ForkLifter.InputAction_BasicPress, out _) && !ForkLifter.instance.IsExpectingInputNow(ForkLifter.InputAction_BasicPress.inputLockCategory))
{
Stab(null);
}

View file

@ -35,7 +35,7 @@ namespace HeavenStudio.Games.Scripts_ForkLifter
transform.GetChild(0).GetChild(i).GetComponent<SpriteRenderer>().sprite = transform.GetChild(0).GetComponent<SpriteRenderer>().sprite;
}
game.ScheduleInput(startBeat, 2f, InputType.STANDARD_DOWN, Just, Miss, Out);
game.ScheduleInput(startBeat, 2f, ForkLifter.InputAction_BasicPress, Just, Miss, Out);
}
public void Hit()

View file

@ -4,6 +4,7 @@ using UnityEngine;
using HeavenStudio.Util;
using HeavenStudio.Common;
using HeavenStudio.InputSystem;
namespace HeavenStudio.Games
{
@ -27,8 +28,139 @@ namespace HeavenStudio.Games
public float createBeat;
}
#region Premade Input Actions
const int IAEmptyCat = -1;
const int IAPressCat = 0;
const int IAReleaseCat = 1;
const int IAFlickCat = 2;
protected static bool IA_Empty(out double dt)
{
dt = 0;
return false;
}
protected static bool IA_PadBasicPress(out double dt)
{
return PlayerInput.GetPadDown(InputController.ActionsPad.East, out dt);
}
protected static bool IA_TouchBasicPress(out double dt)
{
return PlayerInput.GetTouchDown(InputController.ActionsTouch.Tap, out dt);
}
protected static bool IA_BatonBasicPress(out double dt)
{
return PlayerInput.GetBatonDown(InputController.ActionsBaton.Face, out dt);
}
protected static bool IA_PadBasicRelease(out double dt)
{
return PlayerInput.GetPadUp(InputController.ActionsPad.East, out dt);
}
protected static bool IA_TouchBasicRelease(out double dt)
{
return PlayerInput.GetTouchUp(InputController.ActionsTouch.Tap, out dt);
}
protected static bool IA_BatonBasicRelease(out double dt)
{
return PlayerInput.GetBatonUp(InputController.ActionsBaton.Face, out dt);
}
protected static bool IA_TouchFlick(out double dt)
{
return PlayerInput.GetFlick(out dt);
}
public static PlayerInput.InputAction InputAction_BasicPress =
new("BasicPress", new int[] { IAPressCat, IAPressCat, IAPressCat },
IA_PadBasicPress, IA_TouchBasicPress, IA_BatonBasicPress);
public static PlayerInput.InputAction InputAction_BasicRelease =
new("BasicPress", new int[] { IAReleaseCat, IAReleaseCat, IAReleaseCat },
IA_PadBasicRelease, IA_TouchBasicRelease, IA_BatonBasicRelease);
public static PlayerInput.InputAction InputAction_FlickPress =
new("BasicPress", new int[] { IAPressCat, IAFlickCat, IAPressCat },
IA_PadBasicPress, IA_TouchFlick, IA_BatonBasicPress);
public static PlayerInput.InputAction InputAction_FlickRelease =
new("BasicPress", new int[] { IAReleaseCat, IAFlickCat, IAReleaseCat },
IA_PadBasicRelease, IA_TouchFlick, IA_BatonBasicRelease);
#endregion
public List<PlayerActionEvent> scheduledInputs = new List<PlayerActionEvent>();
/// <summary>
/// Schedule an Input for a later time in the minigame. Executes the methods put in parameters
/// </summary>
/// <param name="startBeat">When the scheduling started (in beats)</param>
/// <param name="timer">How many beats later should the input be expected</param>
/// <param name="inputAction">The input action that's expected</param>
/// <param name="OnHit">Method to run if the Input has been Hit</param>
/// <param name="OnMiss">Method to run if the Input has been Missed</param>
/// <param name="OnBlank">Method to run whenever there's an Input while this is Scheduled (Shouldn't be used too much)</param>
/// <returns></returns>
public PlayerActionEvent ScheduleInput(
double startBeat,
double timer,
PlayerInput.InputAction inputAction,
PlayerActionEvent.ActionEventCallbackState OnHit,
PlayerActionEvent.ActionEventCallback OnMiss,
PlayerActionEvent.ActionEventCallback OnBlank,
PlayerActionEvent.ActionEventHittableQuery HittableQuery = null
)
{
GameObject evtObj = new GameObject("ActionEvent" + (startBeat + timer));
evtObj.AddComponent<PlayerActionEvent>();
PlayerActionEvent evt = evtObj.GetComponent<PlayerActionEvent>();
evt.startBeat = startBeat;
evt.timer = timer;
evt.InputAction = inputAction;
evt.OnHit = OnHit;
evt.OnMiss = OnMiss;
evt.OnBlank = OnBlank;
evt.IsHittable = HittableQuery;
evt.OnDestroy = RemoveScheduledInput;
evt.canHit = true;
evt.enabled = true;
evt.transform.parent = this.transform.parent;
evtObj.SetActive(true);
scheduledInputs.Add(evt);
return evt;
}
public PlayerActionEvent ScheduleAutoplayInput(double startBeat,
double timer,
PlayerInput.InputAction inputAction,
PlayerActionEvent.ActionEventCallbackState OnHit,
PlayerActionEvent.ActionEventCallback OnMiss,
PlayerActionEvent.ActionEventCallback OnBlank)
{
PlayerActionEvent evt = ScheduleInput(startBeat, timer, inputAction, OnHit, OnMiss, OnBlank);
evt.autoplayOnly = true;
return evt;
}
public PlayerActionEvent ScheduleUserInput(double startBeat,
double timer,
PlayerInput.InputAction inputAction,
PlayerActionEvent.ActionEventCallbackState OnHit,
PlayerActionEvent.ActionEventCallback OnMiss,
PlayerActionEvent.ActionEventCallback OnBlank,
PlayerActionEvent.ActionEventHittableQuery HittableQuery = null)
{
PlayerActionEvent evt = ScheduleInput(startBeat, timer, inputAction, OnHit, OnMiss, OnBlank, HittableQuery);
evt.noAutoplay = true;
return evt;
}
/// <summary>
/// Schedule an Input for a later time in the minigame. Executes the methods put in parameters
/// </summary>
@ -143,10 +275,10 @@ namespace HeavenStudio.Games
return closest;
}
public PlayerActionEvent GetClosestScheduledInput(string action)
public PlayerActionEvent GetClosestScheduledInput(int[] actionCats)
{
if (action == null) return null;
int catIdx = (int)PlayerInput.CurrentControlStyle;
int cat = actionCats[catIdx];
PlayerActionEvent closest = null;
foreach (PlayerActionEvent toCompare in scheduledInputs)
@ -156,7 +288,7 @@ namespace HeavenStudio.Games
if (closest == null)
{
if (toCompare.InputAction.name == action)
if (toCompare.InputAction.inputLockCategory[catIdx] == cat)
closest = toCompare;
}
else
@ -164,11 +296,9 @@ namespace HeavenStudio.Games
double t1 = closest.startBeat + closest.timer;
double t2 = toCompare.startBeat + toCompare.timer;
// Debug.Log("t1=" + t1 + " -- t2=" + t2);
if (t2 < t1)
{
if (toCompare.InputAction.name == action)
if (toCompare.InputAction.inputLockCategory[catIdx] == cat)
closest = toCompare;
}
}
@ -187,9 +317,9 @@ namespace HeavenStudio.Games
return input.IsExpectingInputNow();
}
public bool IsExpectingInputNow(string wantAction)
public bool IsExpectingInputNow(int[] wantActionCategory)
{
PlayerActionEvent input = GetClosestScheduledInput(wantAction);
PlayerActionEvent input = GetClosestScheduledInput(wantActionCategory);
if (input == null) return false;
return input.IsExpectingInputNow();
}

View file

@ -1,14 +1,8 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using DG.Tweening;
using HeavenStudio.Util;
using Starpelly;
using HeavenStudio.Common;
using HeavenStudio.InputSystem;
namespace HeavenStudio.Games
{
@ -170,7 +164,9 @@ namespace HeavenStudio.Games
if (InputAction != null)
{
if (toCompare.InputAction == null) continue;
if (toCompare.InputAction != null && toCompare.InputAction == InputAction) continue;
int catIdx = (int)PlayerInput.CurrentControlStyle;
if (toCompare.InputAction != null
&& toCompare.InputAction.inputLockCategory[catIdx] == InputAction.inputLockCategory[catIdx]) continue;
}
else
{

View file

@ -739,7 +739,10 @@ namespace HeavenStudio.InputSystem
public override Vector2 GetPointer()
{
return Vector2.zero;
Camera cam = GameManager.instance.CursorCam;
Vector3 rawPointerPos = Input.mousePosition;
rawPointerPos.z = Mathf.Abs(cam.gameObject.transform.position.z);
return cam.ScreenToWorldPoint(rawPointerPos);
}
public override bool GetHatDirection(InputDirection direction)
@ -967,17 +970,15 @@ namespace HeavenStudio.InputSystem
return otherHalf;
}
public override bool GetFlick(out double dt, out InputDirection direction)
public override bool GetFlick(out double dt)
{
dt = 0;
direction = InputDirection.Up;
return false;
}
public override bool GetSwipe(out double dt, out InputDirection direction)
public override bool GetSwipe(out double dt)
{
dt = 0;
direction = InputDirection.Up;
return false;
}

View file

@ -190,7 +190,10 @@ namespace HeavenStudio.InputSystem
public override Vector2 GetPointer()
{
return Vector2.zero;
Camera cam = GameManager.instance.CursorCam;
Vector3 rawPointerPos = Input.mousePosition;
rawPointerPos.z = Mathf.Abs(cam.gameObject.transform.position.z);
return cam.ScreenToWorldPoint(rawPointerPos);
}
//todo: directionals
@ -262,17 +265,15 @@ namespace HeavenStudio.InputSystem
return playerNum;
}
public override bool GetFlick(out double dt, out InputDirection direction)
public override bool GetFlick(out double dt)
{
dt = 0;
direction = InputDirection.Up;
return false;
}
public override bool GetSwipe(out double dt, out InputDirection direction)
public override bool GetSwipe(out double dt)
{
dt = 0;
direction = InputDirection.Up;
return false;
}

View file

@ -35,8 +35,9 @@ namespace HeavenStudio.InputSystem
{
public class InputMouse : InputController
{
const double FlickMarginTime = 0.1;
const double BigMoveMarginRate = 1.25;
const double FlickMarginTime = 0.05;
const double BigMoveMarginSpd = 0.1;
const double SmallMoveMarginSpd = 0.025;
private static readonly KeyCode[] keyCodes = Enum.GetValues(typeof(KeyCode))
.Cast<KeyCode>()
@ -73,10 +74,12 @@ namespace HeavenStudio.InputSystem
}
}
Vector3 realPos, lastRealPos;
Vector3 rawPointerPos, lastRawPointerPos, startPointerPos, lastDownPointerPos, lastUpPointerPos;
Vector3 deltaPointerPos, lastDeltaPointerPos;
double timeMoveChange, timeDirectionChange;
byte dirLeftRight, dirUpDown;
bool hasFlicked, hasSwiped, isInMove;
public override void InitializeController()
{
@ -85,15 +88,55 @@ namespace HeavenStudio.InputSystem
public override void UpdateState()
{
// Update the state of the controller
lastRawPointerPos = rawPointerPos;
lastDeltaPointerPos = deltaPointerPos;
rawPointerPos = Input.mousePosition;
deltaPointerPos = rawPointerPos - lastRawPointerPos;
Camera cam = GameManager.instance.CursorCam;
hasFlicked = false;
hasSwiped = false;
lastRawPointerPos = rawPointerPos;
lastRealPos = realPos;
lastDeltaPointerPos = deltaPointerPos;
rawPointerPos = Input.mousePosition;
rawPointerPos.z = Mathf.Abs(cam.gameObject.transform.position.z);
realPos = cam.ScreenToWorldPoint(rawPointerPos);
deltaPointerPos = realPos - lastRealPos;
float speed = deltaPointerPos.magnitude;
if (GetAction(ControlStyles.Touch, 0))
{
Debug.Log(deltaPointerPos.normalized);
Debug.Log($"pointer speed: {deltaPointerPos.magnitude}, direction: {deltaPointerPos.normalized}");
if (speed >= BigMoveMarginSpd)
{
timeMoveChange = Time.realtimeSinceStartupAsDouble;
if (!isInMove)
{
isInMove = true;
hasSwiped = true;
Debug.Log($"just started moving or direction change");
}
}
else
{
if (isInMove && speed < SmallMoveMarginSpd)
{
Debug.Log($"just stopped moving");
isInMove = false;
}
}
}
double dMoveChange = Time.realtimeSinceStartupAsDouble - timeMoveChange;
if (GetActionUp(ControlStyles.Touch, 0, out double dt))
{
isInMove = false;
lastRawPointerPos = rawPointerPos;
lastRealPos = realPos;
lastDeltaPointerPos = deltaPointerPos;
hasFlicked = dMoveChange < FlickMarginTime && speed >= BigMoveMarginSpd;
if (hasFlicked)
{
Debug.Log($"flicked (speed: {dMoveChange})");
}
}
}
@ -283,7 +326,7 @@ namespace HeavenStudio.InputSystem
public override Vector2 GetPointer()
{
return Vector2.zero;
return realPos;
}
//todo: directionals
@ -355,18 +398,16 @@ namespace HeavenStudio.InputSystem
return playerNum;
}
public override bool GetFlick(out double dt, out InputDirection direction)
public override bool GetFlick(out double dt)
{
dt = 0;
direction = InputDirection.Up;
return false;
return hasFlicked;
}
public override bool GetSwipe(out double dt, out InputDirection direction)
public override bool GetSwipe(out double dt)
{
dt = 0;
direction = InputDirection.Up;
return false;
dt = hasSwiped ? Time.realtimeSinceStartupAsDouble - timeMoveChange : 0;
return hasSwiped;
}
public override void SetMaterialProperties(Material m)

View file

@ -294,8 +294,8 @@ namespace HeavenStudio.InputSystem
/// <returns></returns>
public abstract bool GetHatDirectionUp(InputDirection direction, out double dt);
public abstract bool GetFlick(out double dt, out InputDirection direction);
public abstract bool GetSwipe(out double dt, out InputDirection direction);
public abstract bool GetFlick(out double dt);
public abstract bool GetSwipe(out double dt);
/// <summary>
/// Sets the player number (starts at 1, set to -1 or null for no player)

View file

@ -9,6 +9,7 @@ using HeavenStudio.InputSystem;
using static JSL;
using HeavenStudio.Games;
using System.Diagnostics.Contracts;
namespace HeavenStudio.InputSystem
{
@ -31,11 +32,13 @@ namespace HeavenStudio
public delegate bool ActionQuery(out double dt);
public string name;
public int[] inputLockCategory;
public ActionQuery padAction, touchAction, batonAction;
public InputAction(string name, ActionQuery pad, ActionQuery touch, ActionQuery baton)
public InputAction(string name, int[] inputLockCategory, ActionQuery pad, ActionQuery touch, ActionQuery baton)
{
this.name = name;
this.inputLockCategory = inputLockCategory;
padAction = pad;
touchAction = touch;
batonAction = baton;
@ -231,73 +234,115 @@ namespace HeavenStudio
public static bool GetPadDown(InputController.ActionsPad ac, out double dt)
{
bool a = GetInputController(1).GetActionDown(InputController.ControlStyles.Pad, (int)ac, out dt);
return a && !GameManager.instance.autoplay && Conductor.instance.isPlaying && GameManager.instance.canInput;
return a && PlayerHasControl();
}
public static bool GetPadDown(InputController.ActionsPad ac)
{
bool a = GetInputController(1).GetActionDown(InputController.ControlStyles.Pad, (int)ac, out _);
return a && !GameManager.instance.autoplay && Conductor.instance.isPlaying && GameManager.instance.canInput;
return a && PlayerHasControl();
}
public static bool GetPadUp(InputController.ActionsPad ac, out double dt)
{
bool a = GetInputController(1).GetActionUp(InputController.ControlStyles.Pad, (int)ac, out dt);
return a && !GameManager.instance.autoplay && Conductor.instance.isPlaying && GameManager.instance.canInput;
return a && PlayerHasControl();
}
public static bool GetPadUp(InputController.ActionsPad ac)
{
bool a = GetInputController(1).GetActionUp(InputController.ControlStyles.Pad, (int)ac, out _);
return a && !GameManager.instance.autoplay && Conductor.instance.isPlaying && GameManager.instance.canInput;
return a && PlayerHasControl();
}
public static bool GetPad(InputController.ActionsPad ac)
{
bool a = GetInputController(1).GetAction(InputController.ControlStyles.Pad, (int)ac);
return a && !GameManager.instance.autoplay && Conductor.instance.isPlaying && GameManager.instance.canInput;
return a && PlayerHasControl();
}
public static bool GetTouchDown(InputController.ActionsPad ac, out double dt)
public static bool GetBatonDown(InputController.ActionsBaton ac, out double dt)
{
bool a = GetInputController(1).GetActionDown(InputController.ControlStyles.Baton, (int)ac, out dt);
return a && PlayerHasControl();
}
public static bool GetBatonDown(InputController.ActionsBaton ac)
{
bool a = GetInputController(1).GetActionDown(InputController.ControlStyles.Baton, (int)ac, out _);
return a && PlayerHasControl();
}
public static bool GetBatonUp(InputController.ActionsBaton ac, out double dt)
{
bool a = GetInputController(1).GetActionUp(InputController.ControlStyles.Baton, (int)ac, out dt);
return a && PlayerHasControl();
}
public static bool GetBatonUp(InputController.ActionsBaton ac)
{
bool a = GetInputController(1).GetActionUp(InputController.ControlStyles.Baton, (int)ac, out _);
return a && PlayerHasControl();
}
public static bool GetBaton(InputController.ActionsBaton ac)
{
bool a = GetInputController(1).GetAction(InputController.ControlStyles.Baton, (int)ac);
return a && PlayerHasControl();
}
public static bool GetTouchDown(InputController.ActionsTouch ac, out double dt)
{
bool a = GetInputController(1).GetActionDown(InputController.ControlStyles.Touch, (int)ac, out dt);
return a && !GameManager.instance.autoplay && Conductor.instance.isPlaying && GameManager.instance.canInput;
return a && PlayerHasControl();
}
public static bool GetTouchDown(InputController.ActionsPad ac)
public static bool GetTouchDown(InputController.ActionsTouch ac)
{
bool a = GetInputController(1).GetActionDown(InputController.ControlStyles.Touch, (int)ac, out _);
return a && !GameManager.instance.autoplay && Conductor.instance.isPlaying && GameManager.instance.canInput;
return a && PlayerHasControl();
}
public static bool GetTouchUp(InputController.ActionsPad ac, out double dt)
public static bool GetTouchUp(InputController.ActionsTouch ac, out double dt)
{
bool a = GetInputController(1).GetActionUp(InputController.ControlStyles.Touch, (int)ac, out dt);
return a && !GameManager.instance.autoplay && Conductor.instance.isPlaying && GameManager.instance.canInput;
return a && PlayerHasControl();
}
public static bool GetTouchUp(InputController.ActionsPad ac)
public static bool GetTouchUp(InputController.ActionsTouch ac)
{
bool a = GetInputController(1).GetActionUp(InputController.ControlStyles.Touch, (int)ac, out _);
return a && !GameManager.instance.autoplay && Conductor.instance.isPlaying && GameManager.instance.canInput;
return a && PlayerHasControl();
}
public static bool GetTouch(InputController.ActionsTouch ac)
{
bool a = GetInputController(1).GetAction(InputController.ControlStyles.Touch, (int)ac);
return a && !GameManager.instance.autoplay && Conductor.instance.isPlaying && GameManager.instance.canInput;
return a && PlayerHasControl();
}
public static bool GetSwipe()
{
bool a = false;
return a && !GameManager.instance.autoplay && Conductor.instance.isPlaying && GameManager.instance.canInput;
bool a = GetInputController(1).GetSwipe(out _);
return a && PlayerHasControl();
}
public static bool GetSwipe(out double dt)
{
bool a = GetInputController(1).GetSwipe(out dt);
return a && PlayerHasControl();
}
public static bool GetFlick()
{
bool a = false;
return a && !GameManager.instance.autoplay && Conductor.instance.isPlaying && GameManager.instance.canInput;
bool a = GetInputController(1).GetFlick(out _);
return a && PlayerHasControl();
}
public static bool GetFlick(out double dt)
{
bool a = GetInputController(1).GetFlick(out dt);
return a && PlayerHasControl();
}
#region Deprecated Input Methods
@ -305,35 +350,35 @@ namespace HeavenStudio
public static bool Pressed()
{
bool keyDown = GetInputController(1).GetActionDown(InputController.ControlStyles.Pad, (int)InputController.ActionsPad.East, out _);
return keyDown && !GameManager.instance.autoplay && Conductor.instance.isPlaying && GameManager.instance.canInput;
return keyDown && PlayerHasControl();
}
[Obsolete("Use GetPadDown instead")]
public static bool Pressed(out double dt)
{
bool keyDown = GetInputController(1).GetActionDown(InputController.ControlStyles.Pad, (int)InputController.ActionsPad.East, out dt);
return keyDown && !GameManager.instance.autoplay && Conductor.instance.isPlaying && GameManager.instance.canInput;
return keyDown && PlayerHasControl();
}
[Obsolete("Use GetPadUp instead")]
public static bool PressedUp()
{
bool keyUp = GetInputController(1).GetActionUp(InputController.ControlStyles.Pad, (int)InputController.ActionsPad.East, out _);
return keyUp && !GameManager.instance.autoplay && Conductor.instance.isPlaying && GameManager.instance.canInput;
return keyUp && PlayerHasControl();
}
[Obsolete("Use GetPadUp instead")]
public static bool PressedUp(out double dt)
{
bool keyUp = GetInputController(1).GetActionUp(InputController.ControlStyles.Pad, (int)InputController.ActionsPad.East, out dt);
return keyUp && !GameManager.instance.autoplay && Conductor.instance.isPlaying && GameManager.instance.canInput;
return keyUp && PlayerHasControl();
}
[Obsolete("Use GetPad instead")]
public static bool Pressing()
{
bool pressing = GetInputController(1).GetAction(InputController.ControlStyles.Pad, (int)InputController.ActionsPad.East);
return pressing && !GameManager.instance.autoplay && Conductor.instance.isPlaying && GameManager.instance.canInput;
return pressing && PlayerHasControl();
}
[Obsolete("Use GetPadDown instead")]

View file

@ -13,12 +13,12 @@ public class ScaleByVelocity : MonoBehaviour
private Vector2 startScale;
private void Start ()
private void Start()
{
startScale = transform.localScale;
}
private void Update ()
private void Update()
{
var velocity = rigidbody.velocity.magnitude;
@ -28,15 +28,15 @@ public class ScaleByVelocity : MonoBehaviour
var amount = velocity * strength + bias;
var inverseAmount = 1.0f;
if (velocity > 0.4f)
inverseAmount = (1f / amount) * startScale.magnitude;
inverseAmount = (1f / amount) * startScale.magnitude;
switch (axis)
{
case Axis.X:
transform.localScale = new Vector3 (amount - 0.414214f, inverseAmount, 1f);
transform.localScale = new Vector3(amount - 0.414214f, inverseAmount, 1f);
return;
case Axis.Y:
transform.localScale = new Vector3 (Mathf.Clamp(inverseAmount, 0.6f, 1f), amount, 1f);
transform.localScale = new Vector3(Mathf.Clamp(inverseAmount, 0.6f, 1f), amount, 1f);
return;
}
}