Added sprint mechanic, unified options menu
This commit is contained in:
@@ -109,7 +109,7 @@
|
||||
"name": "Pause",
|
||||
"type": "Button",
|
||||
"id": "42da73ec-1cff-4563-a69e-b79d164ae159",
|
||||
"expectedControlType": "Button",
|
||||
"expectedControlType": "",
|
||||
"processors": "",
|
||||
"interactions": "",
|
||||
"initialStateCheck": false
|
||||
@@ -488,10 +488,19 @@
|
||||
"name": "Disarm",
|
||||
"type": "Button",
|
||||
"id": "6e5b6b66-b604-4710-a089-8200ee206c2c",
|
||||
"expectedControlType": "Button",
|
||||
"expectedControlType": "",
|
||||
"processors": "",
|
||||
"interactions": "",
|
||||
"initialStateCheck": false
|
||||
},
|
||||
{
|
||||
"name": "Sprint",
|
||||
"type": "Button",
|
||||
"id": "a9a4e469-311f-40ed-a560-7b4b5ae29f2d",
|
||||
"expectedControlType": "",
|
||||
"processors": "",
|
||||
"interactions": "Press(behavior=2)",
|
||||
"initialStateCheck": false
|
||||
}
|
||||
],
|
||||
"bindings": [
|
||||
@@ -846,6 +855,28 @@
|
||||
"action": "Disarm",
|
||||
"isComposite": false,
|
||||
"isPartOfComposite": false
|
||||
},
|
||||
{
|
||||
"name": "",
|
||||
"id": "916e6712-71f4-42bb-97c6-6d6cc298a30d",
|
||||
"path": "<Keyboard>/shift",
|
||||
"interactions": "",
|
||||
"processors": "",
|
||||
"groups": ";KeyboardMouse",
|
||||
"action": "Sprint",
|
||||
"isComposite": false,
|
||||
"isPartOfComposite": false
|
||||
},
|
||||
{
|
||||
"name": "",
|
||||
"id": "f5ab043c-757b-4fde-8cb8-a59c7a858b00",
|
||||
"path": "<Gamepad>/leftStick/down",
|
||||
"interactions": "",
|
||||
"processors": "",
|
||||
"groups": "",
|
||||
"action": "Sprint",
|
||||
"isComposite": false,
|
||||
"isPartOfComposite": false
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
9393
Assets/Prefabs/Options.prefab
Normal file
9393
Assets/Prefabs/Options.prefab
Normal file
File diff suppressed because it is too large
Load Diff
7
Assets/Prefabs/Options.prefab.meta
Normal file
7
Assets/Prefabs/Options.prefab.meta
Normal file
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 91c2fdde83c3c85bc9b4c24377975e1e
|
||||
PrefabImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -32,6 +32,7 @@ public class Controls : MonoBehaviour
|
||||
|
||||
private float minPitch = -75f;
|
||||
private float maxPitch = 80f;
|
||||
private bool isSprinting = false;
|
||||
|
||||
void Start()
|
||||
{
|
||||
@@ -58,7 +59,7 @@ public class Controls : MonoBehaviour
|
||||
}
|
||||
if (uihandler.canPlayerMove())
|
||||
{
|
||||
ControlEvents.Move(input);
|
||||
ControlEvents.Move(input, isSprinting);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -132,7 +133,11 @@ public class Controls : MonoBehaviour
|
||||
direction = MoveDirection.Up;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void OnSprint(InputValue value)
|
||||
{
|
||||
isSprinting = value.isPressed;
|
||||
}
|
||||
|
||||
public void OnInteraction()
|
||||
|
||||
@@ -3,15 +3,15 @@ using UnityEngine;
|
||||
public static class ControlEvents
|
||||
{
|
||||
public static event System.Action<float, float> OnLookingInput;
|
||||
public static event System.Action<Vector3> OnMovingInput;
|
||||
public static event System.Action<Vector3, bool> OnMovingInput;
|
||||
|
||||
public static void Look(float pitch, float yaw)
|
||||
{
|
||||
OnLookingInput?.Invoke(pitch, yaw);
|
||||
}
|
||||
|
||||
public static void Move(Vector3 force)
|
||||
public static void Move(Vector3 force, bool isSprinting)
|
||||
{
|
||||
OnMovingInput?.Invoke(force);
|
||||
OnMovingInput?.Invoke(force, isSprinting);
|
||||
}
|
||||
}
|
||||
@@ -135,10 +135,6 @@ namespace Assets.Scripts
|
||||
fight.GetComponent<Fight>().playerAction(index);
|
||||
}
|
||||
|
||||
public void switchOptionView(string key){
|
||||
uihandler.showOptionView(key);
|
||||
}
|
||||
|
||||
public void closeTutorial(){
|
||||
uihandler.closeTutorial();
|
||||
}
|
||||
|
||||
@@ -120,8 +120,6 @@ namespace Assets.Scripts
|
||||
FileHandler.loadOptionDisplay();
|
||||
hideOtherElements(options);
|
||||
state = UIState.PAUSEOPTIONS;
|
||||
EventSystem.current.SetSelectedGameObject(GameObject.Find("btnAudio"));
|
||||
showOptionView("audio");
|
||||
}
|
||||
|
||||
public void closeOptions()
|
||||
@@ -525,22 +523,6 @@ namespace Assets.Scripts
|
||||
state = UIState.GAME;
|
||||
}
|
||||
|
||||
public void showOptionView(string key)
|
||||
{
|
||||
GameObject optionContent = GameObject.Find("pnlContent");
|
||||
for (int i = 0; i < optionContent.transform.childCount; i++)
|
||||
{
|
||||
if (optionContent.transform.GetChild(i).name.ToLower().Contains(key))
|
||||
{
|
||||
optionContent.transform.GetChild(i).transform.localScale = new Vector3(1, 1, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
optionContent.transform.GetChild(i).transform.localScale = new Vector3(0, 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void switchLanguage()
|
||||
{
|
||||
GameObject language = GameObject.Find("dropLanguage");
|
||||
|
||||
@@ -165,7 +165,7 @@ namespace Assets.Scripts.Player
|
||||
return new PlayerObject(name, playerRace, playerClass, difficulty);
|
||||
}
|
||||
|
||||
public void move(Vector3 input)
|
||||
public void move(Vector3 input, bool isSprinting)
|
||||
{
|
||||
if(gameObject.GetComponent<Rigidbody>().linearVelocity.y <= 0.1f && gameObject.GetComponent<Rigidbody>().linearVelocity.y >= -0.1f){
|
||||
jumpFrameCounter++;
|
||||
@@ -185,8 +185,9 @@ namespace Assets.Scripts.Player
|
||||
}
|
||||
}
|
||||
Vector3 movement = new Vector3(input.x, 0, input.z);
|
||||
gameObject.transform.Translate(movement * speed * Time.deltaTime);
|
||||
gameObject.GetComponent<Animator>().SetFloat("velocity", (movement * speed).z);
|
||||
Vector3 force = movement * speed * (isSprinting ? 2f : 1f);
|
||||
gameObject.transform.Translate(force * Time.deltaTime);
|
||||
gameObject.GetComponent<Animator>().SetFloat("velocity", force.z);
|
||||
GameObject.Find("QuestLog").GetComponent<QuestLog>().updateQuests("explore", gameObject, 1);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user