fixed controls, texts and added image, v1.4.1

This commit is contained in:
TAASONI3
2023-07-05 17:42:35 +02:00
parent 0dc2ff831f
commit d0d9a6847a
33 changed files with 11964 additions and 405 deletions

View File

@@ -40,6 +40,9 @@ public class Controls : MonoBehaviour
if(Cursor.lockState != CursorLockMode.Locked){
Cursor.lockState = CursorLockMode.Locked;
}
GameObject.Find("txtInteract").GetComponent<Text>().text = GameObject.Find("txtInteract").GetComponent<Text>().text.Replace("[E]", "[ButtonEast]");
GameObject.Find("txtInteraction_Tutorial").GetComponent<Text>().text = GameObject.Find("txtInteraction_Tutorial").GetComponent<Text>().text.Replace("[E]", "[ButtonEast]");
GameObject.Find("txtTutorialGoal").GetComponent<Text>().text = GameObject.Find("txtTutorialGoal").GetComponent<Text>().text.Replace("[ESC]", "[Start]");
}
else{
if(uihandler.canPlayerRotate()){
@@ -48,6 +51,9 @@ public class Controls : MonoBehaviour
else{
Cursor.lockState = CursorLockMode.Confined;
}
GameObject.Find("txtInteract").GetComponent<Text>().text = GameObject.Find("txtInteract").GetComponent<Text>().text.Replace("[ButtonEast]", "[E]");
GameObject.Find("txtInteraction_Tutorial").GetComponent<Text>().text = GameObject.Find("txtInteraction_Tutorial").GetComponent<Text>().text.Replace("[E]", "[ButtonEast]");
GameObject.Find("txtTutorialGoal").GetComponent<Text>().text = GameObject.Find("txtTutorialGoal").GetComponent<Text>().text.Replace("[Start]", "[ESC]");
}
if(uihandler.state == UIState.GAME && playerInput.currentActionMap.name != "MainGame"){
playerInput.SwitchCurrentActionMap("MainGame");

View File

@@ -20,8 +20,6 @@ public class AudioHandler : MonoBehaviour
AudioSource cameraAudio;
AudioSource playerAudio;
string filepath = "./audiosettings.txt";
// Start is called before the first frame update
public void Start()
{
@@ -118,8 +116,8 @@ public class AudioHandler : MonoBehaviour
string result = "";
float music = GameObject.Find("slideMusic").GetComponent<Slider>().value;
float effects = GameObject.Find("slideEffects").GetComponent<Slider>().value;
result = result + TextHandler.getText("music") + ": " + music + "\r\n";
result = result + TextHandler.getText("effects") + ": " + effects;
result = result + TextHandler.getText("music") + ":" + music + "\r\n";
result = result + TextHandler.getText("effects") + ":" + effects;
return result;
}
}

View File

@@ -82,6 +82,7 @@ namespace Assets.Scripts
string saveText = "";
audioHandler.playButtonClick();
saveText = saveText + uihandler.saveVideoSettings() + "\r\n";
saveText = saveText + uihandler.saveLanguage() + "\r\n";
saveText = saveText + audioHandler.saveAudioSettings() + "\r\n";
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;

View File

@@ -8,6 +8,7 @@ using UnityEngine;
using UnityEngine.UI;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using UnityEngine.Localization.Settings;
namespace Assets.Scripts
{
@@ -54,8 +55,9 @@ namespace Assets.Scripts
sw = File.CreateText(settingsPath);
sw.WriteLine("Music:0.5");
sw.WriteLine("Effects:0.5");
sw.WriteLine("Resolution:0");
sw.WriteLine("Resolution:1");
sw.WriteLine("Mode:0");
sw.WriteLine("Language:en");
sw.WriteLine("SensitivityMouse:1");
sw.WriteLine("SensitivityController:1");
sw.Flush();
@@ -96,6 +98,9 @@ namespace Assets.Scripts
break;
}
break;
case "Language":
LocalizationSettings.SelectedLocale = LocalizationSettings.AvailableLocales.GetLocale(line.Split(":")[1]);
break;
case "SensitivityMouse":
if(isIngame){
GameObject.Find("Main Camera").GetComponent<PlayerCamera>().mouseSpeed = float.Parse(line.Split(':')[1]);
@@ -126,6 +131,9 @@ namespace Assets.Scripts
case "Mode":
GameObject.Find("dropMode").GetComponent<Dropdown>().value = int.Parse(line.Split(':')[1]);
break;
case "Language":
GameObject.Find("dropLanguage").GetComponent<Dropdown>().value = line.Split(':')[1].Equals("en") ? 1 : 0;
break;
case "SensitivityMouse":
GameObject.Find("slideSensitivityMouse").GetComponent<Slider>().value = float.Parse(line.Split(':')[1]);
break;

View File

@@ -34,8 +34,20 @@ public class TextHandler : MonoBehaviour
public static string translate(string text){
string result = "";
for(int i = 0; i < text.Split(" ").Length; i++){
result += getText(text.Split(" ")[i]) + " ";
string[] parts = text.Split(" ");
for(int i = 0; i < parts.Length; i++){
try{
int.Parse(parts[i]);
result += parts[i] + " ";
}
catch(Exception ex){
if(parts[i].Contains("/")){
result += parts[i] + " ";
}
else{
result += getText(parts[i]) + " ";
}
}
}
return result;
}

View File

@@ -4,6 +4,7 @@ using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Localization.Settings;
using UnityEngine.UI;
namespace Assets.Scripts
@@ -127,7 +128,6 @@ namespace Assets.Scripts
public void openOptions()
{
options.SetActive(true);
FileHandler.loadOptionDisplay();
hideOtherElements(options);
state = UIState.PAUSEOPTIONS;
@@ -137,7 +137,6 @@ namespace Assets.Scripts
public void closeOptions()
{
options.SetActive(false);
state = UIState.PAUSE;
openPauseMenu();
}
@@ -304,6 +303,22 @@ namespace Assets.Scripts
return result;
}
public string saveLanguage(){
GameObject language = GameObject.Find("dropLanguage");
string result = "";
switch (language.GetComponent<Dropdown>().value)
{
case 0:
result = "de";
break;
case 1:
result = "en";
break;
}
result = "Language:"+result;
return result;
}
public void openPauseMenu()
{
hideOtherElements(pauseMenu);
@@ -576,5 +591,18 @@ namespace Assets.Scripts
}
}
}
public void switchLanguage(){
GameObject language = GameObject.Find("dropLanguage");
switch (language.GetComponent<Dropdown>().value)
{
case 0:
LocalizationSettings.SelectedLocale = LocalizationSettings.AvailableLocales.GetLocale("de");
break;
case 1:
LocalizationSettings.SelectedLocale = LocalizationSettings.AvailableLocales.GetLocale("en");
break;
}
}
}
}

