资源简介
该工具集便于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< this.currState_.Count; ++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 < stateList.Count; ++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< self.currState_.Count; ++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法调用系统手型鼠标指针
- 下一篇:七段共阴极数码管引脚及原理
相关资源
- VLC for Unity 插件
- 一款Untiy的日期选择插件,非常好用,
- unity摄像机控制系统源码Camera Control
- unity插件连接安卓蓝牙测试可用
- Unity 层级编辑器插件最新版 Hierarc
- Time of Day Unity插件
- Super ScrollView for UGUI.unitypackage
- book-page.unitypackage
- unity插件——WorldComposer
- unity最新录屏插件
- Unity插件:NodeCanvas 2.6.2
- UGUI MiniMap 1.8
-
VLC Pla
yer for Unity插件 - Bolt_2_0_0a10.unitypackage
- AVpro Video
-
VLC Pla
yer for Unity插件使用测试工程 - EasyTouch5
- DirectX 11 Low Poly Shader - DX11低多边形着
- Playmaker 1.9.0 p20
- Liquid Volume
- Realistic Water v2.0.3 unity 资源 海洋 大海
- OpenCVForUnity,Unity插件
- UnityAsset_UniMerge_v1.7.5
- unity语音识别插件USpeaker
- unity视觉范围视觉迷雾插件Fog Of War
- unity插件 build report tool
- Unity glTF 2.0 ExporterUnity导出glTF插件
- 百度语音识别 Unity插件
- Unity插件 Scratch Card 1.6 刮刮卡/刮刮乐
- Unity插件之NatCorder1.5.1
评论
共有 条评论