Added controls for gamepad, changed input & UI

This commit is contained in:
TAASONI3
2023-07-04 20:15:06 +02:00
parent 0b058f9248
commit 7aba856b17
48 changed files with 24176 additions and 15427 deletions

View File

@@ -12,6 +12,7 @@ namespace Assets.Scripts
Player player;
AudioHandler audioHandler;
WorldGenerator worldGenerator;
GameObject fight;
private void Start()
{
@@ -19,6 +20,7 @@ namespace Assets.Scripts
player = GameObject.Find("Player").GetComponent<Player>();
worldGenerator = GameObject.Find("WorldGenerator").GetComponent<WorldGenerator>();
audioHandler = GameObject.Find("AudioHandler").GetComponent<AudioHandler>();
fight = GameObject.Find("Fight");
}
public void openOptions()
@@ -49,35 +51,30 @@ namespace Assets.Scripts
{
audioHandler.playButtonClick();
player.upgradeStrength();
EventSystem.current.SetSelectedGameObject(null);
}
public void upgradeDexterity()
{
audioHandler.playButtonClick();
player.upgradeDexterity();
EventSystem.current.SetSelectedGameObject(null);
}
public void upgradeIntelligence()
{
audioHandler.playButtonClick();
player.upgradeIntelligence();
EventSystem.current.SetSelectedGameObject(null);
}
public void upgradeHealth()
{
audioHandler.playButtonClick();
player.upgradeHealth();
EventSystem.current.SetSelectedGameObject(null);
}
public void upgradeSecondary()
{
audioHandler.playButtonClick();
player.upgradeSecondary();
EventSystem.current.SetSelectedGameObject(null);
}
public void saveOptions()
@@ -86,8 +83,10 @@ namespace Assets.Scripts
audioHandler.playButtonClick();
saveText = saveText + uihandler.saveVideoSettings() + "\r\n";
saveText = saveText + audioHandler.saveAudioSettings() + "\r\n";
GameObject.Find("Main Camera").GetComponent<PlayerCamera>().speed = GameObject.Find("slideSensitivity").GetComponent<Slider>().value;
saveText = saveText + "Sensitivity:"+GameObject.Find("slideSensitivity").GetComponent<Slider>().value;
GameObject.Find("Main Camera").GetComponent<PlayerCamera>().mouseSpeed = GameObject.Find("slideSensitivityMouse").GetComponent<Slider>().value;
GameObject.Find("Main Camera").GetComponent<PlayerCamera>().controllerSpeed = GameObject.Find("slideSensitivityController").GetComponent<Slider>().value;
saveText = saveText + "SensitivityMouse:"+GameObject.Find("slideSensitivityMouse").GetComponent<Slider>().value + "\r\n";
saveText = saveText + "SensitivityController:"+GameObject.Find("slideSensitivityController").GetComponent<Slider>().value;
FileHandler.saveOptions(saveText);
uihandler.closeOptions();
}
@@ -96,7 +95,6 @@ namespace Assets.Scripts
{
audioHandler.playButtonClick();
uihandler.startGame();
EventSystem.current.SetSelectedGameObject(null);
}
public void switchCharactersheet()
@@ -135,5 +133,17 @@ namespace Assets.Scripts
saveString = saveString + "\r\n}";
FileHandler.saveGame(saveString, "./save.json");
}
public void castSkill(int index){
fight.GetComponent<Fight>().playerAction(index);
}
public void switchOptionView(string key){
uihandler.showOptionView(key);
}
public void closeTutorial(){
uihandler.closeTutorial();
}
}
}

View File

@@ -95,9 +95,14 @@ namespace Assets.Scripts
break;
}
break;
case "Sensitivity":
case "SensitivityMouse":
if(isIngame){
GameObject.Find("Main Camera").GetComponent<PlayerCamera>().speed = float.Parse(line.Split(':')[1]);
GameObject.Find("Main Camera").GetComponent<PlayerCamera>().mouseSpeed = float.Parse(line.Split(':')[1]);
}
break;
case "SensitivityController":
if(isIngame){
GameObject.Find("Main Camera").GetComponent<PlayerCamera>().controllerSpeed = float.Parse(line.Split(':')[1]);
}
break;
}
@@ -120,8 +125,11 @@ namespace Assets.Scripts
case "Mode":
GameObject.Find("dropMode").GetComponent<Dropdown>().value = int.Parse(line.Split(':')[1]);
break;
case "Sensitivity":
GameObject.Find("slideSensitivity").GetComponent<Slider>().value = float.Parse(line.Split(':')[1]);
case "SensitivityMouse":
GameObject.Find("slideSensitivityMouse").GetComponent<Slider>().value = float.Parse(line.Split(':')[1]);
break;
case "SensitivityController":
GameObject.Find("slideSensitivityController").GetComponent<Slider>().value = float.Parse(line.Split(':')[1]);
break;
}
}