View File

@@ -75,7 +75,29 @@ namespace Assets.Scripts
}
}
private Item getItemForTooltip()
public void showTooltipSelect(){
GameObject current = EventSystem.current.currentSelectedGameObject;
Item item = current.GetComponent<InventorySlot>().getItemForTooltip();
if (item != null)
{
inventory.itemDisplay.transform.Find("itemImage").GetComponent<RawImage>().texture = item.image;
inventory.itemDisplay.transform.Find("itemImage").GetComponent<RawImage>().color = item.rarityColor;
inventory.itemDisplay.transform.Find("itemName").GetComponent<Text>().text = TextHandler.translate(item.getName());
inventory.itemDisplay.transform.Find("itemStats").GetComponent<Text>().text = item.getInformation();
int changeY = 0;
if (inventory.itemDisplay.transform.localScale == new Vector3(0,0,0))
{
if (Input.mousePosition.y < Screen.height / 2)
{
changeY = -150;
}
inventory.itemDisplay.transform.position = new Vector3(current.transform.position.x - 250, current.transform.position.y + changeY, 0);
}
inventory.itemDisplay.transform.localScale = new Vector3(1, 1, 1);
}
}
public Item getItemForTooltip()
{
Item item = null;
if (place == ItemPlace.BAG)

View File

@@ -31,7 +31,6 @@ namespace Assets.Scripts
place = (ItemPlace)rand.Next(8);
editName();
loadImage();
Debug.Log(itemName);
}
public Equipment(JToken json) : base(json)

View File

