Пример #1
0
    static int Limit(IntPtr L)
    {
        int count = LuaDLL.lua_gettop(L);

        if (count == 2 && LuaScriptMgr.CheckTypes(L, 1, typeof(int), typeof(float)))
        {
            int   arg0 = (int)LuaDLL.lua_tonumber(L, 1);
            float arg1 = (float)LuaDLL.lua_tonumber(L, 2);
            float o    = Games.Module.Props.PropConfig.Limit(arg0, arg1);
            LuaScriptMgr.Push(L, o);
            return(1);
        }
        else if (count == 2 && LuaScriptMgr.CheckTypes(L, 1, typeof(Games.Module.Props.PropConfig), typeof(float)))
        {
            Games.Module.Props.PropConfig obj = (Games.Module.Props.PropConfig)LuaScriptMgr.GetNetObjectSelf(L, 1, "Games.Module.Props.PropConfig");
            float arg0 = (float)LuaDLL.lua_tonumber(L, 2);
            float o    = obj.Limit(arg0);
            LuaScriptMgr.Push(L, o);
            return(1);
        }
        else
        {
            LuaDLL.luaL_error(L, "invalid arguments to method: Games.Module.Props.PropConfig.Limit");
        }

        return(0);
    }
Пример #2
0
        public static Prop[] ParseCompactPropFields(string[] fields, PropConfig[] configs, int start, int end)
        {
            if (start >= fields.Length)
            {
                return(new Prop[0]);
            }

            if (end > fields.Length)
            {
                end = fields.Length;
            }

            int count = end - start;

            Prop[] props = new Prop[count];

            for (int i = 0; i < count; i++)
            {
                float      value  = fields[start + i].ToSingle();
                PropConfig config = configs[i];
                Prop       prop   = Prop.CreateInstance(config, value);

                props[i] = prop;
            }

            return(props);
        }
    static int CreateInstance(IntPtr L)
    {
        int count = LuaDLL.lua_gettop(L);

        if (count == 1)
        {
            string arg0 = LuaScriptMgr.GetLuaString(L, 1);
            Games.Module.Props.Prop o = Games.Module.Props.Prop.CreateInstance(arg0);
            LuaScriptMgr.PushObject(L, o);
            return(1);
        }
        else if (count == 2 && LuaScriptMgr.CheckTypes(L, 1, typeof(Games.Module.Props.PropConfig), typeof(float)))
        {
            Games.Module.Props.PropConfig arg0 = (Games.Module.Props.PropConfig)LuaScriptMgr.GetLuaObject(L, 1);
            float arg1 = (float)LuaDLL.lua_tonumber(L, 2);
            Games.Module.Props.Prop o = Games.Module.Props.Prop.CreateInstance(arg0, arg1);
            LuaScriptMgr.PushObject(L, o);
            return(1);
        }
        else if (count == 2 && LuaScriptMgr.CheckTypes(L, 1, typeof(int), typeof(float)))
        {
            int   arg0 = (int)LuaDLL.lua_tonumber(L, 1);
            float arg1 = (float)LuaDLL.lua_tonumber(L, 2);
            Games.Module.Props.Prop o = Games.Module.Props.Prop.CreateInstance(arg0, arg1);
            LuaScriptMgr.PushObject(L, o);
            return(1);
        }
        else
        {
            LuaDLL.luaL_error(L, "invalid arguments to method: Games.Module.Props.Prop.CreateInstance");
        }

        return(0);
    }
Пример #4
0
        public void ParseField(string field)
        {
            string[] str = field.Split(',');
            int      id  = str.GetInt32(0);

            config = PropConfig.GetInstance(id);
            value  = str.GetSingle(1);
        }
Пример #5
0
        public static Prop CreateInstance(PropConfig config, float value)
        {
            Prop prop = new Prop();

            prop.config = config;
            prop.value  = value;
            return(prop);
        }
Пример #6
0
    static int GetInstance(IntPtr L)
    {
        LuaScriptMgr.CheckArgsCount(L, 1);
        int arg0 = (int)LuaScriptMgr.GetNumber(L, 1);

        Games.Module.Props.PropConfig o = Games.Module.Props.PropConfig.GetInstance(arg0);
        LuaScriptMgr.PushObject(L, o);
        return(1);
    }
Пример #7
0
        public static float Limit(int id, float val)
        {
            PropConfig config = GetInstance(id);

            if (config != null)
            {
                return(config.Limit(val));
            }
            return(val);
        }
Пример #8
0
 public static int[] SortProp(this int[] ids)
 {
     Array.Sort(ids,
                delegate(int p1, int p2){
         PropConfig c1 = PropConfig.GetInstance(p1);
         PropConfig c2 = PropConfig.GetInstance(p2);
         return(c1.priority - c2.priority);
     });
     return(ids);
 }
