龙腾猫跃 4 vuotta sitten
vanhempi
sitoutus
ef54eb0a45

+ 22 - 0
Assets/Resources/Dice/DiceUI.cs

@@ -0,0 +1,22 @@
+using System.Collections;
+using System.Collections.Generic;
+using DG.Tweening;
+using UnityEngine;
+using UnityEngine.UI;
+
+public class DiceUI : MonoBehaviour {
+
+    private Image sprite;
+    public InputM.KeyType keybind;
+    void Start() {
+        sprite = GetComponent<Image>();
+    }
+
+    private bool isKeyDown = false;
+    void Update() {
+        if (isKeyDown == InputM.GetKeyUI(keybind)) return;
+        isKeyDown = !isKeyDown;
+        sprite.DOColor(isKeyDown ? new Color(49f / 255f, 38f / 255f, 31f / 255f, 1) : new Color(111f / 255f, 93f / 255f, 80f / 255f, 1), 0.05f);
+    }
+    
+}

+ 11 - 0
Assets/Resources/Dice/DiceUI.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 31114938d2d94a64c9d2b6e0aae609e2
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 4 - 5
Assets/Resources/Entities/PlayerController.cs

@@ -6,11 +6,10 @@ using UnityEngine;
 
 public class PlayerController : EntityBase {
 
-    public string keyLeft = "a", keyRight = "d", keyJump = "w", keyDown = "s";
-    internal override bool isPressingCrouch() => Input.GetKey(keyDown);
-    internal override bool isPressDownJump() => Input.GetKeyDown(keyJump);
-    internal override bool isPressingLeft() => Input.GetKey(keyLeft);
-    internal override bool isPressingRight() => Input.GetKey(keyRight);
+    internal override bool isPressingCrouch() => InputM.GetKeyEvent(InputM.KeyType.Crouch);
+    internal override bool isPressDownJump() => InputM.GetKeyEvent(InputM.KeyType.Jump);
+    internal override bool isPressingLeft() => InputM.GetKeyEvent(InputM.KeyType.Left);
+    internal override bool isPressingRight() => InputM.GetKeyEvent(InputM.KeyType.Right);
 
     internal override void OnHitBorder() {
         Hurt();

+ 1 - 1
Assets/Resources/Map/Background.png.meta

@@ -47,7 +47,7 @@ TextureImporter:
   spriteMeshType: 1
   alignment: 0
   spritePivot: {x: 0.5, y: 0.5}
-  spritePixelsToUnits: 25
+  spritePixelsToUnits: 23
   spriteBorder: {x: 0, y: 0, z: 0, w: 0}
   spriteGenerateFallbackPhysicsShape: 1
   alphaUsage: 1

+ 26 - 0
Assets/Resources/System/InputM.cs

@@ -0,0 +1,26 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+
+public static class InputM {
+    
+    public static string keyLeft = "a", keyRight = "d", keyJump = "w", keyCrouch = "s", keyFire = "l", keyReload = "r";
+    public static bool GetKeyUI(KeyType key) => key switch {
+        KeyType.Left => keyLeft == "l" ? Input.GetMouseButton(0) : (keyLeft == "r" ? Input.GetMouseButton(1) : Input.GetKey(keyLeft)),
+        KeyType.Right => keyRight == "l" ? Input.GetMouseButton(0) : (keyRight == "r" ? Input.GetMouseButton(1) : Input.GetKey(keyRight)),
+        KeyType.Jump => keyJump == "l" ? Input.GetMouseButton(0) : (keyJump == "r" ? Input.GetMouseButton(1) : Input.GetKey(keyJump)),
+        KeyType.Crouch => keyCrouch == "l" ? Input.GetMouseButton(0) : (keyCrouch == "r" ? Input.GetMouseButton(1) : Input.GetKey(keyCrouch)),
+        KeyType.Fire => keyFire == "l" ? Input.GetMouseButton(0) : (keyFire == "r" ? Input.GetMouseButton(1) : Input.GetKey(keyFire)),
+        _ => keyReload == "l" ? Input.GetMouseButton(0) : (keyReload == "r" ? Input.GetMouseButton(1) : Input.GetKey(keyReload)),
+    };
+    public static bool GetKeyEvent(KeyType key) => key switch {
+        KeyType.Left => keyLeft == "l" ? Input.GetMouseButton(0) : (keyLeft == "r" ? Input.GetMouseButton(1) : Input.GetKey(keyLeft)),
+        KeyType.Right => keyRight == "l" ? Input.GetMouseButton(0) : (keyRight == "r" ? Input.GetMouseButton(1) : Input.GetKey(keyRight)),
+        KeyType.Jump => keyJump == "l" ? Input.GetMouseButtonDown(0) : (keyJump == "r" ? Input.GetMouseButtonDown(1) : Input.GetKeyDown(keyJump)),
+        KeyType.Crouch => keyCrouch == "l" ? Input.GetMouseButton(0) : (keyCrouch == "r" ? Input.GetMouseButton(1) : Input.GetKey(keyCrouch)),
+        KeyType.Fire => keyFire == "l" ? Input.GetMouseButton(0) : (keyFire == "r" ? Input.GetMouseButton(1) : Input.GetKey(keyFire)),
+        _ => keyReload == "l" ? Input.GetMouseButtonDown(0) : (keyReload == "r" ? Input.GetMouseButtonDown(1) : Input.GetKeyDown(keyReload)),
+    };
+    public enum KeyType { Left, Right, Jump, Crouch, Fire, Reload }
+
+}

+ 11 - 0
Assets/Resources/System/InputM.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: c6a604d118c1a1048a8be03e40d92e94
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: