Ejemplo n.º 1
0
    static int nextInt(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 1)
            {
                XRandom obj = (XRandom)ToLua.CheckObject <XRandom>(L, 1);
                int     o   = obj.nextInt();
                LuaDLL.lua_pushinteger(L, o);
                return(1);
            }
            else if (count == 2)
            {
                XRandom obj  = (XRandom)ToLua.CheckObject <XRandom>(L, 1);
                int     arg0 = (int)LuaDLL.luaL_checknumber(L, 2);
                int     o    = obj.nextInt(arg0);
                LuaDLL.lua_pushinteger(L, o);
                return(1);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to method: XRandom.nextInt"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
Ejemplo n.º 2
0
    protected string RandomTmx(string[] tmxids, XRandom random)
    {
        int           num3;
        List <string> list   = new List <string>();
        int           index  = 0;
        int           length = tmxids.Length;

        while (index < length)
        {
            string str = tmxids[index];
            if (this.CanRandomTmx(str))
            {
                list.Add(str);
            }
            index++;
        }
        if (random != null)
        {
            num3 = random.nextInt(0, list.Count);
        }
        else
        {
            num3 = GameLogic.Random(0, list.Count);
        }
        string tmxid = list[num3];

        this.AddUsedTmx(tmxid);
        if (!GameLogic.Release.MapCreatorCtrl.HaveTmx(tmxid))
        {
            object[] args = new object[] { GameLogic.Hold.BattleData.Level_CurrentStage, tmxid };
            SdkManager.Bugly_Report("RoomGenerateBase", Utils.FormatString("stage:{0} RandomTmx[{1}] is dont have!!!", args));
            return(this.RandomTmx(tmxids));
        }
        return(tmxid);
    }