2024-08-13 21:11:05 +02:00
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using TMPro;
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
public class InputManagerScript : MonoBehaviour
|
|
|
|
{
|
|
|
|
|
|
|
|
// Input Options
|
|
|
|
[Header("Input")]
|
|
|
|
[SerializeField] private KeyCode moveRight;
|
|
|
|
[SerializeField] private KeyCode moveLeft;
|
|
|
|
[SerializeField] private KeyCode moveForward;
|
|
|
|
[SerializeField] private KeyCode moveBack;
|
|
|
|
[SerializeField] private KeyCode jump;
|
|
|
|
[SerializeField] private KeyCode shoot;
|
|
|
|
[SerializeField] private KeyCode reload;
|
|
|
|
|
|
|
|
// for the UI of button remaping
|
|
|
|
[SerializeField] private TextMeshProUGUI[] currentKeys;
|
|
|
|
|
|
|
|
// Update is called once per frame
|
|
|
|
void Update()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------- Get Input (for other Scripts) -----------------------------------------
|
|
|
|
public KeyCode getMoveRight()
|
|
|
|
{
|
|
|
|
return moveRight;
|
|
|
|
}
|
|
|
|
|
|
|
|
public KeyCode getMoveLeft()
|
|
|
|
{
|
|
|
|
return moveLeft;
|
|
|
|
}
|
|
|
|
|
|
|
|
public KeyCode getMoveForward()
|
|
|
|
{
|
|
|
|
return moveForward;
|
|
|
|
}
|
|
|
|
|
|
|
|
public KeyCode getMoveBack()
|
|
|
|
{
|
|
|
|
return moveBack;
|
|
|
|
}
|
|
|
|
|
|
|
|
public KeyCode getJump()
|
|
|
|
{
|
|
|
|
return jump;
|
|
|
|
}
|
|
|
|
|
|
|
|
public KeyCode getShoot()
|
|
|
|
{
|
|
|
|
return shoot;
|
|
|
|
}
|
|
|
|
|
|
|
|
public KeyCode getReload()
|
|
|
|
{
|
|
|
|
return reload;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------- Remap Buttons ----------------------------------------------------
|
|
|
|
public void remapKey(string actionName, KeyCode key) // remaps the action to the new Button and changes it in the UI (keybinding)
|
|
|
|
{
|
|
|
|
switch(actionName)
|
|
|
|
{
|
|
|
|
case "moveRight":
|
|
|
|
moveRight = key; // new Button
|
|
|
|
currentKeys[0].text = key.ToString();
|
|
|
|
break;
|
|
|
|
case "moveLeft":
|
|
|
|
moveLeft = key;
|
|
|
|
currentKeys[1].text = key.ToString();
|
|
|
|
break;
|
|
|
|
case "moveForward":
|
|
|
|
moveForward = key;
|
|
|
|
currentKeys[2].text = key.ToString();
|
|
|
|
break;
|
|
|
|
case "moveBack":
|
|
|
|
moveBack = key;
|
|
|
|
currentKeys[3].text = key.ToString();
|
|
|
|
break;
|
2024-08-21 12:44:54 +02:00
|
|
|
case "jump":
|
|
|
|
jump = key;
|
|
|
|
currentKeys[4].text = key.ToString();
|
|
|
|
break;
|
2024-08-13 21:11:05 +02:00
|
|
|
case "shoot":
|
|
|
|
shoot = key;
|
2024-08-21 12:44:54 +02:00
|
|
|
currentKeys[5].text = key.ToString();
|
2024-08-13 21:11:05 +02:00
|
|
|
break;
|
|
|
|
case "reload":
|
|
|
|
reload = key;
|
2024-08-21 12:44:54 +02:00
|
|
|
currentKeys[6].text = key.ToString();
|
2024-08-13 21:11:05 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|