Пример #9
0
        virtual protected void OnLoad(string filename, System.Object data)
        {
            if (data == null)
            {
                Debug.LogError("[Error] finelname=" + filename);
            }
            String text = data as String;

            List <PropConfig> ptsort = new List <PropConfig>();

            using (StringReader sr = new StringReader(text))
            {
                sr.ReadLine();
                sr.ReadLine();
                while (sr.Peek() >= 0)
                {
                    string   str    = sr.ReadLine();
                    string[] fields = str.Split(';');
                    if (string.IsNullOrEmpty(fields [0]))
                    {
                        continue;
                    }
                    int        i   = 0;
                    PropConfig ept = new PropConfig();
                    ept.id   = fields [i++].ToInt32();
                    ept.name = fields [i++];
                    ept.displayMultiplier = fields [i++].ToSingle();
                    ept.format            = fields [i++];
                    ept.mapping           = fields [i++].Trim();

                    if (!string.IsNullOrEmpty(fields [i].Trim()))
                    {
                        ept.limitMinValue = fields [i].ToSingle();
                    }
                    i++;

                    if (!string.IsNullOrEmpty(fields [i].Trim()))
                    {
                        ept.limitMaxValue = fields [i].ToSingle();
                    }
                    i++;

                    ept.priority = fields [i++].ToInt32();
                    ept.additive = fields [i++].ToInt32();
                    ept.type     = (PropType)fields [i++].ToInt32();
                    i++;
                    ept.commentName = fields [i++];
//                    ept.pass = (EnhPropPass)fields[5].ToInt32();
                    _propConfigs [ept.id] = ept;
                    ptsort.Add(ept);
                }
            }
            ptsort.Sort((t1, t2) => t1.priority - t2.priority);
            propsorts = ptsort.ToArray();
        }
Пример #10
0
 public static float[] Limit(this float[] src)
 {
     for (int i = 0; i < src.Length; i++)
     {
         if (src[i] != 0)
         {
             src[i] = PropConfig.Limit(i, src[i]);
         }
     }
     return(src);
 }
Пример #11
0
    static int _CreateGames_Module_Props_PropConfig(IntPtr L)
    {
        int count = LuaDLL.lua_gettop(L);

        if (count == 0)
        {
            Games.Module.Props.PropConfig obj = new Games.Module.Props.PropConfig();
            LuaScriptMgr.PushObject(L, obj);
            return(1);
        }
        else
        {
            LuaDLL.luaL_error(L, "invalid arguments to method: Games.Module.Props.PropConfig.New");
        }

        return(0);
    }
Пример #12
0
    static int set_limitMaxValue(IntPtr L)
    {
        object o = LuaScriptMgr.GetLuaObject(L, 1);

        Games.Module.Props.PropConfig obj = (Games.Module.Props.PropConfig)o;

        if (obj == null)
        {
            LuaTypes types = LuaDLL.lua_type(L, 1);

            if (types == LuaTypes.LUA_TTABLE)
            {
                LuaDLL.luaL_error(L, "unknown member name limitMaxValue");
            }
            else
            {
                LuaDLL.luaL_error(L, "attempt to index limitMaxValue on a nil value");
            }
        }

        obj.limitMaxValue = (float)LuaScriptMgr.GetNumber(L, 3);
        return(0);
    }
Пример #13
0
    static int set_type(IntPtr L)
    {
        object o = LuaScriptMgr.GetLuaObject(L, 1);

        Games.Module.Props.PropConfig obj = (Games.Module.Props.PropConfig)o;

        if (obj == null)
        {
            LuaTypes types = LuaDLL.lua_type(L, 1);

            if (types == LuaTypes.LUA_TTABLE)
            {
                LuaDLL.luaL_error(L, "unknown member name type");
            }
            else
            {
                LuaDLL.luaL_error(L, "attempt to index type on a nil value");
            }
        }

        obj.type = (Games.Module.Props.PropType)LuaScriptMgr.GetNetObject(L, 3, typeof(Games.Module.Props.PropType));
        return(0);
    }
Пример #14
0
    static int set_commentName(IntPtr L)
    {
        object o = LuaScriptMgr.GetLuaObject(L, 1);

        Games.Module.Props.PropConfig obj = (Games.Module.Props.PropConfig)o;

        if (obj == null)
        {
            LuaTypes types = LuaDLL.lua_type(L, 1);

            if (types == LuaTypes.LUA_TTABLE)
            {
                LuaDLL.luaL_error(L, "unknown member name commentName");
            }
            else
            {
                LuaDLL.luaL_error(L, "attempt to index commentName on a nil value");
            }
        }

        obj.commentName = LuaScriptMgr.GetString(L, 3);
        return(0);
    }
Пример #15
0
    static int get_name(IntPtr L)
    {
        object o = LuaScriptMgr.GetLuaObject(L, 1);

        Games.Module.Props.PropConfig obj = (Games.Module.Props.PropConfig)o;

        if (obj == null)
        {
            LuaTypes types = LuaDLL.lua_type(L, 1);

            if (types == LuaTypes.LUA_TTABLE)
            {
                LuaDLL.luaL_error(L, "unknown member name name");
            }
            else
            {
                LuaDLL.luaL_error(L, "attempt to index name on a nil value");
            }
        }

        LuaScriptMgr.Push(L, obj.name);
        return(1);
    }
Пример #16
0
        public static PropConfig[] ParsePropConfigFields(string[] fields, int start, int end)
        {
            if (start >= fields.Length)
            {
                return(new PropConfig[0]);
            }

            if (end > fields.Length)
            {
                end = fields.Length;
            }

            PropConfig[] configs = new PropConfig[end - start];

            for (int i = start; i < end; i++)
            {
                int id = fields[i].ToInt32();

                PropConfig config = PropConfig.GetInstance(id);
                configs[i - start] = config;
            }

            return(configs);
        }
Пример #17
0
        public static Prop CreateInstance(int id, float value)
        {
            PropConfig config = PropConfig.GetInstance(id);

            return(CreateInstance(config, value));
        }
Пример #18
0
 public static float Limit(this float src, int propId)
 {
     return(PropConfig.Limit(propId, src));
 }