IEnumerator TextLogin() { yield return new WaitForFixedUpdate(); while(posLength < labelToDisplay.Length){ posLength++; yield return new WaitForSeconds(speedLetters); } LoadManager.Instance.Loading(); labelToDisplay = TextManager.Instance.texts["SplashScreen"]["CONNECTING"]; posLength = 0; while(posLength < labelToDisplay.Length){ posLength++; yield return new WaitForSeconds(speedLetters); } yield return new WaitForSeconds(1f); ProfileManager.Instance.LoadProfiles(); var verif = ProfileManager.Instance.verifyCurrentProfile(); if(verif){ labelToDisplay = TextManager.Instance.texts["SplashScreen"]["CONNECTING_SUCCEED"].Replace("USER_NAME", ProfileManager.Instance.currentProfile.name); posLength = 0; while(posLength < labelToDisplay.Length){ posLength++; yield return new WaitForSeconds(speedLetters); } yield return new WaitForSeconds(1f); ls = LOGIN_STATUT.VALID; stateIntro = INTRO_STATE.FINISH; }else if(ProfileManager.Instance.profiles.Count > 0){ labelToDisplay = TextManager.Instance.texts["SplashScreen"]["CONNECTING_CHOOSE"]; posLength = 0; while(posLength < labelToDisplay.Length){ posLength++; yield return new WaitForSeconds(speedLetters); } ls = LOGIN_STATUT.CHOOSE; }else{ labelToDisplay = TextManager.Instance.texts["SplashScreen"]["CONNECTING_FAIL"]; posLength = 0; while(posLength < labelToDisplay.Length){ posLength++; yield return new WaitForSeconds(speedLetters); } yield return new WaitForSeconds(1f); labelToDisplay = ""; posLength = 0; ls = LOGIN_STATUT.INVALID; } }
void Start() { TextManager.Instance.LoadTextFile(); labelToDisplay = TextManager.Instance.texts["SplashScreen"]["LOADING"]; posLength = 0; blank = (Texture2D) Resources.Load("blank"); // time = 0; ls = LOGIN_STATUT.NONE; StartCoroutine(TextLogin()); startNumber = 0; profileSelected = -1; password = ""; okforSpeech = false; wrongPassword = false; stateIntro = INTRO_STATE.NONE; answer1selected = -1; answer2selected = -1; alphaAnswer = 0f; inputFired = false; username = ""; newpassword = ""; newpasswordagain = ""; speechToDisplay = ""; alphaBlank = 0f; enterPushedForFinish = false; }
IEnumerator TextDisplay(LOGIN_STATUT lst) { while(posLength < labelToDisplay.Length){ posLength++; yield return new WaitForSeconds(speedLetters); } if(lst != LOGIN_STATUT.NONE){ if(lst == LOGIN_STATUT.INVALID || lst == LOGIN_STATUT.VALID) yield return new WaitForSeconds(1f); ls = lst; } }
void OnGUI() { GUI.skin = skin; if(ls != LOGIN_STATUT.VALID && ls != LOGIN_STATUT.INVALID) GUI.Label(new Rect(labelConnecting.x*Screen.width, labelConnecting.y*Screen.height, labelConnecting.width*Screen.width, labelConnecting.height*Screen.height), labelToDisplay.Substring(0, posLength), "CenteredLabel"); if(ls == LOGIN_STATUT.PASSWORD){ GUI.SetNextControlName("pass"); password = GUI.PasswordField(new Rect(TextAreaPassword.x*Screen.width, TextAreaPassword.y*Screen.height, TextAreaPassword.width*Screen.width, TextAreaPassword.height*Screen.height), password, '*'); GUI.FocusControl("pass"); if(Event.current.isKey && Event.current.keyCode == KeyCode.Return){ if(password == ProfileManager.Instance.profiles[profileSelected].password){ ls = LOGIN_STATUT.NONE; ProfileManager.Instance.setCurrentProfile(ProfileManager.Instance.profiles[profileSelected]); labelToDisplay = TextManager.Instance.texts["SplashScreen"]["CONNECTING_SUCCEED"].Replace("USER_NAME", ProfileManager.Instance.currentProfile.name); posLength = 0; StartCoroutine(TextDisplay(LOGIN_STATUT.VALID)); stateIntro = INTRO_STATE.FINISH; }else{ labelToDisplay = TextManager.Instance.texts["SplashScreen"]["CONNECTING_PASSWORDFAIL"]; posLength = 0; StartCoroutine(TextDisplay(LOGIN_STATUT.NONE)); password = ""; } } if(GUI.Button(new Rect(BackButton.x*Screen.width, BackButton.y*Screen.height, BackButton.width*Screen.width, BackButton.height*Screen.height), "< back", "ButtonSimple")){ ls = LOGIN_STATUT.NONE; labelToDisplay = TextManager.Instance.texts["SplashScreen"]["CONNECTING_CHOOSE"]; posLength = 0; StartCoroutine(TextDisplay(LOGIN_STATUT.CHOOSE)); } } if(ls == LOGIN_STATUT.CHOOSE){ for(int i=startNumber; i<startNumber+4 && i<ProfileManager.Instance.profiles.Count;i++){ if(GUI.Button(new Rect(ButtonProfiles.x*Screen.width, (ButtonProfiles.y + offset*(i-startNumber))*Screen.height, ButtonProfiles.width*Screen.width, ButtonProfiles.height*Screen.height), ProfileManager.Instance.profiles[i].name, profileSelected == i ? "ButtonSimpleSelected" : "ButtonSimple")){ profileSelected = i; infoToDisplay = "Name : " + ProfileManager.Instance.profiles[i].name + "\n\n" + "Number of song played : " + ProfileManager.Instance.profiles[i].scoreOnSong.Count + "\n\n" + "Game time : " + "00:00h" + "\n\n\n\n" + "Story mode progression : " + "0%" + "\n\n" + "Achievement : " + "0/400" + "\n\n"; StopAllCoroutines(); StartCoroutine(TextInfo()); } } if((startNumber+4) < ProfileManager.Instance.profiles.Count){ if(GUI.Button(new Rect(nextButton.x*Screen.width, nextButton.y*Screen.height, nextButton.width*Screen.width, nextButton.height*Screen.height), "next >", "ButtonSimple")){ startNumber += 4; } } if(startNumber > 0){ if(GUI.Button(new Rect(prevButton.x*Screen.width, prevButton.y*Screen.height, prevButton.width*Screen.width, prevButton.height*Screen.height), "< prev", "ButtonSimple")){ startNumber -= 4; } } if(GUI.Button(new Rect(CreateNewButton.x*Screen.width, CreateNewButton.y*Screen.height, CreateNewButton.width*Screen.width, CreateNewButton.height*Screen.height), "NEW PROFILE", "ButtonSimple")){ labelToDisplay = ""; posLength = 0; ls = LOGIN_STATUT.INVALID; } if(profileSelected != -1){ GUI.Label(new Rect(labelInfo.x*Screen.width, labelInfo.y*Screen.height, labelInfo.width*Screen.width, labelInfo.height*Screen.height), infoToDisplay.Substring(0, posLengthInfo)); if(GUI.Button(new Rect(ChooseButton.x*Screen.width, ChooseButton.y*Screen.height, ChooseButton.width*Screen.width, ChooseButton.height*Screen.height), "VALID", "ButtonSimple")){ ls = LOGIN_STATUT.NONE; posLength = 0; labelToDisplay = TextManager.Instance.texts["SplashScreen"]["CONNECTING_PASSWORD"] + " : "; StartCoroutine(TextDisplay(LOGIN_STATUT.PASSWORD)); } } } if(ls == LOGIN_STATUT.INVALID && okforSpeech){ GUI.Label(new Rect(labelSpeech.x*Screen.width, labelSpeech.y*Screen.height, labelSpeech.width*Screen.width, labelSpeech.height*Screen.height), speechToDisplay.Substring(0, posSpeech) , "CenteredBrightLabel"); GUI.color = new Color(0.3f, 0.3f, 0.3f, 1f); GUI.Label(new Rect(PressEnter.x*Screen.width, PressEnter.y*Screen.height, PressEnter.width*Screen.width, PressEnter.height*Screen.height), TextManager.Instance.texts["SplashScreen"]["PRESSENTER"]); GUI.color = new Color(1f, 1f, 1f, 1f); if(stateIntro == INTRO_STATE.QUESTION1){ if(answer1selected != -1){ GUI.color = new Color(1f, 1f, 1f, alphaAnswer); GUI.Label(new Rect(labelAnswer.x*Screen.width, labelAnswer.y*Screen.height, labelAnswer.width*Screen.width, labelAnswer.height*Screen.height), TextManager.Instance.texts["SplashScreen"]["QUESTION_1_ANSWER_" + answer1selected], "CenteredBrightLabel"); } }else if(stateIntro == INTRO_STATE.QUESTION2){ if(answer2selected != -1){ GUI.color = new Color(1f, 1f, 1f, alphaAnswer); GUI.Label(new Rect(labelAnswer.x*Screen.width, labelAnswer.y*Screen.height, labelAnswer.width*Screen.width, labelAnswer.height*Screen.height), TextManager.Instance.texts["SplashScreen"]["QUESTION_2_ANSWER_" + answer2selected], "CenteredBrightLabel"); } }else if(stateIntro == INTRO_STATE.USERNAME){ if(Event.current.isKey && Event.current.keyCode == KeyCode.Return && !String.IsNullOrEmpty(username)){ stateIntro = INTRO_STATE.NONE; specialInputFired = true; }else{ GUI.SetNextControlName("user"); username = GUI.TextField(new Rect(TextFieldCreate.x*Screen.width, TextFieldCreate.y*Screen.height, TextFieldCreate.width*Screen.width, TextFieldCreate.y*Screen.height), username, "CenteredBrightLabel"); GUI.FocusControl("user"); } }else if(stateIntro == INTRO_STATE.PASSWORD){ if(Event.current.isKey && Event.current.keyCode == KeyCode.Return && !String.IsNullOrEmpty(newpassword)){ stateIntro = INTRO_STATE.NONE; specialInputFired = true; }else{ GUI.SetNextControlName("newpassword"); newpassword = GUI.PasswordField(new Rect(TextFieldCreate.x*Screen.width, TextFieldCreate.y*Screen.height, TextFieldCreate.width*Screen.width, TextFieldCreate.y*Screen.height), newpassword, '*', "CenteredBrightLabel"); GUI.FocusControl("newpassword"); } }else if(stateIntro == INTRO_STATE.RETYPEPASSWORD){ if(Event.current.isKey && Event.current.keyCode == KeyCode.Return && !String.IsNullOrEmpty(newpasswordagain)){ if(newpassword != newpasswordagain){ wrongPassword = true; } stateIntro = INTRO_STATE.NONE; specialInputFired = true; }else{ GUI.SetNextControlName("newpasswordagain"); newpasswordagain = GUI.PasswordField(new Rect(TextFieldCreate.x*Screen.width, TextFieldCreate.y*Screen.height, TextFieldCreate.width*Screen.width, TextFieldCreate.y*Screen.height), newpasswordagain, '*', "CenteredBrightLabel"); GUI.FocusControl("newpasswordagain"); } } } if(ls == LOGIN_STATUT.VALID){ GUI.color = new Color(0.3f, 0.3f, 0.3f, 1f); GUI.Label(new Rect(PressEnter.x*Screen.width, PressEnter.y*Screen.height, PressEnter.width*Screen.width, PressEnter.height*Screen.height), TextManager.Instance.texts["SplashScreen"]["PRESSENTER"]); GUI.color = new Color(1f, 1f, 1f, 1f); } GUI.color = new Color(1f, 1f, 1f, alphaBlank); GUI.DrawTexture(new Rect(0f, 0f, Screen.width, Screen.height), blank); }