Added sprint mechanic, unified options menu

This commit is contained in:
finnchen123
2026-02-15 11:40:42 +01:00
parent 55ba43401d
commit 395e58e45c
12 changed files with 11928 additions and 21072 deletions

View File

@@ -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()

View File

@@ -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);
}
}

View File

@@ -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();
}

View File

@@ -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");

View File

@@ -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);
}