一、
public SoldierStateBase IsContaintState(SoldierStateType type)
{
//判断容器中有某个值
for (int i = 0; i < stateList.Count ; i++) {
if (stateList[i].StateType==type ) {
return stateList [i];
}
}
return null;
}
二、
public SoldierStateBase IsContaintState(SoldierStateType type)
{
return stateList.Find(delegate (SoldierStateBase state)
{
return state.StateType == type ? true : false;
});
}
三、
public SoldierStateBase IsContaintState(SoldierStateType type)
{
SoldierStateBase findState= stateList.Find(delegate (SoldierStateBase state)
{
return state.StateType.Equals(type);
});
return null;
}
public SoldierStateBase IsContaintState(SoldierStateType type)
{
int index=0;
index=stateList.FindIndex(x=>x.SoldierStateType ==type);
if(index!=-1){
return stateList[index].value;}
else{
return null;}
}