public void PreloadPose(LuaInterface.LuaTable pose)
 {
     foreach (string imageName in pose.ToArray().Cast <string>())
     {
         AssetLoader.Preload(AssetCacheType.StandingLayer, System.IO.Path.Combine(imageFolder, imageName));
     }
 }
예제 #2
0
 public override void Leave()
 {
     MessageManager.GetInstance().gameMessageCenter.UnRegist(GameLogic_LoginSuccessed, MessageCallback);
     luaMsgTable.Dispose();
     luaMsgTable = null;
     base.Leave();
 }
예제 #3
0
 public void WriteBytes(LuaInterface.LuaTable value)
 {
     for (int i = 1; i <= value.Keys.Count; i++)
     {
         Data.Add(Convert.ToByte(value[i]));
     }
 }
예제 #4
0
        //static LuaManagerKopi lua;
        public override AssetLoadResult <AssetList> Load(String path)
        {
            AssetList assetList = new AssetList();

            ////Create Lua State
            //if (lua == null)
            //    lua = new LuaManagerKopi();
            LuaManagerKopi lua = new LuaManagerKopi();

            List <String> ignores = new List <string>();

            //Find the objects already in lua's global table
            foreach (var key in (lua["_G"] as LuaInterface.LuaTable).Keys)
            {
                ignores.Add(key.ToString());
            }

            //Run the file
            using (var stream = Engine.AssetManager.AssetSource.Open(path))
                lua.DoFile(stream);

            //For each object in lua's global table
            LuaInterface.LuaTable globals = lua["_G"] as LuaInterface.LuaTable;
            foreach (var key in globals.Keys)
            {
                String keyName = key.ToString();

                //If object was present before, we skip it
                if (ignores.Contains(keyName))
                {
                    continue;
                }

                // keys beginning by "_" are ignored.
                if (keyName.StartsWith("_"))
                {
                    continue;
                }

                //Convert the lua table to an asset
                AssetDefinition asset = ConvertTable(keyName, globals[key] as LuaInterface.LuaTable);
                assetList.Definitions.Add(asset);

                String test = AssetDefinitionXMLHelper.ToXml(asset);
            }

            List <IAssetDependency> dependencies = new List <IAssetDependency>();

            dependencies.Add(Engine.AssetManager.AssetSource.CreateDependency(path));

            AssetLoadResult <AssetList> result;

            result.Instance     = assetList;
            result.Dependencies = dependencies;

            return(result);
        }
예제 #5
0
        public override void Leave()
        {
            UnRegistLuaMessage();
            luaMsgTable.Dispose();
            luaMsgTable = null;

            CallLuaFunc(luaFunLeave);
            base.Leave();
        }
예제 #6
0
        public void SetPoseDelayed(LuaInterface.LuaTable pose)
        {
            if (!CheckCharacterName("pose"))
            {
                return;
            }

            var prefix  = nameToConfig[characterName].prefix;
            var poseStr = PoseArrayToString(pose.ToArray().Cast <string>().Select(x => prefix + x).ToArray());

            characterToImageName[characterName] = poseStr;
        }
예제 #7
0
        public void SetLuaHandler(LuaInterface.LuaTable lua_obj, LuaInterface.LuaFunction on_finish, LuaInterface.LuaFunction on_event)
        {
            LuaObj   = lua_obj;
            OnFinish = on_finish;
            OnEvent  = on_event;

            for (int i = 0; i < UiAinm.Length; i++)
            {
                UnregisterEventHandler(i, InternalOnEvent);
                RegisterEventHandler(i, InternalOnEvent);
            }
        }
예제 #8
0
        AssetDefinition ConvertTable(String name, LuaInterface.LuaTable t)
        {
            String type = (String)t["_class"];

            AssetDefinition asset = new AssetDefinition(name, type);

            foreach (var key in t.Keys)
            {
                String keyName = key.ToString();
                Copy(asset.Fields, keyName, t[key]);
            }

            return(asset);
        }
예제 #9
0
        public override void Enter(string preStateName)
        {
            base.Enter(preStateName);

            loginSuccess = false;

            UFrameLuaClient.GetMainState().DoFile("UFrame/Game/GameState/StateLogin.lua");
            luaMsgTable = UFrameLuaClient.GetMainState().GetTable("MessageCode");
            luaFunEnter = UFrameLuaClient.GetMainState().GetFunction("StateLogin.Enter");
            luaFunLeave = UFrameLuaClient.GetMainState().GetFunction("StateLogin.Leave");

            CallLuaFunc(luaFunEnter);

            RegistLuaMessage();
        }
