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;
}
我看不懂这段代码。能提示下吗?
相关分类