コード例 #1
0
    void Start()
    {
        cube    = TheCube.GetComponent <TheCube>();
        textbox = Textbox.GetComponent <Text>();

        Debug.Log(script_path);
        script = Script.FromSource(script_path);

        var conditions = new Dictionary <string, Func <bool> >()
        {
            { "True", () => true },
            { "False", () => false },
            { "CurrentColorNotGreen", () => cube.CurrentColor != GREEN }
        };

        var actions = new Dictionary <string, Action>()
        {
            { "DoNothing", () => { } }
        };

        var functions = new Dictionary <string, Delegate>()
        {
            { "TurnCubeColor", (Action <string>)ChangeCubeColor },
            { "SetString", (Action <Script, string, string>)SetString }
        };

        script.Conditions = conditions;
        script.Actions    = actions;
        script.Functions  = functions;

        script.Prime();
        script.Validate();

        StartCoroutine(script.GetCurrentEnumerator(OnLine, SelectChoice, OnChoiceSelected, OnReturn));
    }
コード例 #2
0
    void Start()
    {
        cube    = TheCube.GetComponent <TheCube>();
        textbox = Textbox.GetComponent <Text>();

        Debug.Log(script_path);
        script = Script.FromSource(script_path);

        var conditions = new Dictionary <string, Func <bool> >()
        {
            { "True", () => true },
            { "False", () => false },
            { "CurrentColorNotGreen", () => cube.CurrentColor != GREEN }
        };

        var actions = new Dictionary <string, Action>()
        {
            { "DoNothing", () => { } },
            { "TurnCubeGreen", () => ChangeCubeColor(GREEN) },
            { "TurnCubeBlue", () => ChangeCubeColor(Color.blue) }
        };

        script.SetDelegates(conditions, actions);

        script.Prime();
        script.Validate();

        StartCoroutine(script.GetCurrentEnumerator(OnLine, SelectChoice, OnChoiceSelected, OnReturn));
    }