private void Process_UpdateQuestionToGUI() { m_AttackQuestionLabel.text = this.m_AttackQuestion.QuestionString; this.m_AttackInputField.text = ""; m_DefendQuestionLabel.text = this.m_DefendQuestion.QuestionString; RandomizeMapper(); int actuallyIndexFromAnswer = 0; for (int i = 0; i < m_DenfendButtonText.Length && i < m_DefendRandomMapper.Length; ++i) { actuallyIndexFromAnswer = m_DefendRandomMapper[i]; // Debug.Log("button i=" + i + " actuallyIndexFromAnswer=" + actuallyIndexFromAnswer ); if (i < this.m_DefendQuestion.m_Answers.Count) { m_DenfendButtonText[i].text = m_DefendQuestion.m_Answers[actuallyIndexFromAnswer].AnswerString; } else { m_DenfendButtonText[i].text = ""; } } StartActionAnimation(true); m_State = LanguageUIState.LanguageUIState_WaitPlayer; }
private void Process_WaitBattlePlay() { if (m_BattlePlay && false == m_BattlePlay.IsInAnimation()) { m_State = LanguageUIState.LanguageUIState_StartRequestQuestion; } }
private void Process_StartInitialize() { if (null != m_Server) { this.m_Server.RequestQuestions(); m_State = LanguageUIState.LanguageUIState_WaitInitialize; } }
private void Process_StartRequestQuestion() { if (m_Server) { m_AttackQuestion = m_Server.GetAQuestion(); m_DefendQuestion = m_Server.GetAQuestion(); } m_State = LanguageUIState.LanguageUIState_WaitRequestQuestion; }
private void Process_StartRequestAddAnswer() { if (string.Empty == this.m_AttackInputField.text) { return; } if (m_Server) { m_Server.RequestAddAnswer(m_AttackQuestion.ID, this.m_AttackInputField.text); } m_State = LanguageUIState.LanguageUIState_WaitRequestAddAnswer; }
private void TryDoDefend(int _Index) { int actuallyIndexFromAnswer = m_DefendRandomMapper[_Index]; Debug.Log("_Index=" + _Index + " actuallyIndexFromAnswer=" + actuallyIndexFromAnswer); if (m_State != LanguageUIState.LanguageUIState_WaitPlayer) { return; } if (m_BattlePlay) { float ratio = m_DefendQuestion.CalculateRatioOfIndex(actuallyIndexFromAnswer); m_BattlePlay.Defend(ratio * 2); } StartActionAnimation(false); m_State = LanguageUIState.LanguageUIState_WaitBattlePlay; }
// Update is called once per frame void Update() { switch (m_State) { case LanguageUIState.LanguageUIState_Invalid: m_State = LanguageUIState.LanguageUIState_StartInitialize; break; case LanguageUIState.LanguageUIState_StartInitialize: Process_StartInitialize(); break; case LanguageUIState.LanguageUIState_WaitInitialize: Process_WaitInitialize(); break; case LanguageUIState.LanguageUIState_StartRequestQuestion: Process_StartRequestQuestion(); break; case LanguageUIState.LanguageUIState_WaitRequestQuestion: Process_WaitRequestQuestion(); break; case LanguageUIState.LanguageUIState_UpdateQuestionToGUI: Process_UpdateQuestionToGUI(); break; case LanguageUIState.LanguageUIState_WaitPlayer: break; case LanguageUIState.LanguageUIState_WaitBattlePlay: Process_WaitBattlePlay(); break; case LanguageUIState.LanguageUIState_StartRequestAddAnswer: Process_StartRequestAddAnswer(); break; case LanguageUIState.LanguageUIState_WaitRequestAddAnswer: Process_WaitRequestAddAnswer(); break; } }
public void TryDoAttack() { Debug.Log("TryDoAttack"); if (m_State != LanguageUIState.LanguageUIState_WaitPlayer) { return; } if (null != m_AttackInputField && string.Empty != m_AttackInputField.text) { string stringFromInput = m_AttackInputField.text; Debug.Log("stringFromInput=" + stringFromInput); if (m_BattlePlay) { float ratio = m_AttackQuestion.TryCalculateRatioOfAnAnswer(stringFromInput); m_BattlePlay.Attack(ratio * 2); } StartActionAnimation(false); m_State = LanguageUIState.LanguageUIState_StartRequestAddAnswer; } }
public void TryDoAttack() { Debug.Log("TryDoAttack"); if (m_State != LanguageUIState.LanguageUIState_WaitPlayer ) { return ; } if( null != m_AttackInputField && string.Empty != m_AttackInputField.text ) { string stringFromInput = m_AttackInputField.text ; Debug.Log("stringFromInput=" + stringFromInput ); if( m_BattlePlay ) { float ratio = m_AttackQuestion.TryCalculateRatioOfAnAnswer( stringFromInput ) ; m_BattlePlay.Attack( ratio * 2 ) ; } StartActionAnimation( false ) ; m_State = LanguageUIState.LanguageUIState_StartRequestAddAnswer ; } }
private void Process_StartRequestQuestion() { if( m_Server ) { m_AttackQuestion = m_Server.GetAQuestion() ; m_DefendQuestion = m_Server.GetAQuestion() ; } m_State = LanguageUIState.LanguageUIState_WaitRequestQuestion ; }
private void Process_WaitRequestAddAnswer() { m_State = LanguageUIState.LanguageUIState_WaitBattlePlay; }
private void Process_WaitBattlePlay() { if( m_BattlePlay && false == m_BattlePlay.IsInAnimation() ) { m_State = LanguageUIState.LanguageUIState_StartRequestQuestion ; } }
private void Process_WaitInitialize() { m_State = LanguageUIState.LanguageUIState_StartRequestQuestion ; }
private void Process_WaitRequestAddAnswer() { m_State = LanguageUIState.LanguageUIState_WaitBattlePlay ; }
private void Process_WaitRequestQuestion() { m_State = LanguageUIState.LanguageUIState_UpdateQuestionToGUI; }
private void Process_WaitRequestQuestion() { m_State = LanguageUIState.LanguageUIState_UpdateQuestionToGUI ; }
private void Process_WaitInitialize() { m_State = LanguageUIState.LanguageUIState_StartRequestQuestion; }
private void TryDoDefend( int _Index ) { int actuallyIndexFromAnswer = m_DefendRandomMapper[ _Index ] ; Debug.Log("_Index=" + _Index + " actuallyIndexFromAnswer=" +actuallyIndexFromAnswer); if (m_State != LanguageUIState.LanguageUIState_WaitPlayer ) { return ; } if( m_BattlePlay ) { float ratio = m_DefendQuestion.CalculateRatioOfIndex( actuallyIndexFromAnswer ) ; m_BattlePlay.Defend( ratio * 2 ) ; } StartActionAnimation( false ) ; m_State = LanguageUIState.LanguageUIState_WaitBattlePlay ; }
private void Process_UpdateQuestionToGUI() { m_AttackQuestionLabel.text = this.m_AttackQuestion.QuestionString ; this.m_AttackInputField.text = "" ; m_DefendQuestionLabel.text = this.m_DefendQuestion.QuestionString ; RandomizeMapper() ; int actuallyIndexFromAnswer = 0 ; for( int i = 0 ; i < m_DenfendButtonText.Length && i < m_DefendRandomMapper.Length ; ++i ) { actuallyIndexFromAnswer = m_DefendRandomMapper[ i ] ; // Debug.Log("button i=" + i + " actuallyIndexFromAnswer=" + actuallyIndexFromAnswer ); if( i < this.m_DefendQuestion.m_Answers.Count ) { m_DenfendButtonText[ i ].text = m_DefendQuestion.m_Answers[ actuallyIndexFromAnswer ].AnswerString ; } else { m_DenfendButtonText[i].text = "" ; } } StartActionAnimation( true ) ; m_State = LanguageUIState.LanguageUIState_WaitPlayer ; }
private void Process_StartRequestAddAnswer() { if( string.Empty == this.m_AttackInputField.text ) { return ; } if( m_Server ) { m_Server.RequestAddAnswer( m_AttackQuestion.ID , this.m_AttackInputField.text ) ; } m_State = LanguageUIState.LanguageUIState_WaitRequestAddAnswer ; }
private void Process_StartInitialize() { if( null != m_Server ) { this.m_Server.RequestQuestions() ; m_State = LanguageUIState.LanguageUIState_WaitInitialize ; } }
// Update is called once per frame void Update() { switch( m_State ) { case LanguageUIState.LanguageUIState_Invalid : m_State = LanguageUIState.LanguageUIState_StartInitialize ; break ; case LanguageUIState.LanguageUIState_StartInitialize : Process_StartInitialize() ; break ; case LanguageUIState.LanguageUIState_WaitInitialize : Process_WaitInitialize() ; break ; case LanguageUIState.LanguageUIState_StartRequestQuestion : Process_StartRequestQuestion() ; break ; case LanguageUIState.LanguageUIState_WaitRequestQuestion : Process_WaitRequestQuestion() ; break ; case LanguageUIState.LanguageUIState_UpdateQuestionToGUI : Process_UpdateQuestionToGUI() ; break ; case LanguageUIState.LanguageUIState_WaitPlayer : break ; case LanguageUIState.LanguageUIState_WaitBattlePlay : Process_WaitBattlePlay() ; break ; case LanguageUIState.LanguageUIState_StartRequestAddAnswer : Process_StartRequestAddAnswer() ; break ; case LanguageUIState.LanguageUIState_WaitRequestAddAnswer : Process_WaitRequestAddAnswer() ; break ; } }