예제 #10
0
        public static tmTreeNode ParseProfile(Engine engine)
        {
            ScriptEngine se = engine.GetScriptEngine(0) as ScriptEngine;

            LuaInterface.Lua      lua   = se.GetScriptHandle() as LuaInterface.Lua;
            LuaInterface.LuaTable table = lua["items"] as LuaInterface.LuaTable;
            if (table == null)
            {
                throw new System.Exception("Invalid profile,could't found the global variabl \"items\"");
            }

            tmTreeNode tree = new tmTreeNode("Root");   //root

            ParseLuaTable(tree, table);

            return(tree);
        }
예제 #11
0
파일: Form1.cs 프로젝트: weimingtom/pap2
        public ArrayList lt2ArrayList(LuaEx lua, string keyword)
        {
            LuaInterface.LuaTable lt  = lua.GetTable(keyword);
            ArrayList             ret = new ArrayList();

            if (lt == null)
            {
                return(ret);
            }
            foreach (object k in lt.Keys)
            {
                object[] astr = { k.ToString(), lt[k].ToString() };
                ret.Add(astr);
            }
            return(ret);
            //ret.Count
        }
예제 #12
0
        public void InitRC4(byte[] CMKey, LuaInterface.LuaTable SMKey, LuaInterface.LuaTable Hash, string login)
        {
            byte[] SMKeyBytes = new byte[SMKey.Keys.Count];
            byte[] HashBytes  = new byte[Hash.Keys.Count];
            for (int i = 1; i <= SMKey.Keys.Count; i++)
            {
                SMKeyBytes[i - 1] = Convert.ToByte(SMKey[i]);
            }

            for (int i = 1; i <= Hash.Keys.Count; i++)
            {
                HashBytes[i - 1] = Convert.ToByte(Hash[i]);
            }

            Program.RC4_Client = new RC4(GetKey(CMKey, HashBytes, login));
            Program.RC4_Server = new RC4(GetKey(SMKeyBytes, HashBytes, login));

            Program.Encode = true;
        }
예제 #13
0
        public byte[] ConvertLuaTableToBytes(object tcpDataObj)
        {
            List <string> tcpDataList = new List <string>();
            List <string> keyList     = new List <string>();

            LuaInterface.LuaTable tcpDataLT = (LuaInterface.LuaTable)tcpDataObj;

            ConvertLuaTableToList(tcpDataLT, out keyList, out tcpDataList);

            if (tcpDataList == null || tcpDataList.Count == 0)
            {
                return(null);
            }
            byte[] tcpDataByte = new byte[tcpDataList.Count];
            for (int i = 0; i < tcpDataList.Count; i++)
            {
                tcpDataByte[i] = Byte.Parse(tcpDataList[i]);
            }
            return(tcpDataByte);
        }
예제 #14
0
        private void btnGenerate_Click(object sender, EventArgs e)
        {
            String method = cbxGenMethod.Text + ".GetName";

            object[] res = m_luaInterface.Call(method, null);
            try
            {
                LuaInterface.LuaTable namelist = (LuaInterface.LuaTable)res[0];
                foreach (object key in namelist.Keys)
                {
                    tbxName.Text = namelist[key].ToString();
                }
            }
            catch (Exception ex)
            {
                String msg = "Unable to convert " + cbxGenMethod.Text + ".GetName() result to a Lua table.";
                m_log.Error(msg, ex);
                MessageBox.Show(msg, "Error Generating Names");
                return;
            }
        }
예제 #15
0
 private static void ConvertLuaTableToList(LuaInterface.LuaTable lt, out List <string> keyList, out List <string> valueList)
 {
     object[] arrayValues = new object[100];
     object[] arrayKeys   = new object[100];
     lt.Values.CopyTo(arrayValues, 0);
     lt.Keys.CopyTo(arrayKeys, 0);
     keyList   = new List <string>();
     valueList = new List <string>();
     for (int i = 0; i < arrayValues.Length; i++)
     {
         try
         {
             keyList.Add(arrayKeys.GetValue(i).ToString());
             valueList.Add(arrayValues.GetValue(i).ToString());
         }
         catch
         {
             break;
         }
     }
 }
예제 #16
0
 public string WaitForPlaces(LuaInterface.LuaTable tbl, int ms = 500, int max = 5)
 {
     try
     {
         List <string> lst = new List <string>();
         foreach (var x in tbl.Values)
         {
             lst.Add(x.ToString());
         }
         PlaceEnterty pe = _Gm.WaitToPlaces(lst.ToArray(), ms, max);
         if (pe == null)
         {
             return(null);
         }
         return(pe.Key);
     }
     catch (KeyNotFoundException ex)
     {
         throw new Exception("WaitForPlaces,错误无法找到指定地点!");
     }
 }
