为了账号安全,请及时绑定邮箱和手机立即绑定

请问下老师关于状态机的代码

请问下老师关于状态机的代码

C#
gongxiaobo 2016-03-07 19:29:18
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; }//如果是当前状态机,从置当前状态机 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; //-- 析构状态 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); } } //-- 构建状态 for(int i3 = 0; i3 < stateList.Count; ++i3){ State state3 = stateList[i3] as State; state3.start(); newCurrState.Add(state3); } this.currState_ = newCurrState; }我看不懂这段代码。能提示下吗?
查看完整描述

目前暂无任何回答

  • 0 回答
  • 0 关注
  • 1380 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信