better keyboard input

This commit is contained in:
LadyEbony 2020-08-22 14:49:44 -07:00
parent b39e39ec6c
commit e64deabf8a
2 changed files with 59 additions and 5 deletions

View File

@ -222,13 +222,57 @@ public class GameBoard : EntityBase, IAutoSerialize, IAutoDeserialize {
public bool awaitingNeutral; public bool awaitingNeutral;
public static float inputThreshold = 0.3f; public static float inputThreshold = 0.3f;
private bool useKeyboard;
private bool GetInputStyle(){
var key = Input.anyKey;
var h = Input.GetAxisRaw("Horizontal");
var v = Input.GetAxisRaw("Rotate");
if (key){
return true;
} else if (h != 0f || v != 0f){
return false;
}
return useKeyboard;
}
public void PlayerInput() { public void PlayerInput() {
float rightIntent = Input.GetAxisRaw("Horizontal");
float upIntent = Input.GetAxisRaw("Rotate"); useKeyboard = GetInputStyle();
float rightIntent;
float upIntent;
bool skipNeutal;
// involved fix for better pc play
if (useKeyboard){
rightIntent = 0f;
upIntent = 0f;
if (Input.GetKeyDown(KeyCode.LeftArrow))
rightIntent = -1f;
if (Input.GetKeyDown(KeyCode.RightArrow))
rightIntent = 1f;
if (Input.GetKeyDown(KeyCode.UpArrow))
upIntent = 1f;
if (Input.GetKeyDown(KeyCode.DownArrow))
upIntent = -1f;
skipNeutal = false;
} else {
rightIntent = Input.GetAxisRaw("Horizontal");
upIntent = Input.GetAxisRaw("Rotate");
skipNeutal = true;
}
var max = Mathf.Max(Mathf.Abs(rightIntent), Mathf.Abs(upIntent)); var max = Mathf.Max(Mathf.Abs(rightIntent), Mathf.Abs(upIntent));
if (max > 0.3f) { if (max > 0.3f) {
if (!awaitingNeutral) { if (!awaitingNeutral || skipNeutal) {
if (rightIntent > 0.2f) { if (rightIntent > 0.2f) {
dropColumn += 1; dropColumn += 1;
} else if (rightIntent < -0.2f) { } else if (rightIntent < -0.2f) {
@ -249,8 +293,9 @@ public class GameBoard : EntityBase, IAutoSerialize, IAutoDeserialize {
dropColumn = ClampRotatedPosition(playerRotation); dropColumn = ClampRotatedPosition(playerRotation);
dropHeight = playerRotation != 3 ? 12 : 13; // Shift the drop height based on rotation dropHeight = playerRotation != 3 ? 12 : 13; // Shift the drop height based on rotation
awaitingNeutral = true;
} }
awaitingNeutral = true;
} else { } else {
awaitingNeutral = false; awaitingNeutral = false;
} }

View File

@ -1542,6 +1542,15 @@ PrefabInstance:
m_Modification: m_Modification:
m_TransformParent: {fileID: 0} m_TransformParent: {fileID: 0}
m_Modifications: m_Modifications:
- target: {fileID: 482421870, guid: adba91609cb1e5448b76682be198fc9b, type: 3}
propertyPath: m_AnchoredPosition.y
value: 49.999878
objectReference: {fileID: 0}
- target: {fileID: 1736330633687387551, guid: adba91609cb1e5448b76682be198fc9b,
type: 3}
propertyPath: m_AnchoredPosition.y
value: 49.999878
objectReference: {fileID: 0}
- target: {fileID: 1736330635070797285, guid: adba91609cb1e5448b76682be198fc9b, - target: {fileID: 1736330635070797285, guid: adba91609cb1e5448b76682be198fc9b,
type: 3} type: 3}
propertyPath: m_Name propertyPath: m_Name