コード例 #1
0
    private void prepareWave()
    {
        DynValue nextWaves = script.GetVar("nextwaves");

        waves     = new Script[nextWaves.Table.Length];
        waveNames = new string[waves.Length];
        int currentWaveScript = 0;

        try
        {
            for (int i = 0; i < waves.Length; i++)
            {
                currentWaveScript = i;
                waves[i]          = LuaScriptBinder.boundScript();
                DynValue ArenaStatus = UserData.Create(ArenaSizer.luaStatus);
                waves[i].Globals.Set("Arena", ArenaStatus);
                waves[i].Globals["State"]               = (Action <string>)UIController.instance.SwitchStateOnString;
                waves[i].Globals["CreateProjectile"]    = (Func <Script, string, float, float, DynValue>)CreateProjectile;
                waves[i].Globals["CreateProjectileAbs"] = (Func <Script, string, float, float, DynValue>)CreateProjectileAbs;
                waves[i].Globals["EndWave"]             = (Action)endWaveTimer;
                if (nextWaves.Table.Get(i + 1).Type != DataType.String)
                {
                    UnitaleUtil.displayLuaError(StaticInits.ENCOUNTER, "Non-string value encountered in nextwaves table");
                    return;
                }
                else
                {
                    waveNames[i] = nextWaves.Table.Get(i + 1).String;
                }
                waves[i].DoString(ScriptRegistry.Get(ScriptRegistry.WAVE_PREFIX + nextWaves.Table.Get(i + 1).String));
            }
        }
        catch (InterpreterException ex)
        {
            UnitaleUtil.displayLuaError(nextWaves.Table.Get(currentWaveScript + 1).String + ".lua", ex.DecoratedMessage);
        }
    }
コード例 #2
0
 public ScriptWrapper()
 {
     script = LuaScriptBinder.boundScript();
     this.Bind("_getv", (Func <Script, string, DynValue>) this.GetVar);
     script.DoString("setmetatable({}, {__index=function(t, name) return _getv(name); end})");
 }