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 RedBlocQuestion2() { while(redBloc.transform.position.y < cubesQuestion[answer2selected - 1].transform.position.y){ redBloc.transform.position += new Vector3(0f, Time.deltaTime*speedRedBloc, 0f); yield return new WaitForEndOfFrame(); } redBloc.transform.position = new Vector3(0f, camOrtho.transform.position.y-5f, 0f); psExplode.transform.position = cubesQuestion[answer2selected - 1].transform.position; psExplode.transform.position -= new Vector3(0f, 0f, 1f); psExplode.Play(); while(cubesQuestion[0].renderer.material.color.a > 0){ foreach(var cb in cubesQuestion){ cb.renderer.material.color = new Color(cb.renderer.material.color.r, cb.renderer.material.color.g, cb.renderer.material.color.b, cb.renderer.material.color.a - Time.deltaTime*speedAlphaBloc); } alphaAnswer -= Time.deltaTime*speedAlphaBloc; yield return new WaitForEndOfFrame(); } foreach(var cb in cubesQuestion){ cb.transform.position = new Vector3(cb.transform.position.x, camOrtho.transform.position.y-5f, cb.transform.position.z); cb.renderer.material.color = new Color(1f, 1f, 1f, 1f); } while(Camera.main.transform.eulerAngles.y > 0.1f){ Camera.main.transform.rotation = Quaternion.Slerp(Camera.main.transform.rotation, Quaternion.LookRotation(new Vector3(0f, 0f, 1f)), Time.deltaTime/speedRotationCamQues); yield return new WaitForEndOfFrame(); } stateIntro = INTRO_STATE.NONE; }
IEnumerator SpeechDisplay() { for(int i=0;i<=4;i++){ speechToDisplay = TextManager.Instance.texts["SplashScreen"]["SPEECH_" + i]; posSpeech = 0; while(posSpeech < speechToDisplay.Length || !inputFired){ if(posSpeech < speechToDisplay.Length){ posSpeech++; if(inputPassTextFired && posSpeech > 1){ posSpeech = speechToDisplay.Length; } inputPassTextFired = false; yield return new WaitForSeconds(speedSpeech); }else{ inputPassTextFired = false; yield return new WaitForEndOfFrame(); } } } speechToDisplay = TextManager.Instance.texts["SplashScreen"]["SPEECH_5"]; posSpeech = 0; while(posSpeech < speechToDisplay.Length){ posSpeech++; if(inputPassTextFired && posSpeech > 1){ posSpeech = speechToDisplay.Length; } inputPassTextFired = false; yield return new WaitForSeconds(speedSpeech); } stateIntro = INTRO_STATE.QUESTION1; while(!answer1valid){ yield return new WaitForEndOfFrame(); } for(int i=6;i<=9;i++){ speechToDisplay = TextManager.Instance.texts["SplashScreen"]["SPEECH_"+ i]; posSpeech = 0; while(posSpeech < speechToDisplay.Length || !inputFired){ if(posSpeech < speechToDisplay.Length){ posSpeech++; if(inputPassTextFired && posSpeech > 1){ posSpeech = speechToDisplay.Length; } inputPassTextFired = false; yield return new WaitForSeconds(speedSpeech); }else{ inputPassTextFired = false; yield return new WaitForEndOfFrame(); } } } speechToDisplay = TextManager.Instance.texts["SplashScreen"]["SPEECH_10"]; posSpeech = 0; while(posSpeech < speechToDisplay.Length){ posSpeech++; if(inputPassTextFired && posSpeech > 1){ posSpeech = speechToDisplay.Length; } inputPassTextFired = false; yield return new WaitForSeconds(speedSpeech); } stateIntro = INTRO_STATE.QUESTION2; while(!answer2valid){ yield return new WaitForEndOfFrame(); } for(int i=11;i<=12;i++){ speechToDisplay = TextManager.Instance.texts["SplashScreen"]["SPEECH_" + i]; posSpeech = 0; while(posSpeech < speechToDisplay.Length || !inputFired){ if(posSpeech < speechToDisplay.Length){ posSpeech++; if(inputPassTextFired && posSpeech > 1){ posSpeech = speechToDisplay.Length; } inputPassTextFired = false; yield return new WaitForSeconds(speedSpeech); }else{ inputPassTextFired = false; yield return new WaitForEndOfFrame(); } } } for(int i=1;i<=3;i++){ speechToDisplay = TextManager.Instance.texts["SplashScreen"]["SPEECH_RESULT_" + returnResultOfQuestion() + "_" + i]; posSpeech = 0; while(posSpeech < speechToDisplay.Length || !inputFired){ if(posSpeech < speechToDisplay.Length){ posSpeech++; if(inputPassTextFired && posSpeech > 1){ posSpeech = speechToDisplay.Length; } inputPassTextFired = false; yield return new WaitForSeconds(speedSpeech); }else{ inputPassTextFired = false; yield return new WaitForEndOfFrame(); } } } for(int i=13;i<=15;i++){ yield return new WaitForEndOfFrame(); if(wrongPassword){ speechToDisplay = TextManager.Instance.texts["SplashScreen"]["SPEECH_PASSWORDWRONG"]; newpassword = ""; newpasswordagain = ""; wrongPassword = false; }else{ speechToDisplay = TextManager.Instance.texts["SplashScreen"]["SPEECH_" + i]; } posSpeech = 0; var notChanged = false; specialInputFired = false; while(posSpeech < speechToDisplay.Length || !specialInputFired){ if(posSpeech < speechToDisplay.Length){ posSpeech++; yield return new WaitForSeconds(speedSpeech); }else{ if(!notChanged){ if(i == 13) stateIntro = INTRO_STATE.USERNAME; if(i == 14) stateIntro = INTRO_STATE.PASSWORD; if(i == 15) stateIntro = INTRO_STATE.RETYPEPASSWORD; notChanged = true; } yield return new WaitForEndOfFrame(); } } if(wrongPassword){ i = 13; } } var newuser = new Profile(username, newpassword); ProfileManager.Instance.profiles.Add(newuser); ProfileManager.Instance.setCurrentProfile(ProfileManager.Instance.profiles.Last()); ProfileManager.Instance.SaveProfile(); for(int i=16;i<=20;i++){ speechToDisplay = TextManager.Instance.texts["SplashScreen"]["SPEECH_" + i]; if(i == 20) speechToDisplay = speechToDisplay.Replace("USER_NAME", username); posSpeech = 0; while(posSpeech < speechToDisplay.Length || !inputFired){ if(posSpeech < speechToDisplay.Length){ posSpeech++; if(inputPassTextFired && posSpeech > 1){ posSpeech = speechToDisplay.Length; } inputPassTextFired = false; yield return new WaitForSeconds(speedSpeech); }else{ inputPassTextFired = false; yield return new WaitForEndOfFrame(); } } } speechToDisplay = ""; posSpeech = 0; stateIntro = INTRO_STATE.FINISH; StartCoroutine(finishDisplay(false)); }
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); }