Пример #1
0
    static void Postfix(Script ___myLuaScript, string scriptPath)
    {
        object obj;

        obj = ___myLuaScript.Globals["Init"];
        if (obj != null && scriptPath != null)
        {
            if (!LuaPowerData.luaFunctionLoaded.Contains(scriptPath))
            {
                S.I.mainCtrl.StartCoroutine(MoreLuaPower_FunctionHelper.EffectRoutine(___myLuaScript.CreateCoroutine(obj)));
                LuaPowerData.luaFunctionLoaded.Add(scriptPath);
            }
            ___myLuaScript.Globals.Remove("Init");
        }
        obj = ___myLuaScript.Globals["Awake"];
        if (obj != null)
        {
            S.I.mainCtrl.StartCoroutine(MoreLuaPower_FunctionHelper.EffectRoutine(___myLuaScript.CreateCoroutine(obj)));
            ___myLuaScript.Globals.Remove("Awake");
        }
        obj = ___myLuaScript.Globals["Update"];
        if (obj != null)
        {
            bool unique = true;
            foreach (object o in PowerMonoBehavior.UpdateScripts)
            {
                if (DynValue.FromObject(___myLuaScript, o).Function.EntryPointByteCodeLocation == DynValue.FromObject(___myLuaScript, obj).Function.EntryPointByteCodeLocation)
                {
                    unique = false;
                }
            }
            if (unique)
            {
                PowerMonoBehavior.UpdateScripts.Add(obj);
                PowerMonoBehavior.UpdateBaseScripts.Add(___myLuaScript);
            }
            ___myLuaScript.Globals.Remove("Update");
        }
        obj = ___myLuaScript.Globals["GameUpdate"];
        if (obj != null)
        {
            bool unique = true;
            foreach (object o in PowerMonoBehavior.GameUpdateScripts)
            {
                if (DynValue.FromObject(___myLuaScript, o).Function.EntryPointByteCodeLocation == DynValue.FromObject(___myLuaScript, obj).Function.EntryPointByteCodeLocation)
                {
                    unique = false;
                }
            }
            if (unique)
            {
                PowerMonoBehavior.GameUpdateScripts.Add(obj);
                PowerMonoBehavior.GameUpdateBaseScripts.Add(___myLuaScript);
            }
            ___myLuaScript.Globals.Remove("GameUpdate");
        }
    }
 public void Update()
 {
     for (int i = 0; i < UpdateScripts.Count; i++)
     {
         S.I.mainCtrl.StartCoroutine(MoreLuaPower_FunctionHelper.EffectRoutine(UpdateBaseScripts[i].CreateCoroutine(UpdateScripts[i])));
     }
     if (Input.GetKeyDown(KeyCode.BackQuote))
     {
         EnableDeveloperTools();
     }
 }
 public void FixedUpdate()
 {
     if (S.I.batCtrl.GameState == GState.MainMenu ||
         S.I.batCtrl.GameState == GState.HeroSelect ||
         S.I.batCtrl.GameState == GState.GameOver)
     {
         return;
     }
     for (int i = 0; i < GameUpdateScripts.Count; i++)
     {
         S.I.mainCtrl.StartCoroutine(MoreLuaPower_FunctionHelper.EffectRoutine(GameUpdateBaseScripts[i].CreateCoroutine(GameUpdateScripts[i])));
     }
 }
    protected void GetPostProcessGenerators(World world)
    {
        DynValue worldVal     = UserData.Create(world);
        DynValue generatorVal = UserData.Create(this);

        for (int i = 0; i < WorldPostScripts.Count; i++)
        {
            WorldPostBaseScripts[i].Globals["world"]     = worldVal;
            WorldPostBaseScripts[i].Globals["generator"] = generatorVal;
            S.I.mainCtrl.StartCoroutine(MoreLuaPower_FunctionHelper.EffectRoutine(WorldPostBaseScripts[i].CreateCoroutine(WorldPostScripts[i])));
            WorldPostBaseScripts[i].Globals.Remove("world");
            WorldPostBaseScripts[i].Globals.Remove("generator");
        }
        Debug.Log("Got postprocess world generators!");
    }
Пример #5
0
 //Lua event for zones.
 public static void TriggerZoneEvent(string eventName)
 {
     for (int i = 0; i < ZoneEventScripts.Count; i++)
     {
         ZoneEventBaseScripts[i].Globals["world"]     = S.I.runCtrl.currentWorld;
         ZoneEventBaseScripts[i].Globals["eventName"] = eventName;
         ZoneEventBaseScripts[i].Globals["ctrl"]      = S.I.batCtrl;
         ZoneEventBaseScripts[i].Globals["spawnCtrl"] = S.I.spCtrl;
         S.I.mainCtrl.StartCoroutine(MoreLuaPower_FunctionHelper.EffectRoutine(ZoneEventBaseScripts[i].CreateCoroutine(ZoneEventScripts[i])));
         ZoneEventBaseScripts[i].Globals.Remove("eventName");
         ZoneEventBaseScripts[i].Globals.Remove("ctrl");
         ZoneEventBaseScripts[i].Globals.Remove("spawnCtrl");
         ZoneEventBaseScripts[i].Globals.Remove("world");
     }
     CustomWorldGenerator.MakeZoneSectionVisible(eventName);
 }