@@ -17,7 +17,12 @@ namespace Assets.Scripts.Menu
uihandler = GameObject.Find("UIHandler").GetComponent<UIHandlerMenu>();
audioHandler = GameObject.Find("AudioHandler").GetComponent<AudioHandler>();
sceneHandler = GameObject.Find("SceneHandlerLoaded").GetComponent<SceneHandler>();
GameObject.Find("btnLoad").SetActive(FileHandler.hasSaveFile());
if(FileHandler.hasSaveFile()){
GameObject.Find("btnLoad").GetComponent<Button>().interactable = true;
}
else{
GameObject.Find("btnLoad").GetComponent<Button>().interactable = false;
}
}
public void startGame()
@@ -64,6 +69,7 @@ namespace Assets.Scripts.Menu
string saveText = "";
audioHandler.playButtonClick();
saveText = saveText + uihandler.saveVideoSettings() + "\r\n";
saveText = saveText + uihandler.saveLanguage() + "\r\n";
saveText = saveText + audioHandler.saveAudioSettings() + "\r\n";
saveText = saveText + "SensitivityMouse:"+GameObject.Find("slideSensitivityMouse").GetComponent<Slider>().value + "\r\n";
saveText = saveText + "SensitivityController:"+GameObject.Find("slideSensitivityController").GetComponent<Slider>().value;

View File

@@ -4,6 +4,7 @@ using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Localization.Settings;
using UnityEngine.UI;
namespace Assets.Scripts.Menu
@@ -18,9 +19,9 @@ namespace Assets.Scripts.Menu
void Start()
{
FileHandler.loadOptions(false);
options.SetActive(false);
characterCreation.SetActive(false);
mainMenu.SetActive(true);
options.transform.localScale = new Vector3(0,0,0);
characterCreation.transform.localScale = new Vector3(0,0,0);
mainMenu.transform.localScale = new Vector3(1,1,1);
SteamWorksHandler.getStandardAchievement("StartAchievement");
EventSystem.current.SetSelectedGameObject(GameObject.Find("btnStart"));
}
@@ -95,22 +96,25 @@ namespace Assets.Scripts.Menu
public void openCharacterCreation()
{
characterCreation.SetActive(true);
mainMenu.SetActive(false);
options.transform.localScale = new Vector3(0,0,0);
characterCreation.transform.localScale = new Vector3(1,1,1);
mainMenu.transform.localScale = new Vector3(0,0,0);
EventSystem.current.SetSelectedGameObject(GameObject.Find("inName"));
}
public void closeCharacterCreation()
{
characterCreation.SetActive(false);
mainMenu.SetActive(true);
options.transform.localScale = new Vector3(0,0,0);
characterCreation.transform.localScale = new Vector3(0,0,0);
mainMenu.transform.localScale = new Vector3(1,1,1);
EventSystem.current.SetSelectedGameObject(GameObject.Find("btnStart"));
}
public void openOptions()
{
options.SetActive(true);
mainMenu.SetActive(false);
options.transform.localScale = new Vector3(1,1,1);
characterCreation.transform.localScale = new Vector3(0,0,0);
mainMenu.transform.localScale = new Vector3(0,0,0);
FileHandler.loadOptionDisplay();
EventSystem.current.SetSelectedGameObject(GameObject.Find("btnAudio"));
showOptionView("audio");
@@ -118,8 +122,9 @@ namespace Assets.Scripts.Menu
public void closeOptions()
{
options.SetActive(false);
mainMenu.SetActive(true);
options.transform.localScale = new Vector3(0,0,0);
characterCreation.transform.localScale = new Vector3(0,0,0);
mainMenu.transform.localScale = new Vector3(1,1,1);
EventSystem.current.SetSelectedGameObject(GameObject.Find("btnStart"));
}
@@ -166,6 +171,22 @@ namespace Assets.Scripts.Menu
return result;
}
public string saveLanguage(){
GameObject language = GameObject.Find("dropLanguage");
string result = "";
switch (language.GetComponent<Dropdown>().value)
{
case 0:
result = "de";
break;
case 1:
result = "en";
break;
}
result = "Language:"+result;
return result;
}
public void updateCreationInformation()
{
setPlayerInformation();
@@ -202,5 +223,18 @@ namespace Assets.Scripts.Menu
}
}
}
public void switchLanguage(){
GameObject language = GameObject.Find("dropLanguage");
switch (language.GetComponent<Dropdown>().value)
{
case 0:
LocalizationSettings.SelectedLocale = LocalizationSettings.AvailableLocales.GetLocale("de");
break;
case 1:
LocalizationSettings.SelectedLocale = LocalizationSettings.AvailableLocales.GetLocale("en");
break;
}
}
}
}

View File

