資源簡介
該工具集便于unity3d程序員快捷開發,集成了許多方法,可以在游戲中直接調用,具體用法,網上有很多資料。

代碼片段和文件信息
using?UnityEngine;
using?System.Collections;
using?System.Collections.Generic;
namespace?GDGeek{
public?class?FSM?{
private?Dictionary?states_?=?new?Dictionary();
private?ArrayList?currState_?=?new?ArrayList();
public?FSM(){
State?root?=?new?State();
root.name?=?“root“;
this.states_[“root“]??=?root;
this.currState_.Add(root);
}
public?void?addState(string?stateName?State?state){
this.addState?(stateName?state?““);
}
public?void?addState(string?stateName?State?state?string?fatherName){
if(fatherName?==?““){
state.fatherName?=?“root“;
}
else{
state.fatherName?=?fatherName;
}
state.getCurrState?=?delegate?(string?name){
for(int?i?=?0;?i State?s?=?this.currState_[i]?as?State;
if(s.name?==?name)
{
return?s;
}
}
return?null;
};
this.states_[stateName]?=?state;
}
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? State?state3?=?stateList[i3]?as?State;
state3.start();
newCurrState.Add(state3);
}
this.currState_?=?newCurrState;
}
public?State?getCurrState(string?name)
{
var?self?=?this;
for(var?i?=0;?i {
State?state?=?self.currState_[i]?as??State;
if(state.name?==?name)
{
return?state;
}
}
return?null;
}
public?void?init(string?state
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????6148??2014-12-19?23:12??GDGeek\.DS_Store
?????文件?????????74??2014-12-08?10:16??GDGeek\.git\COMMIT_EDITMSG
?????文件????????277??2014-12-01?14:22??GDGeek\.git\config
?????文件?????????73??2014-12-01?14:22??GDGeek\.git\desc
?????文件?????????87??2014-12-10?16:58??GDGeek\.git\FETCH_HEAD
?????文件?????????23??2014-12-01?14:22??GDGeek\.git\HEAD
?????文件????????452??2014-12-01?14:22??GDGeek\.git\hooks\applypatch-msg.sample
?????文件????????896??2014-12-01?14:22??GDGeek\.git\hooks\commit-msg.sample
?????文件????????160??2014-12-01?14:22??GDGeek\.git\hooks\post-commit.sample
?????文件????????552??2014-12-01?14:22??GDGeek\.git\hooks\post-receive.sample
?????文件????????189??2014-12-01?14:22??GDGeek\.git\hooks\post-update.sample
?????文件????????398??2014-12-01?14:22??GDGeek\.git\hooks\pre-applypatch.sample
?????文件???????1704??2014-12-01?14:22??GDGeek\.git\hooks\pre-commit.sample
?????文件???????4951??2014-12-01?14:22??GDGeek\.git\hooks\pre-reba
?????文件???????1239??2014-12-01?14:22??GDGeek\.git\hooks\prepare-commit-msg.sample
?????文件???????3611??2014-12-01?14:22??GDGeek\.git\hooks\update.sample
?????文件??????16697??2014-12-09?10:16??GDGeek\.git\index
?????文件????????250??2014-12-01?14:22??GDGeek\.git\info\exclude
?????文件???????1243??2014-12-08?10:16??GDGeek\.git\logs\HEAD
?????文件???????1243??2014-12-08?10:16??GDGeek\.git\logs\refs\heads\master
?????文件????????167??2014-12-01?14:22??GDGeek\.git\logs\refs\remotes\origin\HEAD
?????文件???????1284??2014-12-08?17:18??GDGeek\.git\logs\refs\remotes\origin\master
?????文件????????159??2014-12-01?14:23??GDGeek\.git\ob
?????文件????????573??2014-12-08?10:14??GDGeek\.git\ob
?????文件????????291??2014-12-01?14:23??GDGeek\.git\ob
?????文件???????1286??2014-12-01?14:23??GDGeek\.git\ob
?????文件????????260??2014-12-01?14:23??GDGeek\.git\ob
?????文件????????362??2014-12-01?14:23??GDGeek\.git\ob
?????文件????????596??2014-12-01?14:23??GDGeek\.git\ob
?????文件????????160??2014-12-01?14:23??GDGeek\.git\ob
............此處省略561個文件信息
- 上一篇:API法調用系統手型鼠標指針
- 下一篇:七段共陰極數碼管引腳及原理
評論
共有 條評論