Reworked menu and achievements
This commit is contained in:
@@ -9,13 +9,11 @@ namespace Assets.Scripts.Menu
|
||||
public class ButtonHandlerMenu : MonoBehaviour
|
||||
{
|
||||
UIHandlerMenu uihandler;
|
||||
AudioHandler audioHandler;
|
||||
SceneHandler sceneHandler;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
uihandler = GameObject.Find("UIHandler").GetComponent<UIHandlerMenu>();
|
||||
audioHandler = GameObject.Find("AudioHandler").GetComponent<AudioHandler>();
|
||||
sceneHandler = GameObject.Find("SceneHandlerLoaded").GetComponent<SceneHandler>();
|
||||
if(FileHandler.hasSaveFile()){
|
||||
GameObject.Find("btnLoad").GetComponent<Button>().interactable = true;
|
||||
@@ -27,13 +25,11 @@ namespace Assets.Scripts.Menu
|
||||
|
||||
public void startGame()
|
||||
{
|
||||
audioHandler.playButtonClick();
|
||||
uihandler.startGame(sceneHandler);
|
||||
}
|
||||
|
||||
public void closeGame()
|
||||
{
|
||||
audioHandler.playButtonClick();
|
||||
#if UNITY_EDITOR
|
||||
UnityEditor.EditorApplication.isPlaying = false;
|
||||
#endif
|
||||
@@ -42,35 +38,30 @@ namespace Assets.Scripts.Menu
|
||||
|
||||
public void openOptions()
|
||||
{
|
||||
audioHandler.playButtonClick();
|
||||
uihandler.openOptions();
|
||||
}
|
||||
|
||||
public void closeOptions()
|
||||
{
|
||||
audioHandler.playButtonClick();
|
||||
uihandler.closeOptions();
|
||||
}
|
||||
|
||||
public void openCreation()
|
||||
{
|
||||
audioHandler.playButtonClick();
|
||||
uihandler.openCharacterCreation();
|
||||
}
|
||||
|
||||
public void closeCreation()
|
||||
{
|
||||
audioHandler.playButtonClick();
|
||||
uihandler.closeCharacterCreation();
|
||||
}
|
||||
|
||||
public void saveOptions()
|
||||
{
|
||||
string saveText = "";
|
||||
audioHandler.playButtonClick();
|
||||
saveText = saveText + uihandler.saveVideoSettings() + "\r\n";
|
||||
saveText = saveText + uihandler.saveLanguage() + "\r\n";
|
||||
saveText = saveText + audioHandler.saveAudioSettings() + "\r\n";
|
||||
saveText = saveText + uihandler.saveAudioSettings() + "\r\n";
|
||||
saveText = saveText + "SensitivityMouse:"+GameObject.Find("slideSensitivityMouseHorizontal").GetComponent<Slider>().value + "/" + GameObject.Find("slideSensitivityMouseVertical").GetComponent<Slider>().value;
|
||||
FileHandler.saveOptions(saveText);
|
||||
uihandler.closeOptions();
|
||||
@@ -78,7 +69,6 @@ namespace Assets.Scripts.Menu
|
||||
|
||||
public void loadGame()
|
||||
{
|
||||
audioHandler.playButtonClick();
|
||||
uihandler.loadGame(sceneHandler);
|
||||
}
|
||||
|
||||
|
||||
@@ -20,9 +20,9 @@ namespace Assets.Scripts.Menu
|
||||
void Start()
|
||||
{
|
||||
FileHandler.loadOptions(false);
|
||||
options.transform.localScale = new Vector3(0,0,0);
|
||||
characterCreation.transform.localScale = new Vector3(0,0,0);
|
||||
SteamWorksHandler.getStandardAchievement("StartAchievement");
|
||||
options.transform.localScale = new Vector3(0, 0, 0);
|
||||
characterCreation.transform.localScale = new Vector3(0, 0, 0);
|
||||
SteamWorksHandler.getFirstPlayAchievement();
|
||||
EventSystem.current.SetSelectedGameObject(GameObject.Find("btnStart"));
|
||||
}
|
||||
|
||||
@@ -35,7 +35,6 @@ namespace Assets.Scripts.Menu
|
||||
PlayerPrefs.SetString("playername", GameObject.Find("inName").GetComponent<InputField>().text);
|
||||
PlayerPrefs.SetInt("difficulty", GameObject.Find("dropDifficulty").GetComponent<Dropdown>().value);
|
||||
PlayerPrefs.SetInt("isLoad", 0);
|
||||
SteamWorksHandler.getStandardAchievement("CharAchievement");
|
||||
sceneHandler.openGameScene();
|
||||
}
|
||||
|
||||
@@ -84,22 +83,22 @@ namespace Assets.Scripts.Menu
|
||||
|
||||
public void openCharacterCreation()
|
||||
{
|
||||
options.transform.localScale = new Vector3(0,0,0);
|
||||
characterCreation.transform.localScale = new Vector3(1,1,1);
|
||||
options.transform.localScale = new Vector3(0, 0, 0);
|
||||
characterCreation.transform.localScale = new Vector3(1, 1, 1);
|
||||
EventSystem.current.SetSelectedGameObject(GameObject.Find("inName"));
|
||||
}
|
||||
|
||||
public void closeCharacterCreation()
|
||||
{
|
||||
options.transform.localScale = new Vector3(0,0,0);
|
||||
characterCreation.transform.localScale = new Vector3(0,0,0);
|
||||
options.transform.localScale = new Vector3(0, 0, 0);
|
||||
characterCreation.transform.localScale = new Vector3(0, 0, 0);
|
||||
EventSystem.current.SetSelectedGameObject(GameObject.Find("btnStart"));
|
||||
}
|
||||
|
||||
public void openOptions()
|
||||
{
|
||||
options.transform.localScale = new Vector3(1,1,1);
|
||||
characterCreation.transform.localScale = new Vector3(0,0,0);
|
||||
options.transform.localScale = new Vector3(1, 1, 1);
|
||||
characterCreation.transform.localScale = new Vector3(0, 0, 0);
|
||||
FileHandler.loadOptionDisplay();
|
||||
EventSystem.current.SetSelectedGameObject(GameObject.Find("btnAudio"));
|
||||
showOptionView("audio");
|
||||
@@ -107,12 +106,13 @@ namespace Assets.Scripts.Menu
|
||||
|
||||
public void closeOptions()
|
||||
{
|
||||
options.transform.localScale = new Vector3(0,0,0);
|
||||
characterCreation.transform.localScale = new Vector3(0,0,0);
|
||||
options.transform.localScale = new Vector3(0, 0, 0);
|
||||
characterCreation.transform.localScale = new Vector3(0, 0, 0);
|
||||
EventSystem.current.SetSelectedGameObject(GameObject.Find("btnStart"));
|
||||
}
|
||||
|
||||
public string saveVideoSettings(){
|
||||
public string saveVideoSettings()
|
||||
{
|
||||
GameObject resolution = GameObject.Find("dropResolution");
|
||||
GameObject mode = GameObject.Find("dropMode");
|
||||
string result = "";
|
||||
@@ -150,12 +150,13 @@ namespace Assets.Scripts.Menu
|
||||
}
|
||||
break;
|
||||
}
|
||||
result = result + "Resolution:"+resolution.GetComponent<Dropdown>().value+"\r\n";
|
||||
result = result + "Mode:"+mode.GetComponent<Dropdown>().value;
|
||||
result = result + "Resolution:" + resolution.GetComponent<Dropdown>().value + "\r\n";
|
||||
result = result + "Mode:" + mode.GetComponent<Dropdown>().value;
|
||||
return result;
|
||||
}
|
||||
|
||||
public string saveLanguage(){
|
||||
public string saveLanguage()
|
||||
{
|
||||
GameObject language = GameObject.Find("dropLanguage");
|
||||
string result = "";
|
||||
switch (language.GetComponent<Dropdown>().value)
|
||||
@@ -167,7 +168,17 @@ namespace Assets.Scripts.Menu
|
||||
result = "en";
|
||||
break;
|
||||
}
|
||||
result = "Language:"+result;
|
||||
result = "Language:" + result;
|
||||
return result;
|
||||
}
|
||||
|
||||
public string saveAudioSettings()
|
||||
{
|
||||
string result = "";
|
||||
float music = GameObject.Find("slideMusic").GetComponent<Slider>().value;
|
||||
float effects = GameObject.Find("slideEffects").GetComponent<Slider>().value;
|
||||
result = result + "Music:" + music + "\r\n";
|
||||
result = result + "Effects:" + effects;
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -192,23 +203,29 @@ namespace Assets.Scripts.Menu
|
||||
sceneHandler.openGameScene();
|
||||
}
|
||||
|
||||
public bool isCharacterCreation(){
|
||||
public bool isCharacterCreation()
|
||||
{
|
||||
return characterCreation.activeSelf;
|
||||
}
|
||||
|
||||
public void showOptionView(string key){
|
||||
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);
|
||||
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);
|
||||
else
|
||||
{
|
||||
optionContent.transform.GetChild(i).transform.localScale = new Vector3(0, 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void switchLanguage(){
|
||||
public void switchLanguage()
|
||||
{
|
||||
GameObject language = GameObject.Find("dropLanguage");
|
||||
switch (language.GetComponent<Dropdown>().value)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user