예제 #17
0
 public string CheckPlaces(LuaInterface.LuaTable strs)
 {
     try
     {
         List <string> lst = new List <string>();
         foreach (var x in strs.Values)
         {
             lst.Add(x.ToString());
         }
         PlaceEnterty pe = _Gm.CheckPlaces(lst.ToArray());
         if (pe == null)
         {
             return(null);
         }
         return(pe.Key);
     }
     catch (KeyNotFoundException ex)
     {
         throw new Exception("CheckPlaces,错误无法找到指定地点!");
     }
 }
예제 #18
0
        static void ParseLuaTable(tmTreeNode tree, LuaInterface.LuaTable table)
        {
            try
            {
                foreach (object index in table.Keys)
                {
                    LuaInterface.LuaTable luaItem = table[index] as LuaInterface.LuaTable;
                    if (null == luaItem)
                    {
                        continue;
                    }
                    TestItem aItem = new TestItem();
                    //Console.WriteLine("LuaInterface.LuaTable<{0}> <{1}>", index as string,luaItem.ToString());
                    foreach (object key in luaItem.Keys)
                    {
                        if (null == luaItem[key])
                        {
                            continue;
                        }
                        //error occur here.
                        //Console.WriteLine("LuaInterface.luaItem[{0}],[{1}]", key as string, luaItem[key].ToString());
                        aItem[key.ToString()] = luaItem[key].ToString();
                    }
                    tmTreeNode node = new tmTreeNode(aItem);

                    tree.AddChildNode(node);

                    LuaInterface.LuaTable sub = luaItem["sub"] as LuaInterface.LuaTable;

                    if (null != sub)
                    {
                        ParseLuaTable(node, sub);
                    }
                }
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.Message + "In ParseLuaTable");
            }
        }
예제 #19
0
        public override void Enter(string preStateName)
        {
            Logger.LogWarp.Log("StateLogin Enter");
            base.Enter(preStateName);

            loginSuccess = false;

            UFrameLuaClient.GetMainState().DoFile("UFrame/Game/GameState/StateLogin.lua");
            var luaFunEnter = UFrameLuaClient.GetMainState().GetFunction("StateLogin.Enter");

            if (luaFunEnter != null)
            {
                Logger.LogWarp.Log("call luaFunEnter");
                luaFunEnter.Call();
                luaFunEnter.Dispose();
                luaFunEnter = null;
            }

            luaMsgTable = UFrameLuaClient.GetMainState().GetTable("MessageCode");
            GameLogic_LoginSuccessed = (int)(double)(luaMsgTable["GameLogic_LoginSuccessed"]);
            MessageManager.GetInstance().gameMessageCenter.Regist(GameLogic_LoginSuccessed, MessageCallback);
        }
예제 #20
0
파일: Form1.cs 프로젝트: weimingtom/pap2
        public string lt2ArrayList_parms(LuaEx lua, string keyword)
        {
            string ret = keyword;

            try
            {
                LuaInterface.LuaTable lt = (LuaInterface.LuaTable)(lua.DoString("return debug.getinfo(" + keyword + ")")[0]);
                if (lt["what"].ToString() == "Lua")
                {
                    ret += "(";
                    ret += lt["strparms"].ToString();
                    if (lt["has3dot"].ToString() == "1")
                    {
                        ret += ",...";
                    }
                    ret += ")";
                }
            }
            catch
            {
                ret = "";
            }
            return(ret);
        }
