MainGM.cs
using System.Collections; using UnityEngine; using UnityEngine.SceneManagement; using System; public class MainGM : MonoBehaviour { public static MainGM Instance { get; private set; } public bool isPaused { get; set; } public bool isLANGOptionChanged { get; set; } public bool isAndroidAudioLoaded { get; set; } public bool isFirstOnCenter { get; set; } public GameObject previousStage { get; set; } //SFX public AudioSource SFX; public AudioClip touchSFX; public GameObject[] BgImg; public LanguageSelection langSelection; public UIScrollView stageSelect_Scrollview; public UICenterOnChild centerOnChild; public GameObject[] gridStages; public GameObject[] mainButtons; public GameObject pn_FadeOut; public GameObject pn_Main; public GameObject pn_Popup_Settings; public UIScrollView settings_ScrollView; public GameObject Img_MusicOn; public GameObject Img_MusicOff; public GameObject Img_SFXOn; public GameObject Img_SFXOff; public GameObject Img_AutoRestartOn; public GameObject Img_AutoRestartOff; public UILabel Lb_Language; public UILabel Lb_Controls; public UILabel Lb_AutoRestartOnOff; public GameObject GooglePlayLogin_Btn_Check; public GameObject FacebookLogin_Btn_Check; public GameObject pn_Popup_Credits; public UIScrollView credits_ScrollView; public GameObject pn_Popup_TermsOfUse; public UIScrollView termsOfUse_ScrollView; public GameObject pn_Popup_Quit; public GameObject img_Main_Character; public GameObject btn_Credits; public GameObject btn_TermsOfUse; public int currStageIdx { get; set; } enum Difficulty { Locked, //0 Easy, //1 Normal, //2 Hard //3 } void Awake() { //가비지 컬렉트 GC.Collect(); //구글플레이, 페이스북 연동 초기화 GooglePlayGamesMgr.Instance.Initialize(); FacebookMgr.GetInstance.Initialize(); //설정정보 로드 SaveData.LoadOption(); //스테이지별 난이도 로드 LoadAndSetDifficulty(); //최고점수 로드 LoadAndSetHighScore(); //언어설정 SetLocalization(); Instance = this; isPaused = false; isLANGOptionChanged = false; isFirstOnCenter = true; previousStage = gridStages[0]; pn_FadeOut.transform.position = new Vector3(0, 0, 0); pn_Main.transform.position = new Vector3(0, 0, 0); pn_Popup_Settings.transform.position = new Vector3(0, 0, 0); pn_Popup_Credits.transform.position = new Vector3(0, 0, 0); pn_Popup_TermsOfUse.transform.position = new Vector3(0, 0, 0); pn_Popup_Quit.transform.position = new Vector3(0, 0, 0); NGUITools.SetActive(pn_FadeOut, false); NGUITools.SetActive(pn_Main, true); NGUITools.SetActive(pn_Popup_Settings, false); NGUITools.SetActive(pn_Popup_Credits, false); NGUITools.SetActive(pn_Popup_TermsOfUse, false); NGUITools.SetActive(pn_Popup_Quit, false); } void Start() { stageSelect_Scrollview.onDragStarted = HideAllUI; centerOnChild.onCenter = KnowWhatIsCentered; if (SaveData.MusicOnOff.Equals("ON")) { MainBGMSoundManager.Instance.BGMUnMute(); } else { MainBGMSoundManager.Instance.BGMMute(); } MainBGMSoundManager.Instance.BGMPlay(); StartCoroutine("MainCharacterMotion"); } IEnumerator MainCharacterMotion() { InstaHideAllUI(); ShowAllUIElements(0.0f); img_Main_Character.GetComponent<TweenTransform>().enabled = true; yield return new WaitForSeconds(1.05f); img_Main_Character.GetComponent<TweenTransform>().enabled = false; img_Main_Character.GetComponent<TweenPosition>().enabled = true; isFirstOnCenter = false; yield break; } void OnApplicationPause(bool pause) { if (pause) PauseGame(); else ResumeGame(); } void PauseGame() { isPaused = true; Time.timeScale = 0; MainBGMSoundManager.Instance.BGMPause(); } void ResumeGame() { isPaused = false; Time.timeScale = 1; MainBGMSoundManager.Instance.BGMResume(); } public void ClickPlayStage(GameObject go) { StartCoroutine(GoOnToSelectedStage(go)); } IEnumerator GoOnToSelectedStage(GameObject go) { MainBGMSoundManager.Instance.BGMStop(); SFX.PlayOneShot(touchSFX, 1.0f); GameObject Btn_PlayStage = go.transform.Find("Btn_PlayStage").gameObject; GameObject Img_PlayBrightness = Btn_PlayStage.transform.Find("Img_PlayBrightness").gameObject; GameObject Img_Play = Btn_PlayStage.transform.Find("Img_Play").gameObject; GameObject Img_Brightness = Btn_PlayStage.transform.Find("Img_Brightness").gameObject; HideAllUI(); NGUITools.SetActive(Img_PlayBrightness, false); NGUITools.SetActive(Img_Play, true); NGUITools.SetActive(Img_Brightness, true); TweenAlpha.Begin(Img_Brightness, 0.2f, 0.0f); TweenScale.Begin(Img_Play, 0.2f, new Vector3(2.5f, 2.5f, 0.0f)); TweenAlpha.Begin(Img_Play, 0.2f, 0.0f); yield return new WaitForSeconds(0.3f); NGUITools.SetActive(pn_FadeOut, true); //Splash 0, Main 1이므로 각 stage의 index는 currStageIdx + 2 AsyncOperation asyncOperation = SceneManager.LoadSceneAsync(currStageIdx + 2); asyncOperation.allowSceneActivation = false; while (!asyncOperation.isDone) { while (asyncOperation.progress == 0.9f) { yield return new WaitForSeconds(0.5f); asyncOperation.allowSceneActivation = true; } yield return null; } yield break; } public void SetOptionPopup() { Img_MusicOn.transform.Find("Lb_MusicOn").GetComponent<UILabel>().text = Localization.Get("Music") + " ON"; Img_MusicOff.transform.Find("Lb_MusicOff").GetComponent<UILabel>().text = Localization.Get("Music") + " OFF"; if (SaveData.MusicOnOff.Equals("ON")) { NGUITools.SetActive(Img_MusicOn, true); NGUITools.SetActive(Img_MusicOff, false); } else { NGUITools.SetActive(Img_MusicOn, false); NGUITools.SetActive(Img_MusicOff, true); } Img_SFXOn.transform.Find("Lb_SFXOn").GetComponent<UILabel>().text = Localization.Get("SFX") + " ON"; Img_SFXOff.transform.Find("Lb_SFXOff").GetComponent<UILabel>().text = Localization.Get("SFX") + " OFF"; if (SaveData.SFXOnOff.Equals("ON")) { NGUITools.SetActive(Img_SFXOn, true); NGUITools.SetActive(Img_SFXOff, false); } else { NGUITools.SetActive(Img_SFXOn, false); NGUITools.SetActive(Img_SFXOff, true); } Lb_Language.text = Localization.Get("Language"); Lb_Controls.text = Localization.Get("Controls") + " : "; if (SaveData.Controls.Equals("Vertical")) Lb_Controls.text += Localization.Get("Vertical"); else Lb_Controls.text += Localization.Get("Horizontal"); Img_AutoRestartOn.transform.Find("Lb_AutoRestartOn").GetComponent<UILabel>().text = Localization.Get("AutoRestart") + " ON"; Img_AutoRestartOff.transform.Find("Lb_AutoRestartOff").GetComponent<UILabel>().text = Localization.Get("AutoRestart") + " OFF"; if (SaveData.AutoRestartOnOff.Equals("ON")) { NGUITools.SetActive(Img_AutoRestartOn, true); NGUITools.SetActive(Img_AutoRestartOff, false); } else { NGUITools.SetActive(Img_AutoRestartOn, false); NGUITools.SetActive(Img_AutoRestartOff, true); } //GooglePlay 연동 확인 if (GooglePlayGamesMgr.Instance.Authenticated) { NGUITools.SetActive(GooglePlayLogin_Btn_Check, true); } else { NGUITools.SetActive(GooglePlayLogin_Btn_Check, false); } //Facebook 연동 확인 if (FacebookMgr.GetInstance.IsLoggedIn) { NGUITools.SetActive(FacebookLogin_Btn_Check, true); } else { NGUITools.SetActive(FacebookLogin_Btn_Check, false); } } public void ReloadMainScreen() { SceneManager.LoadScene("MainScreen"); } void SetLocalization() { if (SaveData.Language.Equals("")) Localization.language = "한국어;"; else Localization.language = SaveData.Language; } public void KnowWhatIsCentered(GameObject centeredStage) { if (isFirstOnCenter) return; if (centeredStage == gridStages[0]) currStageIdx = 0; else if (centeredStage == gridStages[1]) currStageIdx = 1; else if (centeredStage == gridStages[2]) currStageIdx = 2; else if (centeredStage == gridStages[3]) currStageIdx = 3; else if (centeredStage == gridStages[4]) currStageIdx = 4; else if (centeredStage == gridStages[5]) currStageIdx = 5; ShowAllUIElements(0.5f); if (previousStage != centeredStage) { ChangeStageBackground(currStageIdx); MainBGMSoundManager.Instance.BGMStop(); MainBGMSoundManager.Instance.ChangeBGM(currStageIdx); MainBGMSoundManager.Instance.BGMPlay(); } previousStage = centeredStage; } public void ChangeStageBackground(int stageIndex) { for (int i = 0; i < BgImg.Length; i++) { if (i == stageIndex) { NGUITools.SetActive(BgImg[i], true); } else { NGUITools.SetActive(BgImg[i], false); } } } public void LoadAndSetHighScore() { SaveData.LoadHiScore(); for (int i = 0; i < SaveData.HiScore.Length; i++) { UILabel label = gridStages[i].transform.Find("Lb_ScoreHighscore").GetComponent<UILabel>(); label.text = SaveData.HiScore[i].ToString(); } } public void LoadAndSetDifficulty() { SaveData.LoadStageDifficulty(); for (int i = 1; i < gridStages.Length; i++) { if (SaveData.StageDifficulty[i] > (int)Difficulty.Locked) { NGUITools.SetActive(gridStages[i].transform.Find("Btn_PlayStage").gameObject.transform.Find("Img_PlayBrightness").gameObject, true); NGUITools.SetActive(gridStages[i].transform.Find("Btn_PlayStage").gameObject.transform.Find("Img_Play").gameObject, true); NGUITools.SetActive(gridStages[i].transform.Find("Btn_PlayStage").gameObject.transform.Find("Img_Brightness").gameObject, true); NGUITools.SetActive(gridStages[i].transform.Find("Btn_PlayStage").gameObject.transform.Find("Img_Locked").gameObject, false); } else { NGUITools.SetActive(gridStages[i].transform.Find("Btn_PlayStage").gameObject.transform.Find("Img_PlayBrightness").gameObject, false); NGUITools.SetActive(gridStages[i].transform.Find("Btn_PlayStage").gameObject.transform.Find("Img_Play").gameObject, false); NGUITools.SetActive(gridStages[i].transform.Find("Btn_PlayStage").gameObject.transform.Find("Img_Brightness").gameObject, false); NGUITools.SetActive(gridStages[i].transform.Find("Btn_PlayStage").gameObject.transform.Find("Img_Locked").gameObject, true); } } } public void ChangeDifficulty(GameObject easy, GameObject normal, GameObject hard) { int difficulty = (int)Difficulty.Locked; bool isUnlocked = false; if (easy.activeInHierarchy) { NGUITools.SetActive(easy, false); NGUITools.SetActive(normal, false); NGUITools.SetActive(hard, false); NGUITools.SetActive(normal, true); difficulty = (int)Difficulty.Easy; } else if (normal.activeInHierarchy) { NGUITools.SetActive(easy, false); NGUITools.SetActive(normal, false); NGUITools.SetActive(hard, false); NGUITools.SetActive(hard, true); difficulty = (int)Difficulty.Normal; } else if (hard.activeInHierarchy) { NGUITools.SetActive(easy, false); NGUITools.SetActive(normal, false); NGUITools.SetActive(hard, false); NGUITools.SetActive(easy, true); difficulty = (int)Difficulty.Hard; } if (difficulty <= SaveData.StageDifficulty[currStageIdx]) { isUnlocked = true; } else { isUnlocked = false; } NGUITools.SetActive(gridStages[currStageIdx].transform.Find("Btn_PlayStage").gameObject.transform.Find("Img_Play").gameObject, isUnlocked); NGUITools.SetActive(gridStages[currStageIdx].transform.Find("Btn_PlayStage").gameObject.transform.Find("Img_Locked").gameObject, !isUnlocked); } public void ShowAllUIElements(float duration) { for (int i = 0; i < mainButtons.Length; i++) { TweenAlpha.Begin(mainButtons[i], duration, 1.0f); } for (int i = 0; i < gridStages.Length; i++) { TweenAlpha.Begin(gridStages[i].transform.Find("Lb_StageNum").gameObject, duration, 1.0f); TweenAlpha.Begin(gridStages[i].transform.Find("Lb_StageName").gameObject, duration, 1.0f); TweenAlpha.Begin(gridStages[i].transform.Find("Lb_StageTime").gameObject, duration, 1.0f); TweenAlpha.Begin(gridStages[i].transform.Find("Difficulty").gameObject, duration, 1.0f); TweenAlpha.Begin(gridStages[i].transform.Find("Lb_TextHighscore").gameObject, duration, 1.0f); TweenAlpha.Begin(gridStages[i].transform.Find("Lb_ScoreHighscore").gameObject, duration, 1.0f); TweenAlpha.Begin(gridStages[i].transform.Find("Btn_Contacts").gameObject, duration, 1.0f); TweenAlpha.Begin(gridStages[i].transform.Find("Btn_PlayStage").gameObject, duration, 1.0f); } } public void HideAllUI() { for (int i = 0; i < mainButtons.Length; i++) { TweenAlpha.Begin(mainButtons[i], 0.5f, 0.0f); } for (int i = 0; i < gridStages.Length; i++) { TweenAlpha.Begin(gridStages[i].transform.Find("Lb_StageNum").gameObject, 0.6f, 0.0f); TweenAlpha.Begin(gridStages[i].transform.Find("Lb_StageName").gameObject, 0.6f, 0.0f); TweenAlpha.Begin(gridStages[i].transform.Find("Lb_StageTime").gameObject, 0.6f, 0.0f); TweenAlpha.Begin(gridStages[i].transform.Find("Difficulty").gameObject, 0.55f, 0.0f); TweenAlpha.Begin(gridStages[i].transform.Find("Lb_TextHighscore").gameObject, 0.5f, 0.0f); TweenAlpha.Begin(gridStages[i].transform.Find("Lb_ScoreHighscore").gameObject, 0.5f, 0.0f); TweenAlpha.Begin(gridStages[i].transform.Find("Btn_Contacts").gameObject, 0.5f, 0.0f); TweenAlpha.Begin(gridStages[i].transform.Find("Btn_PlayStage").gameObject, 0.5f, 0.0f); } } public void InstaHideAllUI() { for (int i = 0; i < mainButtons.Length; i++) { TweenAlpha.Begin(mainButtons[i], 0.001f, 0.0f); } for (int i = 0; i < gridStages.Length; i++) { TweenAlpha.Begin(gridStages[i].transform.Find("Lb_StageNum").gameObject, 0.001f, 0.0f); TweenAlpha.Begin(gridStages[i].transform.Find("Lb_StageName").gameObject, 0.001f, 0.0f); TweenAlpha.Begin(gridStages[i].transform.Find("Lb_StageTime").gameObject, 0.001f, 0.0f); TweenAlpha.Begin(gridStages[i].transform.Find("Difficulty").gameObject, 0.001f, 0.0f); TweenAlpha.Begin(gridStages[i].transform.Find("Lb_TextHighscore").gameObject, 0.001f, 0.0f); TweenAlpha.Begin(gridStages[i].transform.Find("Lb_ScoreHighscore").gameObject, 0.001f, 0.0f); TweenAlpha.Begin(gridStages[i].transform.Find("Btn_Contacts").gameObject, 0.001f, 0.0f); TweenAlpha.Begin(gridStages[i].transform.Find("Btn_PlayStage").gameObject, 0.001f, 0.0f); } } public void ShowSettingsUI() { TweenAlpha.Begin(pn_Popup_Settings.transform.Find("Btn_Close").gameObject, 0.5f, 1.0f); TweenAlpha.Begin(pn_Popup_Settings.transform.Find("ScrollBar").gameObject, 0.5f, 1.0f); TweenAlpha.Begin(pn_Popup_Settings.transform.Find("ScrollView").gameObject, 0.5f, 1.0f); } public void HideSettingsUI() { TweenAlpha.Begin(pn_Popup_Settings.transform.Find("Btn_Close").gameObject, 0.5f, 0.0f); TweenAlpha.Begin(pn_Popup_Settings.transform.Find("ScrollBar").gameObject, 0.5f, 0.0f); TweenAlpha.Begin(pn_Popup_Settings.transform.Find("ScrollView").gameObject, 0.5f, 0.0f); } public void ShowUI(float duration) { for (int i = 0; i < gridStages.Length; i++) { TweenAlpha.Begin(gridStages[i].transform.Find("Lb_StageNum").gameObject, duration, 1.0f); TweenAlpha.Begin(gridStages[i].transform.Find("Lb_StageName").gameObject, duration, 1.0f); TweenAlpha.Begin(gridStages[i].transform.Find("Lb_StageTime").gameObject, duration, 1.0f); TweenAlpha.Begin(gridStages[i].transform.Find("Difficulty").gameObject, duration, 1.0f); TweenAlpha.Begin(gridStages[i].transform.Find("Lb_TextHighscore").gameObject, duration, 1.0f); TweenAlpha.Begin(gridStages[i].transform.Find("Lb_ScoreHighscore").gameObject, duration, 1.0f); TweenAlpha.Begin(gridStages[i].transform.Find("Btn_Contacts").gameObject, duration, 1.0f); TweenAlpha.Begin(gridStages[i].transform.Find("Btn_PlayStage").gameObject, duration, 1.0f); } } public void HideUI() { for (int i = 0; i < gridStages.Length; i++) { TweenAlpha.Begin(gridStages[i].transform.Find("Lb_StageNum").gameObject, 0.6f, 0.0f); TweenAlpha.Begin(gridStages[i].transform.Find("Lb_StageName").gameObject, 0.6f, 0.0f); TweenAlpha.Begin(gridStages[i].transform.Find("Lb_StageTime").gameObject, 0.6f, 0.0f); TweenAlpha.Begin(gridStages[i].transform.Find("Difficulty").gameObject, 0.55f, 0.0f); TweenAlpha.Begin(gridStages[i].transform.Find("Lb_TextHighscore").gameObject, 0.5f, 0.0f); TweenAlpha.Begin(gridStages[i].transform.Find("Lb_ScoreHighscore").gameObject, 0.5f, 0.0f); TweenAlpha.Begin(gridStages[i].transform.Find("Btn_Contacts").gameObject, 0.5f, 0.0f); TweenAlpha.Begin(gridStages[i].transform.Find("Btn_PlayStage").gameObject, 0.5f, 0.0f); } } }
MainInput.cs
using UnityEngine; using System.Collections; using Facebook.Unity; using GooglePlayGames; public class MainInput : MonoBehaviour { public MainGM mainGM { get; private set; } public GameObject stageSelect; public UICenterOnChild centerOnChild; public float scrollPerSecond { get; set; } public float minScrollPosition; public float maxScrollPosition; public float targetStage { get; set; } public bool isScrollingLeft { get; set; } public bool isScrollingRight { get; set; } public string officalWebsiteURL; public string composerURL; public string illustratorURL; void Start() { isScrollingLeft = false; isScrollingRight = false; mainGM = GetComponent<MainGM>(); } void Update() { if (Input.GetKeyDown(KeyCode.Escape)) { if (mainGM.pn_Popup_Quit.activeInHierarchy) { CancelQuitGame(); } else if (mainGM.pn_Popup_Credits.activeInHierarchy) { CloseCreditsPopup(); } else if (mainGM.pn_Popup_TermsOfUse.activeInHierarchy) { CloseTermsOfUsePopup(); } else if (mainGM.pn_Popup_Settings.activeInHierarchy) { CloseSettingsPopup(); } else { if (!mainGM.pn_Popup_Quit.activeInHierarchy) { NGUITools.SetActive(mainGM.pn_Popup_Quit, true); } } } } public void ScrollLeft() { if (isScrollingLeft) return; isScrollingLeft = true; mainGM.HideUI(); SpringPanel.Begin(stageSelect, new Vector3(stageSelect.transform.localPosition.x + 1280f, 0, 0), 8.3f); mainGM.ShowUI(0.05f); mainGM.previousStage = mainGM.gridStages[mainGM.currStageIdx]; if (mainGM.currStageIdx==0) { mainGM.currStageIdx = 5; } else { mainGM.currStageIdx--; } Invoke("ButtonScrollCallback", 0.2f); } public void ScrollRight() { if (isScrollingRight) return; isScrollingRight = true; mainGM.HideUI(); SpringPanel.Begin(stageSelect, new Vector3(stageSelect.transform.localPosition.x - 1280f, 0, 0), 8.3f); mainGM.ShowUI(0.05f); mainGM.previousStage = mainGM.gridStages[mainGM.currStageIdx]; if (mainGM.currStageIdx == 5) { mainGM.currStageIdx = 0; } else { mainGM.currStageIdx++; } Invoke("ButtonScrollCallback", 0.5f); } public void ButtonScrollCallback() { mainGM.stageSelect_Scrollview.SendMessage("Drag"); mainGM.ChangeStageBackground(mainGM.currStageIdx); MainBGMSoundManager.Instance.BGMStop(); MainBGMSoundManager.Instance.ChangeBGM(mainGM.currStageIdx); MainBGMSoundManager.Instance.BGMPlay(); if (isScrollingLeft) { isScrollingLeft = false; } else { isScrollingRight = false; } } public void OpenSettingsPopUp() { StartCoroutine("OpenSettingsCo"); } IEnumerator OpenSettingsCo() { MainBGMSoundManager.Instance.BGMMute(); mainGM.HideAllUI(); yield return new WaitForSeconds(0.5f); NGUITools.SetActive(mainGM.mainButtons[2], true); mainGM.SetOptionPopup(); NGUITools.SetActive(mainGM.pn_Popup_Settings, true); TweenAlpha.Begin(mainGM.pn_Popup_Settings, 0.5f, 1); yield break; } public void CloseSettingsPopup() { StartCoroutine("CloseSettingsCo"); } IEnumerator CloseSettingsCo() { SaveData.SaveOption(); TweenAlpha.Begin(mainGM.pn_Popup_Settings, 0.5f, 0); yield return new WaitForSeconds(0.5f); mainGM.settings_ScrollView.ResetPosition(); NGUITools.SetActive(mainGM.pn_Popup_Settings, false); if (SaveData.Language != Localization.language) { mainGM.ReloadMainScreen(); } mainGM.ShowAllUIElements(0.5f); yield return new WaitForSeconds(0.5f); NGUITools.SetActive(mainGM.mainButtons[2], true); if (SaveData.MusicOnOff.Equals("ON")) { MainBGMSoundManager.Instance.BGMUnMute(); } yield break; } public void OpenCreditsPopup() { StartCoroutine("OpenCreditsCo"); } IEnumerator OpenCreditsCo() { mainGM.HideSettingsUI(); yield return new WaitForSeconds(0.5f); NGUITools.SetActive(mainGM.btn_Credits, true); NGUITools.SetActive(mainGM.pn_Popup_Credits, true); TweenAlpha.Begin(mainGM.pn_Popup_Credits, 0.5f, 1); yield break; } public void CloseCreditsPopup() { mainGM.credits_ScrollView.ResetPosition(); StartCoroutine("CloseCreditsCo"); } IEnumerator CloseCreditsCo() { TweenAlpha.Begin(mainGM.pn_Popup_Credits, 0.5f, 0); yield return new WaitForSeconds(0.5f); NGUITools.SetActive(mainGM.pn_Popup_Credits, false); mainGM.ShowSettingsUI(); yield return new WaitForSeconds(0.5f); NGUITools.SetActive(mainGM.btn_Credits, true); yield break; } public void OpenTermsOfUsePopup() { StartCoroutine("OpenTermsOfUseCo"); } IEnumerator OpenTermsOfUseCo() { mainGM.HideSettingsUI(); yield return new WaitForSeconds(0.5f); NGUITools.SetActive(mainGM.btn_TermsOfUse, true); NGUITools.SetActive(mainGM.pn_Popup_TermsOfUse, true); TweenAlpha.Begin(mainGM.pn_Popup_TermsOfUse, 0.5f, 1); yield break; } public void CloseTermsOfUsePopup() { mainGM.termsOfUse_ScrollView.ResetPosition(); StartCoroutine("CloseTermsOfUseCo"); } IEnumerator CloseTermsOfUseCo() { TweenAlpha.Begin(mainGM.pn_Popup_TermsOfUse, 0.5f, 0); yield return new WaitForSeconds(0.5f); NGUITools.SetActive(mainGM.pn_Popup_TermsOfUse, false); mainGM.ShowSettingsUI(); yield return new WaitForSeconds(0.5f); NGUITools.SetActive(mainGM.btn_TermsOfUse, true); yield break; } public void OpenQuitPopup() { NGUITools.SetActive(mainGM.pn_Popup_Settings, true); } public void QuitGame() { Application.Quit(); } public void CancelQuitGame() { NGUITools.SetActive(mainGM.pn_Popup_Quit, false); } public void ChangeMusicOption() { if (SaveData.MusicOnOff.Equals("ON")) { SaveData.MusicOnOff = "OFF"; NGUITools.SetActive(mainGM.Img_MusicOn, false); NGUITools.SetActive(mainGM.Img_MusicOff, true); } else { SaveData.MusicOnOff = "ON"; NGUITools.SetActive(mainGM.Img_MusicOn, true); NGUITools.SetActive(mainGM.Img_MusicOff, false); } } public void ChangeSFXOption() { if (SaveData.SFXOnOff.Equals("ON")) { SaveData.SFXOnOff = "OFF"; NGUITools.SetActive(mainGM.Img_SFXOn, false); NGUITools.SetActive(mainGM.Img_SFXOff, true); } else { SaveData.SFXOnOff = "ON"; NGUITools.SetActive(mainGM.Img_SFXOn, true); NGUITools.SetActive(mainGM.Img_SFXOff, false); } } public void ChangeLANGOption() { if (SaveData.Language.Equals("한국어")) { mainGM.Lb_Language.text = "English"; } else { mainGM.Lb_Language.text = "한국어"; } SaveData.Language = mainGM.Lb_Language.text; Debug.Log("Language: " + SaveData.Language); } public void ChangeControlsOption() { if (SaveData.Controls.Equals("Vertical")) SaveData.Controls = "Horizontal"; else SaveData.Controls = "Vertical"; mainGM.Lb_Controls.text = Localization.Get("Controls") + " : " + Localization.Get(SaveData.Controls); } public void ChangeAutoRestartOption() { if (SaveData.AutoRestartOnOff.Equals("ON")) { SaveData.AutoRestartOnOff = "OFF"; NGUITools.SetActive(mainGM.Img_AutoRestartOn, false); NGUITools.SetActive(mainGM.Img_AutoRestartOff, true); } else { SaveData.AutoRestartOnOff = "ON"; NGUITools.SetActive(mainGM.Img_AutoRestartOn, true); NGUITools.SetActive(mainGM.Img_AutoRestartOff, false); } } public void ConnectToGoogleServicesFromSettings() { if (GooglePlayGamesMgr.Instance.Authenticated) { GooglePlayGamesMgr.Instance.SignOutFromGooglePlay(); NGUITools.SetActive(mainGM.GooglePlayLogin_Btn_Check, false); } else { Social.localUser.Authenticate((bool success) => { if (success) { NGUITools.SetActive(mainGM.GooglePlayLogin_Btn_Check, true); } else { NGUITools.SetActive(mainGM.GooglePlayLogin_Btn_Check, false); } }); } } public void ConnectToFacebookFromSettings() { if (!FB.IsLoggedIn) { FB.LogInWithReadPermissions(null, AuthCallback); } else { FB.LogOut(); NGUITools.SetActive(mainGM.FacebookLogin_Btn_Check, false); } } private void AuthCallback(ILoginResult result) { if (FB.IsLoggedIn) { NGUITools.SetActive(mainGM.FacebookLogin_Btn_Check, true); } else { NGUITools.SetActive(mainGM.FacebookLogin_Btn_Check, false); } } public void ConnectToOfficalWebsite() { Application.OpenURL(string.Format("http://{0}", officalWebsiteURL)); } public void ConnectToComposer() { Application.OpenURL(string.Format("http://{0}", composerURL)); } public void ConnectToIllustrator() { Application.OpenURL(string.Format("http://{0}", illustratorURL)); } public void OpenStageContactsPopup(GameObject go) { GameObject pn_Popup_Contacts = go.transform.Find("Pn_Popup_Contacts").gameObject; NGUITools.SetActive(pn_Popup_Contacts, true); } IEnumerator OpenStageContactsCo(GameObject go) { mainGM.HideAllUI(); TweenAlpha.Begin(go.transform.Find("Icon_MUSIC").gameObject, 0.3f, 0.0f); TweenAlpha.Begin(go.transform.Find("Icon_ART").gameObject, 0.3f, 0.0f); TweenAlpha.Begin(go.transform.Find("Lb_ART_MUSIC").gameObject, 0.3f, 0.0f); TweenAlpha.Begin(go.transform.Find("Lb_ART_MUSIC_Credits").gameObject, 0.3f, 0.0f); yield return new WaitForSeconds(0.5f); GameObject pn_Popup_Contacts = go.transform.Find("Pn_Popup_Contacts").gameObject; NGUITools.SetActive(pn_Popup_Contacts, true); TweenAlpha.Begin(pn_Popup_Contacts, 0.5f, 1.0f); yield return new WaitForSeconds(0.5f); } public void CloseStageContactsPopup(GameObject go) { GameObject pn_Popup_Contacts = go.transform.Find("Pn_Popup_Contacts").gameObject; NGUITools.SetActive(pn_Popup_Contacts, false); } IEnumerator CloseStageContactsCo(GameObject go) { TweenAlpha.Begin(go.transform.Find("Icon_MUSIC").gameObject, 0.0f, 0.0f); TweenAlpha.Begin(go.transform.Find("Icon_ART").gameObject, 0.0f, 0.0f); TweenAlpha.Begin(go.transform.Find("Lb_ART_MUSIC").gameObject, 0.0f, 0.0f); TweenAlpha.Begin(go.transform.Find("Lb_ART_MUSIC_Credits").gameObject, 0.0f, 0.0f); GameObject pn_Popup_Contacts = go.transform.Find("Pn_Popup_Contacts").gameObject; TweenAlpha.Begin(pn_Popup_Contacts, 0.7f, 0); yield return new WaitForSeconds(0.5f); NGUITools.SetActive(pn_Popup_Contacts, false); TweenAlpha.Begin(go.transform.Find("Icon_MUSIC").gameObject, 0.5f, 1.0f); TweenAlpha.Begin(go.transform.Find("Icon_ART").gameObject, 0.5f, 1.0f); TweenAlpha.Begin(go.transform.Find("Lb_ART_MUSIC").gameObject, 0.5f, 1.0f); TweenAlpha.Begin(go.transform.Find("Lb_ART_MUSIC_Credits").gameObject, 0.5f, 1.0f); mainGM.ShowAllUIElements(0.5f); yield return new WaitForSeconds(0.6f); } }