public void translation(string name) { State target = this.states_[name] as State;//target state if (target == null)//if no target return! { return; } //if current, reset if(target == this.currState_[this.currState_.Count-1]) { target.over(); target.start(); return; }//如果是當(dāng)前狀態(tài)機(jī),從置當(dāng)前狀態(tài)機(jī) State publicState = null; ArrayList stateList = new ArrayList(); State tempState = target; string fatherName = tempState.fatherName; //do loop? while(tempState != null) { //reiterator current list for(var i = this.currState_.Count -1; i >= 0; i--) { State state = this.currState_[i] as State; //if has public? if(state == tempState) { publicState = state; break; } } //end if(publicState != null) { break;} //else push state_list stateList.Insert(0, tempState); //state_list.unshift(temp_state); if(fatherName != "") { tempState = this.states_[fatherName] as State; fatherName = tempState.fatherName; } else { tempState = null; } } //if no public return if (publicState == null){ return; } ArrayList newCurrState = new ArrayList(); bool under = true; //-- 析構(gòu)狀態(tài) for(int i2 = this.currState_.Count -1; i2>=0; --i2) { State state2 = this.currState_[i2] as State; if(state2 == publicState) { under = false; } if(under){ state2.over(); } else{ newCurrState.Insert(0, state2); } } //-- 構(gòu)建狀態(tài) for(int i3 = 0; i3 < stateList.Count; ++i3){ State state3 = stateList[i3] as State; state3.start(); newCurrState.Add(state3); } this.currState_ = newCurrState; }我看不懂這段代碼。能提示下嗎?
請(qǐng)問(wèn)下老師關(guān)于狀態(tài)機(jī)的代碼
gongxiaobo
2016-03-07 19:29:18