예제 #21
0
        public CUPRP ParseUPRP(LuaInterface.LuaTable t)
        {
            CUPRP cUPRP = new CUPRP();



            ushort STATUSFLAG  = 0;
            ushort STATUSVALID = 0;

            if (t["clocked"] != null)
            {
                bool v = (bool)t["clocked"];
                STATUSVALID += (ushort)(0b1 << 0);
                if (v)
                {
                    STATUSFLAG += (ushort)(0b1 << 0);
                }
            }
            if (t["burrowed"] != null)
            {
                bool v = (bool)t["burrowed"];
                STATUSVALID += (ushort)(0b1 << 1);
                if (v)
                {
                    STATUSFLAG += (ushort)(0b1 << 1);
                }
            }
            if (t["intransit"] != null)
            {
                bool v = (bool)t["intransit"];
                STATUSVALID += (ushort)(0b1 << 2);
                if (v)
                {
                    STATUSFLAG += (ushort)(0b1 << 2);
                }
            }
            if (t["hallucinated"] != null)
            {
                bool v = (bool)t["hallucinated"];
                STATUSVALID += (ushort)(0b1 << 3);
                if (v)
                {
                    STATUSFLAG += (ushort)(0b1 << 3);
                }
            }
            if (t["invincible"] != null)
            {
                bool v = (bool)t["invincible"];
                STATUSVALID += (ushort)(0b1 << 4);
                if (v)
                {
                    STATUSFLAG += (ushort)(0b1 << 4);
                }
            }


            ushort POINTVALID = 0;

            if (t["hitpoint"] != null)
            {
                double v = (double)t["hitpoint"];
                POINTVALID    += (ushort)(0b1 << 1);
                cUPRP.HITPOINT = (byte)v;
            }
            if (t["shield"] != null)
            {
                double v = (double)t["shield"];
                POINTVALID       += (ushort)(0b1 << 2);
                cUPRP.SHIELDPOINT = (byte)v;
            }
            if (t["energy"] != null)
            {
                double v = (double)t["energy"];
                POINTVALID       += (ushort)(0b1 << 3);
                cUPRP.ENERGYPOINT = (byte)v;
            }
            if (t["resource"] != null)
            {
                double v = (double)t["resource"];
                POINTVALID    += (ushort)(0b1 << 4);
                cUPRP.RESOURCE = (uint)v;
            }
            if (t["hanger"] != null)
            {
                double v = (double)t["hanger"];
                POINTVALID  += (ushort)(0b1 << 5);
                cUPRP.HANGAR = (ushort)v;
            }


            cUPRP.STATUSVALID = STATUSVALID;
            cUPRP.POINTVALID  = POINTVALID;
            cUPRP.STATUSFLAG  = STATUSFLAG;


            return(cUPRP);
        }
 public void SetPose(LuaInterface.LuaTable pose, bool fade = true)
 {
     this.RuntimeAssert(characterTextureMerger != null && textureChanger != null,
                        "CharacterTextureMerger and OverlayTextureChanger must be present when setting pose.");
     SetPose(pose.ToArray().Cast <string>().ToArray(), fade);
 }
예제 #23
0
        public void Triggerinterpreter(LuaInterface.LuaTable t)
        {
            CTrigger cTrigger = new CTrigger(mapData, IsTrigger);

            if (t["players"] != null)
            {
                LuaInterface.LuaTable players = (LuaInterface.LuaTable)t["players"];
                for (int i = 1; i <= players.Values.Count; i++)
                {
                    double v    = (double)Lua.GetFunction("ParsePlayer").Call(players[i])[0];
                    int    pnum = (int)v;

                    cTrigger.playerlist[pnum] = 1;
                }
            }
            if (t["flag"] != null)
            {
                LuaInterface.LuaTable flags = (LuaInterface.LuaTable)t["flag"];

                ushort flag = 0;
                for (int i = 1; i <= flags.Values.Count; i++)
                {
                    double v     = (double)Lua.GetFunction("ParseTrigFlag").Call(flags[i])[0];
                    int    flagv = (int)v;

                    flag += (ushort)(0b1 << flagv);
                }

                cTrigger.exeflag = flag;
            }
            if (t["conditions"] != null)
            {
                LuaInterface.LuaTable conds = (LuaInterface.LuaTable)t["conditions"];
                for (int i = 1; i <= conds.Values.Count; i++)
                {
                    LuaInterface.LuaTable con = (LuaInterface.LuaTable)conds[i];

                    bool tEnable = true;
                    if (con["Disable"] != null)
                    {
                        con     = (LuaInterface.LuaTable)con["item"];
                        tEnable = false;
                    }

                    TrigItem trigItem = GetTrigItem(con);
                    if (trigItem == null)
                    {
                        continue;
                    }


                    trigItem.IsEnable = tEnable;

                    cTrigger.conditions.Add(trigItem);
                }
            }
            if (t["actions"] != null)
            {
                LuaInterface.LuaTable acts = (LuaInterface.LuaTable)t["actions"];
                for (int i = 1; i <= acts.Values.Count; i++)
                {
                    LuaInterface.LuaTable act = (LuaInterface.LuaTable)acts[i];

                    bool tEnable = true;
                    if (act["Disable"] != null)
                    {
                        act     = (LuaInterface.LuaTable)act["item"];
                        tEnable = false;
                    }

                    TrigItem trigItem = GetTrigItem(act);
                    if (trigItem == null)
                    {
                        continue;
                    }

                    trigItem.IsEnable = tEnable;

                    cTrigger.actions.Add(trigItem);
                }
            }

            Triggers.Add(cTrigger);
        }
