Exemplo n.º 1
0
    /// <summary>
    /// If Playing a ScenarioNode , then the Played Scenario is the Instance.
    /// </summary>
    public void Play()
    {
        CheckInstance();

        SystemUtility.ClearAllTextBoxMessage();

        VM vm = VM.Instance;
        vm.currentScenarioName = gameObject.name;

        // ScenarioScript Mode.
        /*		if( useScenarioScript ){
            ViNoToolkit.KAGInterpreter kag = new ViNoToolkit.KAGInterpreter();
         		List<byte> byteList = kag.Interpret( scenarioScript.text );
            ByteCodes btcodes = new ByteCodes( byteList.ToArray() );

            btcodes.Add( Opcode.END );

            vm.SetCode( btcodes.GetCode() );
        }
        //*/
        // Default Mode.
        //		else{
            ByteCodes btcodes = null;
            if( startNode.gameObject == this.gameObject ){
                btcodes = new ByteCodes();
                btcodes.Init();
        #if true
                startNode.ToByteCode( btcodes );
        #else
                TEST_ADD_CODE( btcodes , GetComponents<ViNode>() );
        #endif
            }
            else{
                btcodes = Compile();//useCompiledScript ? new ByteCodes( compiledScriptFile.bytes ) : Compile();
            }

            btcodes.Add( Opcode.END );

            vm.SetCode( btcodes.GetCode() );
        //		}

        if( startFromSave ){
            //if ScenarioCtrl exists in this scene, then loaddata from that info.
            ScenarioCtrl sc = ScenarioCtrl.Instance;
            if( sc != null ){
                ViNo.LoadData( sc.fileName , ref sc.saveInfo );
            }
        }
        else{
            if( useScenarioScript ){
                vm.Run();
            }
            else{
                if( startNode == null ){
                    vm.Run();
                }
                else{
                    PlayFromStartNode();
                }
            }
        }
    }
Exemplo n.º 2
0
    /// <summary>
    /// If Playing a ScenarioNode , then the Played Scenario is the Instance.
    /// </summary>
    public void Play()
    {
        CheckInstance();

        SystemUtility.ClearAllTextBoxMessage();

        VM vm = VM.Instance;

        vm.currentScenarioName = gameObject.name;

        // ScenarioScript Mode.

/*		if( useScenarioScript ){
 *                      ViNoToolkit.KAGInterpreter kag = new ViNoToolkit.KAGInterpreter();
 *                      List<byte> byteList = kag.Interpret( scenarioScript.text );
 *                      ByteCodes btcodes = new ByteCodes( byteList.ToArray() );
 *
 *                      btcodes.Add( Opcode.END );
 *
 *                      vm.SetCode( btcodes.GetCode() );
 *              }
 * //*/
        // Default Mode.
//		else{
        ByteCodes btcodes = null;

        if (startNode.gameObject == this.gameObject)
        {
            btcodes = new ByteCodes();
            btcodes.Init();
#if true
            startNode.ToByteCode(btcodes);
#else
            TEST_ADD_CODE(btcodes, GetComponents <ViNode>());
#endif
        }
        else
        {
            btcodes = Compile();                    //useCompiledScript ? new ByteCodes( compiledScriptFile.bytes ) : Compile();
        }

        btcodes.Add(Opcode.END);

        vm.SetCode(btcodes.GetCode());
//		}

        if (startFromSave)
        {
            //if ScenarioCtrl exists in this scene, then loaddata from that info.
            ScenarioCtrl sc = ScenarioCtrl.Instance;
            if (sc != null)
            {
                ViNo.LoadData(sc.fileName, ref sc.saveInfo);
            }
        }
        else
        {
            if (useScenarioScript)
            {
                vm.Run();
            }
            else
            {
                if (startNode == null)
                {
                    vm.Run();
                }
                else
                {
                    PlayFromStartNode();
                }
            }
        }
    }