@@ -11,52 +11,52 @@ namespace Assets.Scripts
{
current = 0;
goal = getRandomNumber(10) + 1;
questname = TextHandler.getText("collect") + goal + " ";
questname = "Collect " + goal + " ";
int index = getRandomNumber(11);
switch (index)
{
case 0:
questname = questname + TextHandler.getText("slimeball");
questname = questname + "slimeball";
keyword = "Slimeball";
break;
case 1:
questname = questname + TextHandler.getText("rock");
questname = questname + "rock";
keyword = "Rock";
break;
case 2:
questname = questname + TextHandler.getText("wood");
questname = questname + "wood";
keyword = "Wood";
break;
case 3:
questname = questname + TextHandler.getText("common") + " " + TextHandler.getText("item");
questname = questname + "common item";
keyword = "Common";
break;
case 4:
questname = questname + TextHandler.getText("rare") + " " + TextHandler.getText("item");
questname = questname + "rare item";
keyword = "Rare";
break;
case 5:
questname = questname + TextHandler.getText("epic") + " " + TextHandler.getText("item");
questname = questname + "epic item";
keyword = "Epic";
break;
case 6:
questname = questname + TextHandler.getText("legendary") + " " + TextHandler.getText("item");
questname = questname + "legendary item";
keyword = "Legendary";
break;
case 7:
questname = questname + TextHandler.getText("iron") + " " + TextHandler.getText("ore");
questname = questname + "Iron ore";
keyword = "Iron";
break;
case 8:
questname = questname + TextHandler.getText("gold") + " " + TextHandler.getText("ore");
questname = questname + "Gold ore";
keyword = "Gold";
break;
case 9:
questname = questname + TextHandler.getText("copper") + " " + TextHandler.getText("ore");
questname = questname + "Copper ore";
keyword = "Copper";
break;
case 10:
questname = questname + TextHandler.getText("tin") + " " + TextHandler.getText("ore");
questname = questname + "Tin ore";
keyword = "Tin";
break;
}

View File

@@ -13,7 +13,7 @@ namespace Assets.Scripts
float coordX = getRandomNumber(1000) - 500;
float coordZ = getRandomNumber(1000) - 500;
coordinates = new Vector3(playerPos.x + coordX, 0, playerPos.z + coordZ);
questname = TextHandler.getText("travel") + " " + Mathf.Floor(coordinates.x) + "/" + Mathf.Floor(coordinates.z) + "(X/Z)";
questname = "Travel to " + Mathf.Floor(coordinates.x) + "/" + Mathf.Floor(coordinates.z) + " (X/Z)";
}
public ExploreQuest(JToken token, GameObject display) : base(token, display) { }

View File

@@ -11,28 +11,28 @@ namespace Assets.Scripts
{
current = 0;
goal = getRandomNumber(10) + 1;
questname = TextHandler.getText("find") + " " + goal + " ";
questname = "Find " + goal + " ";
int index = getRandomNumber(5);
switch (index)
{
case 0:
questname = questname + TextHandler.getText("plane");
questname = questname + "plane";
keyword = "Plane";
break;
case 1:
questname = questname + TextHandler.getText("mountain");
questname = questname + "mountain";
keyword = "Mountain";
break;
case 2:
questname = questname + TextHandler.getText("forest");
questname = questname + "forest";
keyword = "Forest";
break;
case 3:
questname = questname + TextHandler.getText("river");
questname = questname + "river";
keyword = "River";
break;
case 4:
questname = questname + TextHandler.getText("lake");
questname = questname + "lake";
keyword = "Lake";
break;
}
@@ -42,7 +42,7 @@ namespace Assets.Scripts
public void generateCityQuest()
{
questname = TextHandler.getText("cities");
questname = "Find all cities";
keyword = "City";
current = 0;
goal = GameObject.Find("WorldGenerator").GetComponent<WorldGenerator>().getCityAmount();

View File

@@ -11,20 +11,20 @@ namespace Assets.Scripts
{
current = 0;
goal = getRandomNumber(20) + 1;
questname = TextHandler.getText("kill")+ " " + goal + " ";
questname = "Kill " + goal + " ";
int index = getRandomNumber(3);
switch (index)
{
case 0:
questname = questname + TextHandler.getText("slime");
questname = questname + "slime";
keyword = "slime";
break;
case 1:
questname = questname + TextHandler.getText("bossSlime");
questname = questname + "boss slime";
keyword = "boss";
break;
case 2:
questname = questname + TextHandler.getText("minibossSlime");
questname = questname + "miniBoss slime";
keyword = "miniboss";
break;
}