예제 #24
0
        public TrigItem GetTrigItem(LuaInterface.LuaTable t)
        {
            bool IsAction = true;


            int type = (int)(double)t[1];

            List <object> args = new List <object>();

            for (int c = 2; c <= t.Values.Count - 1; c++)
            {
                args.Add(t[c]);
            }

            TrigItem trigItem = new TrigItem(mapData);

            TriggerDefine td = null;

            switch ((string)t["type"])
            {
            case "Briefing":
                td = Global.WindowTool.triggerManger.BrifngActions[type];
                break;

            case "Condition":
                IsAction = false;
                td       = Global.WindowTool.triggerManger.Conditions[type];
                break;

            case "Action":
                td = Global.WindowTool.triggerManger.Actions[type];
                break;
            }



            trigItem.triggerDefine = td;
            trigItem.IsAction      = IsAction;
            trigItem.IsTrigger     = IsTrigger;
            trigItem.name          = td.NAME;
            trigItem.type          = td.TYPE;

            if (td.argDefines.Count != args.Count)
            {
                throw new Exception(td.NAME + "은 인자수가 " + td.argDefines.Count + "개 입니다. 하지만 " + args.Count + "개의 인자가 들어왔습니다.");
            }



            for (int i = 0; i < td.argDefines.Count; i++)
            {
                TriggerDefine.ArgDefine ad = td.argDefines[i];

                Arg arg = new Arg(mapData);
                arg.argDefine = ad;
                arg.ARGTYPE   = ad.argtype;
                arg.IsInit    = false;



                switch (ad.argtype)
                {
                case ArgType.STRING:
                case ArgType.WAV:
                    arg.STRING.String = (string)args[i];
                    break;

                case ArgType.LOCATION:
                    arg.LOCATION = (LocationData)args[i];
                    break;

                case ArgType.UPRP:
                    arg.UPRP = (CUPRP)args[i];
                    break;

                default:
                    arg.VALUE = (long)(double)args[i];
                    break;
                }
                trigItem.args.Add(arg);
            }



            return(trigItem);
        }
예제 #25
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (!Directory.Exists("Lists"))
            {
                try
                {
                    Directory.CreateDirectory("Lists");
                }
                catch (Exception ex)
                {
                    String msg = "Unable to create list directory";
                    m_log.Error(msg, ex);
                    MessageBox.Show(msg, "Error Generating Names");
                    return;
                }
            }
            String filter = String.Format("namelist_{0}_*.txt", cbxGenMethod.Text);

            String[] files = Directory.GetFiles(".\\Lists", filter);
            int      index = 1;

            if (files.Length > 0)
            {
                foreach (String file in files)
                {
                    String[] parts = file.Split('_');
                    if (parts.Length < 3)
                    {
                        continue;
                    }
                    String[] subparts = parts[parts.Length - 1].Split('.');
                    try
                    {
                        int filenum = int.Parse(subparts[0]);
                        if (filenum > index)
                        {
                            index = filenum;
                        }
                    }
                    catch (Exception ex)
                    {
                        continue;
                    }
                }
                ++index;
            }
            String        method = cbxGenMethod.Text + ".GetName";
            List <String> names  = new List <String>();

            object[] res = m_luaInterface.Call(method, new object[] { nudGenCount.Value });
            try
            {
                LuaInterface.LuaTable namelist = (LuaInterface.LuaTable)res[0];
                foreach (object key in namelist.Keys)
                {
                    names.Add(namelist[key].ToString());
                }
            }
            catch (Exception ex)
            {
                String msg = "Unable to convert " + cbxGenMethod.Text + ".GetName() result to a Lua table.";
                m_log.Error(msg, ex);
                MessageBox.Show(msg, "Error Generating Names");
                return;
            }
            String outfile = String.Format(".\\Lists\\namelist_{0}_{1}.txt", cbxGenMethod.Text, index);

            try
            {
                using (StreamWriter sw = new StreamWriter(outfile))
                {
                    foreach (String name in names)
                    {
                        sw.WriteLine(name);
                    }
                }
            }
            catch (Exception ex)
            {
                String msg = "Error writing " + outfile;
                m_log.Error(msg, ex);
                MessageBox.Show(msg, "Error Writing Names");
            }
        }