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;
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()
@ -39,7 +39,8 @@ namespace HeavenStudio.Games.Scripts_BuiltToScaleDS
double currentBeat = Conductor.instance.songPositionInBeatsAsDouble;
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")
&& !game.lastShotOut)
{
@ -52,9 +53,6 @@ namespace HeavenStudio.Games.Scripts_BuiltToScaleDS
private void Just(PlayerActionEvent caller, float state)
{
var shooterState = game.shooterAnim.GetCurrentAnimatorStateInfo(0);
if (!shooterState.IsName("Windup")) return;
// near miss
if (state >= 1f || state <= -1f) {
NearMiss();

View file

@ -258,6 +258,7 @@ namespace HeavenStudio.Games
List<RiqEntity> spawnedBlockEvents = new List<RiqEntity>();
void Update()
{
shootingThisFrame = false;
if (!Conductor.instance.isPlaying && !Conductor.instance.isPaused)
return;
@ -283,21 +284,13 @@ namespace HeavenStudio.Games
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);
bool canShoot = (!shooterState.IsName("Shoot") || shooterAnim.IsAnimationNotPlaying()) && !shootingThisFrame;
if (canShoot && lastShotOut)
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;
shootingThisFrame = true;
@ -306,15 +299,36 @@ namespace HeavenStudio.Games
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)

View file

@ -104,7 +104,7 @@ namespace HeavenStudio.InputSystem
float speed = deltaPointerPos.magnitude;
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)
{
timeMoveChange = Time.realtimeSinceStartupAsDouble;
@ -112,14 +112,14 @@ namespace HeavenStudio.InputSystem
{
isInMove = true;
hasSwiped = true;
Debug.Log($"just started moving or direction change");
// Debug.Log($"just started moving or direction change");
}
}
else
{
if (isInMove && speed < SmallMoveMarginSpd)
{
Debug.Log($"just stopped moving");
// Debug.Log($"just stopped moving");
isInMove = false;
}
}
@ -133,10 +133,10 @@ namespace HeavenStudio.InputSystem
lastRealPos = realPos;
lastDeltaPointerPos = deltaPointerPos;
hasFlicked = dMoveChange < FlickMarginTime && speed >= BigMoveMarginSpd;
if (hasFlicked)
{
Debug.Log($"flicked (speed: {dMoveChange})");
}
// if (hasFlicked)
// {
// Debug.Log($"flicked (speed: {dMoveChange})");
// }
}
}
@ -332,55 +332,19 @@ namespace HeavenStudio.InputSystem
//todo: directionals
public override bool GetHatDirection(InputDirection direction)
{
switch (direction)
{
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;
}
return false;
}
public override bool GetHatDirectionDown(InputDirection direction, out double dt)
{
dt = 0;
switch (direction)
{
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;
}
return false;
}
public override bool GetHatDirectionUp(InputDirection direction, out double dt)
{
dt = 0;
switch (direction)
{
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;
}
dt = 0;
return false;
}
public override void SetPlayer(int? playerNum)

View file

@ -438,9 +438,12 @@ namespace HeavenStudio.Editor
MainCanvas.enabled = false;
EditorCamera.enabled = false;
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;
}
else
{
@ -448,6 +451,7 @@ namespace HeavenStudio.Editor
EditorCamera.enabled = true;
GameManager.instance.StaticCamera.targetTexture = ScreenRenderTexture;
GameManager.instance.CursorCam.enabled = true && isCursorEnabled;
GameManager.instance.CursorCam.targetTexture = ScreenRenderTexture;
fullscreen = false;
GameCamera.instance.camera.rect = new Rect(0, 0, 1, 1);