btsds InputAction

This commit is contained in:
minenice55 2023-09-18 15:53:55 -04:00
parent df5c1ddf93
commit fefde12bc2
4 changed files with 47 additions and 67 deletions

View file

@ -30,7 +30,7 @@ namespace HeavenStudio.Games.Scripts_BuiltToScaleDS
hitBeat = windupBeat + createLength; hitBeat = windupBeat + createLength;
sinkBeat = hitBeat + (createLength * 2f); sinkBeat = hitBeat + (createLength * 2f);
game.ScheduleInput(windupBeat, createLength, InputType.STANDARD_DOWN, Just, Miss, Out); game.ScheduleInput(windupBeat, createLength, BuiltToScaleDS.InputAction_FlickPress, Just, Miss, Out);
} }
private void Update() private void Update()
@ -39,7 +39,8 @@ namespace HeavenStudio.Games.Scripts_BuiltToScaleDS
double currentBeat = Conductor.instance.songPositionInBeatsAsDouble; double currentBeat = Conductor.instance.songPositionInBeatsAsDouble;
var shooterState = game.shooterAnim.GetCurrentAnimatorStateInfo(0); var shooterState = game.shooterAnim.GetCurrentAnimatorStateInfo(0);
if (currentBeat > windupBeat && currentBeat < hitBeat if ((PlayerInput.CurrentControlStyle != InputSystem.InputController.ControlStyles.Touch || !PlayerInput.PlayerHasControl())
&& currentBeat > windupBeat && currentBeat < hitBeat
&& !shooterState.IsName("Windup") && !shooterState.IsName("Windup")
&& !game.lastShotOut) && !game.lastShotOut)
{ {
@ -52,9 +53,6 @@ namespace HeavenStudio.Games.Scripts_BuiltToScaleDS
private void Just(PlayerActionEvent caller, float state) private void Just(PlayerActionEvent caller, float state)
{ {
var shooterState = game.shooterAnim.GetCurrentAnimatorStateInfo(0);
if (!shooterState.IsName("Windup")) return;
// near miss // near miss
if (state >= 1f || state <= -1f) { if (state >= 1f || state <= -1f) {
NearMiss(); NearMiss();

View file

@ -258,6 +258,7 @@ namespace HeavenStudio.Games
List<RiqEntity> spawnedBlockEvents = new List<RiqEntity>(); List<RiqEntity> spawnedBlockEvents = new List<RiqEntity>();
void Update() void Update()
{ {
shootingThisFrame = false;
if (!Conductor.instance.isPlaying && !Conductor.instance.isPaused) if (!Conductor.instance.isPlaying && !Conductor.instance.isPaused)
return; return;
@ -283,21 +284,13 @@ namespace HeavenStudio.Games
HandleLights(); HandleLights();
} }
currentBeltOffset = (currentBeltOffset + Time.deltaTime * -beltSpeed) % 1f;
beltMaterial.mainTextureOffset = new Vector2(0f, currentBeltOffset);
environmentRenderer.materials = environmentMaterials;
elevatorRenderer.materials = elevatorMaterials;
}
void LateUpdate()
{
var shooterState = shooterAnim.GetCurrentAnimatorStateInfo(0); var shooterState = shooterAnim.GetCurrentAnimatorStateInfo(0);
bool canShoot = (!shooterState.IsName("Shoot") || shooterAnim.IsAnimationNotPlaying()) && !shootingThisFrame; bool canShoot = (!shooterState.IsName("Shoot") || shooterAnim.IsAnimationNotPlaying()) && !shootingThisFrame;
if (canShoot && lastShotOut) if (canShoot && lastShotOut)
lastShotOut = false; lastShotOut = false;
if (canShoot && !lastShotOut && PlayerInput.Pressed() && !IsExpectingInputNow(InputType.STANDARD_DOWN)) if (canShoot && !lastShotOut && PlayerInput.GetIsAction(InputAction_FlickPress, out _) && !IsExpectingInputNow(InputAction_FlickPress.inputLockCategory))
{ {
lastShotOut = true; lastShotOut = true;
shootingThisFrame = true; shootingThisFrame = true;
@ -306,15 +299,36 @@ namespace HeavenStudio.Games
SoundByte.PlayOneShotGame("builtToScaleDS/Boing"); SoundByte.PlayOneShotGame("builtToScaleDS/Boing");
} }
if (!shootingThisFrame) currentBeltOffset = (currentBeltOffset + Time.deltaTime * -beltSpeed) % 1f;
beltMaterial.mainTextureOffset = new Vector2(0f, currentBeltOffset);
environmentRenderer.materials = environmentMaterials;
elevatorRenderer.materials = elevatorMaterials;
if (PlayerInput.PlayerHasControl() && PlayerInput.CurrentControlStyle is InputSystem.InputController.ControlStyles.Touch)
{ {
if (blocksHolder.childCount == 0 && shooterState.IsName("Windup") && shooterAnim.IsAnimationNotPlaying()) if (PlayerInput.GetIsAction(InputAction_BasicPress, out _))
{ {
shooterAnim.Play("WindDown", 0, 0); shooterAnim.Play("Windup", 0, 0);
}
if (PlayerInput.GetIsAction(InputAction_BasicRelease, out _) && !shootingThisFrame)
{
shooterAnim.Play("WindDown", 0, 23 / 28f);
} }
} }
else
{
if (!shootingThisFrame)
{
if (blocksHolder.childCount == 0 && shooterState.IsName("Windup") && shooterAnim.IsAnimationNotPlaying())
{
shooterAnim.Play("WindDown", 0, 0);
}
}
}
}
shootingThisFrame = false; void LateUpdate()
{
} }
public void Lights(double beat, float length, bool autoLights, bool shouldLights) public void Lights(double beat, float length, bool autoLights, bool shouldLights)

View file

@ -104,7 +104,7 @@ namespace HeavenStudio.InputSystem
float speed = deltaPointerPos.magnitude; float speed = deltaPointerPos.magnitude;
if (GetAction(ControlStyles.Touch, 0)) if (GetAction(ControlStyles.Touch, 0))
{ {
Debug.Log($"pointer speed: {deltaPointerPos.magnitude}, direction: {deltaPointerPos.normalized}"); // Debug.Log($"pointer speed: {deltaPointerPos.magnitude}, direction: {deltaPointerPos.normalized}");
if (speed >= BigMoveMarginSpd) if (speed >= BigMoveMarginSpd)
{ {
timeMoveChange = Time.realtimeSinceStartupAsDouble; timeMoveChange = Time.realtimeSinceStartupAsDouble;
@ -112,14 +112,14 @@ namespace HeavenStudio.InputSystem
{ {
isInMove = true; isInMove = true;
hasSwiped = true; hasSwiped = true;
Debug.Log($"just started moving or direction change"); // Debug.Log($"just started moving or direction change");
} }
} }
else else
{ {
if (isInMove && speed < SmallMoveMarginSpd) if (isInMove && speed < SmallMoveMarginSpd)
{ {
Debug.Log($"just stopped moving"); // Debug.Log($"just stopped moving");
isInMove = false; isInMove = false;
} }
} }
@ -133,10 +133,10 @@ namespace HeavenStudio.InputSystem
lastRealPos = realPos; lastRealPos = realPos;
lastDeltaPointerPos = deltaPointerPos; lastDeltaPointerPos = deltaPointerPos;
hasFlicked = dMoveChange < FlickMarginTime && speed >= BigMoveMarginSpd; hasFlicked = dMoveChange < FlickMarginTime && speed >= BigMoveMarginSpd;
if (hasFlicked) // if (hasFlicked)
{ // {
Debug.Log($"flicked (speed: {dMoveChange})"); // Debug.Log($"flicked (speed: {dMoveChange})");
} // }
} }
} }
@ -332,55 +332,19 @@ namespace HeavenStudio.InputSystem
//todo: directionals //todo: directionals
public override bool GetHatDirection(InputDirection direction) public override bool GetHatDirection(InputDirection direction)
{ {
switch (direction) return false;
{
case InputDirection.Up:
return Input.GetKey((KeyCode)currentBindings.Pad[0]);
case InputDirection.Down:
return Input.GetKey((KeyCode)currentBindings.Pad[1]);
case InputDirection.Left:
return Input.GetKey((KeyCode)currentBindings.Pad[2]);
case InputDirection.Right:
return Input.GetKey((KeyCode)currentBindings.Pad[3]);
default:
return false;
}
} }
public override bool GetHatDirectionDown(InputDirection direction, out double dt) public override bool GetHatDirectionDown(InputDirection direction, out double dt)
{ {
dt = 0; dt = 0;
switch (direction) return false;
{
case InputDirection.Up:
return Input.GetKeyDown((KeyCode)currentBindings.Pad[0]);
case InputDirection.Down:
return Input.GetKeyDown((KeyCode)currentBindings.Pad[1]);
case InputDirection.Left:
return Input.GetKeyDown((KeyCode)currentBindings.Pad[2]);
case InputDirection.Right:
return Input.GetKeyDown((KeyCode)currentBindings.Pad[3]);
default:
return false;
}
} }
public override bool GetHatDirectionUp(InputDirection direction, out double dt) public override bool GetHatDirectionUp(InputDirection direction, out double dt)
{ {
dt = 0; dt = 0;
switch (direction) return false;
{
case InputDirection.Up:
return Input.GetKeyUp((KeyCode)currentBindings.Pad[0]);
case InputDirection.Down:
return Input.GetKeyUp((KeyCode)currentBindings.Pad[1]);
case InputDirection.Left:
return Input.GetKeyUp((KeyCode)currentBindings.Pad[2]);
case InputDirection.Right:
return Input.GetKeyUp((KeyCode)currentBindings.Pad[3]);
default:
return false;
}
} }
public override void SetPlayer(int? playerNum) public override void SetPlayer(int? playerNum)

View file

@ -438,9 +438,12 @@ namespace HeavenStudio.Editor
MainCanvas.enabled = false; MainCanvas.enabled = false;
EditorCamera.enabled = false; EditorCamera.enabled = false;
GameManager.instance.StaticCamera.targetTexture = null; GameManager.instance.StaticCamera.targetTexture = null;
GameManager.instance.CursorCam.enabled = false; GameManager.instance.CursorCam.enabled = (PlayerInput.CurrentControlStyle == InputSystem.InputController.ControlStyles.Touch)
&& isCursorEnabled;
GameManager.instance.CursorCam.targetTexture = null;
GameManager.instance.CursorCam.rect = new Rect(0, 0, 1, 1);
fullscreen = true; fullscreen = true;
} }
else else
{ {
@ -448,6 +451,7 @@ namespace HeavenStudio.Editor
EditorCamera.enabled = true; EditorCamera.enabled = true;
GameManager.instance.StaticCamera.targetTexture = ScreenRenderTexture; GameManager.instance.StaticCamera.targetTexture = ScreenRenderTexture;
GameManager.instance.CursorCam.enabled = true && isCursorEnabled; GameManager.instance.CursorCam.enabled = true && isCursorEnabled;
GameManager.instance.CursorCam.targetTexture = ScreenRenderTexture;
fullscreen = false; fullscreen = false;
GameCamera.instance.camera.rect = new Rect(0, 0, 1, 1); GameCamera.instance.camera.rect = new Rect(0, 0, 1, 1);