View File

@@ -42,6 +42,9 @@ namespace Assets.Scripts
updatePlayerHUD();
switchWaterLayer();
updateCoordinates();
if(EventSystem.current.currentSelectedGameObject != null){
EventSystem.current.SetSelectedGameObject(null);
}
}
}
@@ -107,6 +110,7 @@ namespace Assets.Scripts
tutorial.transform.localScale = new Vector3(1, 1, 1);
showHUD();
state = UIState.TUTORIAL;
EventSystem.current.SetSelectedGameObject(GameObject.Find("btnCloseTutorial"));
}
public void switchCharactersheet()
@@ -127,7 +131,8 @@ namespace Assets.Scripts
FileHandler.loadOptionDisplay();
hideOtherElements(options);
state = UIState.PAUSEOPTIONS;
GameObject.Find("ScrollbarOptions").GetComponent<Scrollbar>().value = 1f;
EventSystem.current.SetSelectedGameObject(GameObject.Find("btnAudio"));
showOptionView("audio");
}
public void closeOptions()
@@ -141,6 +146,9 @@ namespace Assets.Scripts
{
hideOtherElements(charactersheet);
state = UIState.CHARACTER;
if(GameObject.Find("btnStrengthIncrease").transform.localScale != new Vector3(0,0,0)){
EventSystem.current.SetSelectedGameObject(GameObject.Find("btnStrengthIncrease"));
}
}
public void closeCharactersheet()
@@ -166,12 +174,13 @@ namespace Assets.Scripts
{
hideOtherElements(inventory);
state = UIState.INVENTORY;
EventSystem.current.SetSelectedGameObject(GameObject.Find("bagOne"));
}
public void closeInventory()
{
inventory.GetComponent<Inventory>().OnMouseUp();
inventory.transform.localScale = new Vector3(0, 0, 0);
GameObject.Find("pnlInventoryActions").transform.localScale = new Vector3(0,0,0);
showHUD();
state = UIState.GAME;
}
@@ -242,6 +251,7 @@ namespace Assets.Scripts
questlog.GetComponent<QuestLog>().showQuests();
state = UIState.QUEST;
hideOtherElements(questlog);
EventSystem.current.SetSelectedGameObject(GameObject.Find("scrollQuestlog"));
}
public void closeQuestLog()
@@ -298,6 +308,7 @@ namespace Assets.Scripts
{
hideOtherElements(pauseMenu);
state = UIState.PAUSE;
EventSystem.current.SetSelectedGameObject(GameObject.Find("btnContinue"));
}
public void closePauseMenu()
@@ -311,6 +322,7 @@ namespace Assets.Scripts
{
state = UIState.DEATH;
hideOtherElements(deathscreen);
EventSystem.current.SetSelectedGameObject(GameObject.Find("btnMenu"));
}
public void hideOtherElements(GameObject obj)
@@ -358,9 +370,9 @@ namespace Assets.Scripts
private void updateFightInterfaceActions(GameObject player)
{
GameObject actionFour = GameObject.Find("action4");
GameObject actionFive = GameObject.Find("action5");
GameObject actionSix = GameObject.Find("action6");
GameObject actionFour = GameObject.Find("btnActionFour");
GameObject actionFive = GameObject.Find("btnActionFive");
GameObject actionSix = GameObject.Find("btnActionSix");
player.GetComponent<Player>().displayAction(0, actionFour.transform.Find("imgAction").gameObject, actionFour.transform.Find("descAction").gameObject);
player.GetComponent<Player>().displayAction(1, actionFive.transform.Find("imgAction").gameObject, actionFive.transform.Find("descAction").gameObject);
@@ -533,6 +545,7 @@ namespace Assets.Scripts
GameObject.Find("Player").GetComponent<Player>().finishPlayerCreation();
hideOtherElements(introduction);
state = UIState.INTRODUCTION;
EventSystem.current.SetSelectedGameObject(GameObject.Find("btnClose"));
}
else
{
@@ -551,5 +564,17 @@ namespace Assets.Scripts
tutorial.transform.localScale = new Vector3(0,0,0);
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);
}
}
}
}
}