コード例 #1
0
ファイル: mode1.cs プロジェクト: GraphicGame/CSLightStudio
 void OnGUI()
 {
     GUI.TextArea(new Rect(0, 0, 600, 100), "这个模式演示传统的状态机模型\n"
         +"脚本如何和程序协同工作\n"
         +"按State1 由程序驱动状态机切换,状态实现在脚本中\n"
         +"按Play Stop会发送给脚本执行");
     if(GUI.Button(new Rect(0, 100, 200, 50), "State1"))
     {
         var state = new ScriptInstanceState("State1");
         state.mgr = smgr;
         smgr.ChangeState(state);
     }
     if (GUI.Button(new Rect(200, 100, 200, 50), "State2"))
     {
         var state = new ScriptInstanceState("State2");
         state.mgr = smgr;
         smgr.ChangeState(state);
     }
     if (GUI.Button(new Rect(400, 100, 200, 50), "State3"))
     {
         var state = new ScriptInstanceState("State3");
         state.mgr = smgr;
         smgr.ChangeState(state);
     }
     if(GUI.Button(new Rect(0,150,200,50),"Play"))
     {
         if(smgr.curState!=null)
             smgr.curState.ClickEvent(1);
     }
     if (GUI.Button(new Rect(200, 150, 200, 50), "Stop"))
     {
         if (smgr.curState != null)
             smgr.curState.ClickEvent(2);
     }
 }
コード例 #2
0
ファイル: StateMgr.cs プロジェクト: GraphicGame/CSLightStudio
 public void ChangeState(string state)
 {
     
     if(state=="state1")
     {
         GameObject sp = GameObject.Instantiate(Resources.Load("state1")) as GameObject;
         IState s = null;
         s = new ScriptInstanceState("State1");//从脚本创建
         //s = new State1();//从真实代码创建
         ChangeState(s,sp);
     }
     if (state == "state2")
     {
         GameObject sp = GameObject.Instantiate(Resources.Load("state2")) as GameObject;
         IState s = null;
         s = new ScriptInstanceState("State2");//从脚本创建
         //s = new State2();//从真实代码创建
         ChangeState(s, sp);
     }
     if (state == "state3")
     {
         GameObject sp = GameObject.Instantiate(Resources.Load("state3")) as GameObject;
         IState s = null;
         s = new ScriptInstanceState("State3");//从脚本创建
         //s = new State3();//从真实代码创建
         ChangeState(s, sp);
     }
 }
コード例 #3
0
 public void ChangeState(string state)
 {
     if (state == "state1")
     {
         GameObject sp = GameObject.Instantiate(Resources.Load("state1")) as GameObject;
         IState     s  = null;
         s = new ScriptInstanceState("State1");//从脚本创建
         //s = new State1();//从真实代码创建
         ChangeState(s, sp);
     }
     if (state == "state2")
     {
         GameObject sp = GameObject.Instantiate(Resources.Load("state2")) as GameObject;
         IState     s  = null;
         s = new ScriptInstanceState("State2");//从脚本创建
         //s = new State2();//从真实代码创建
         ChangeState(s, sp);
     }
     if (state == "state3")
     {
         GameObject sp = GameObject.Instantiate(Resources.Load("state3")) as GameObject;
         IState     s  = null;
         s = new ScriptInstanceState("State3");//从脚本创建
         //s = new State3();//从真实代码创建
         ChangeState(s, sp);
     }
 }
コード例 #4
0
    ScriptInstanceState CreateScriptState(string classtype)
    {
        ScriptInstanceState type = new ScriptInstanceState(classtype);

        type.mgr = this;
        return(type);
    }
コード例 #5
0
ファイル: mode1.cs プロジェクト: yongyoung888/CSLightStudio
 void OnGUI()
 {
     GUI.TextArea(new Rect(0, 0, 600, 100), "这个模式演示传统的状态机模型\n"
                  + "脚本如何和程序协同工作\n"
                  + "按State1 由程序驱动状态机切换,状态实现在脚本中\n"
                  + "按Play Stop会发送给脚本执行");
     if (GUI.Button(new Rect(0, 100, 200, 50), "State1"))
     {
         var state = new ScriptInstanceState("State1");
         state.mgr = smgr;
         smgr.ChangeState(state);
     }
     if (GUI.Button(new Rect(200, 100, 200, 50), "State2"))
     {
         var state = new ScriptInstanceState("State2");
         state.mgr = smgr;
         smgr.ChangeState(state);
     }
     if (GUI.Button(new Rect(400, 100, 200, 50), "State3"))
     {
         var state = new ScriptInstanceState("State3");
         state.mgr = smgr;
         smgr.ChangeState(state);
     }
     if (GUI.Button(new Rect(0, 150, 200, 50), "Play"))
     {
         if (smgr.curState != null)
         {
             smgr.curState.ClickEvent(1);
         }
     }
     if (GUI.Button(new Rect(200, 150, 200, 50), "Stop"))
     {
         if (smgr.curState != null)
         {
             smgr.curState.ClickEvent(2);
         }
     }
 }
コード例 #6
0
ファイル: StateMgr.cs プロジェクト: GraphicGame/CSLightStudio
 ScriptInstanceState CreateScriptState(string classtype)
 {
     ScriptInstanceState type = new ScriptInstanceState(classtype);
     type.mgr = this;
     return type;
 }