热血军团-GlobalVariables

来源:互联网 发布:ims是关系型数据库吗 编辑:程序博客网 时间:2024/04/28 23:02

这个类是一个单例类,除了m_IsClient/m_IsDebug/m_IsPublish/m_IsWaitQuit这几个变量外,重要的是这个类里缓存了两个字典,一个是编码字典m_EncodeTable,一个是解码字典m_DecodeTable,尤其是编码表和解码表非常重要,客户端和服务器端都共用这两张表,这样服务器端和客户端交流才能顺畅


namespace DashFire{    public class GlobalVariables    {        public const int c_TotalPreservedRoomCount = 64;        public const int c_PreservedRoomCountPerThread = 4;        private bool m_IsClient = false;        private bool m_IsDebug = false;        private bool m_IsPublish = false;        private bool m_IsWaitQuit = false;        private Dictionary<string, string> m_EncodeTable = new Dictionary<string, string>();        private Dictionary<string, string> m_DecodeTable = new Dictionary<string, string>();        private static GlobalVariables s_Instance = new GlobalVariables();        public bool IsClient        {            get            {                return this.m_IsClient;            }            set            {                this.m_IsClient = value;            }        }        public bool IsDebug        {            get            {                return this.m_IsDebug;            }            set            {                this.m_IsDebug = value;            }        }        public bool IsPublish        {            get            {                return this.m_IsPublish;            }            set            {                this.m_IsPublish = value;            }        }        public bool IsWaitQuit        {            get            {                return this.m_IsWaitQuit;            }            set            {                this.m_IsWaitQuit = value;            }        }        public Dictionary<string, string> EncodeTable        {            get            {                return this.m_EncodeTable;            }        }        public Dictionary<string, string> DecodeTable        {            get            {                return this.m_DecodeTable;            }        }        public static GlobalVariables Instance        {            get            {                return GlobalVariables.s_Instance;            }        }        private static void AddCrypto(string s, string d, Dictionary<string, string> encodeTable, Dictionary<string, string> decodeTable)        {            encodeTable.Add(s, d);            decodeTable.Add(d, s);        }        private GlobalVariables()        {            GlobalVariables.AddCrypto("skill", "_1_", this.m_EncodeTable, this.m_DecodeTable);            GlobalVariables.AddCrypto("section", "_2_", this.m_EncodeTable, this.m_DecodeTable);            GlobalVariables.AddCrypto("initialization", "_3_", this.m_EncodeTable, this.m_DecodeTable);            GlobalVariables.AddCrypto("onstop", "_4_", this.m_EncodeTable, this.m_DecodeTable);            GlobalVariables.AddCrypto("oninterrupt", "_5_", this.m_EncodeTable, this.m_DecodeTable);            GlobalVariables.AddCrypto("story", "_6_", this.m_EncodeTable, this.m_DecodeTable);            GlobalVariables.AddCrypto("local", "_7_", this.m_EncodeTable, this.m_DecodeTable);            GlobalVariables.AddCrypto("onmessage", "_8_", this.m_EncodeTable, this.m_DecodeTable);            GlobalVariables.AddCrypto("foreach", "_9_", this.m_EncodeTable, this.m_DecodeTable);            GlobalVariables.AddCrypto("loop", "_10_", this.m_EncodeTable, this.m_DecodeTable);            GlobalVariables.AddCrypto("looplist", "_11_", this.m_EncodeTable, this.m_DecodeTable);            GlobalVariables.AddCrypto("while", "_12_", this.m_EncodeTable, this.m_DecodeTable);            GlobalVariables.AddCrypto("if", "_13_", this.m_EncodeTable, this.m_DecodeTable);            GlobalVariables.AddCrypto("else", "_14_", this.m_EncodeTable, this.m_DecodeTable);            GlobalVariables.AddCrypto("inc", "_15_", this.m_EncodeTable, this.m_DecodeTable);            GlobalVariables.AddCrypto("dec", "_16_", this.m_EncodeTable, this.m_DecodeTable);            GlobalVariables.AddCrypto("assign", "_17_", this.m_EncodeTable, this.m_DecodeTable);            GlobalVariables.AddCrypto("propset", "_18_", this.m_EncodeTable, this.m_DecodeTable);            GlobalVariables.AddCrypto("propget", "_19_", this.m_EncodeTable, this.m_DecodeTable);            GlobalVariables.AddCrypto("terminate", "_20_", this.m_EncodeTable, this.m_DecodeTable);            GlobalVariables.AddCrypto("localmessage", "_21_", this.m_EncodeTable, this.m_DecodeTable);            GlobalVariables.AddCrypto("wait", "_22_", this.m_EncodeTable, this.m_DecodeTable);            GlobalVariables.AddCrypto("sleep", "_23_", this.m_EncodeTable, this.m_DecodeTable);            GlobalVariables.AddCrypto("log", "_24_", this.m_EncodeTable, this.m_DecodeTable);            GlobalVariables.AddCrypto("format", "_25_", this.m_EncodeTable, this.m_DecodeTable);            GlobalVariables.AddCrypto("substring", "_26_", this.m_EncodeTable, this.m_DecodeTable);            GlobalVariables.AddCrypto("startstory", "_27_", this.m_EncodeTable, this.m_DecodeTable);            GlobalVariables.AddCrypto("stopstory", "_28_", this.m_EncodeTable, this.m_DecodeTable);            GlobalVariables.AddCrypto("firemessage", "_29_", this.m_EncodeTable, this.m_DecodeTable);            GlobalVariables.AddCrypto("showmissioncomplete", "_30_", this.m_EncodeTable, this.m_DecodeTable);            GlobalVariables.AddCrypto("missioncomplete", "_31_", this.m_EncodeTable, this.m_DecodeTable);            GlobalVariables.AddCrypto("list", "_32_", this.m_EncodeTable, this.m_DecodeTable);            GlobalVariables.AddCrypto("showui", "_33_", this.m_EncodeTable, this.m_DecodeTable);            GlobalVariables.AddCrypto("showdlg", "_34_", this.m_EncodeTable, this.m_DecodeTable);            GlobalVariables.AddCrypto("showwall", "_35_", this.m_EncodeTable, this.m_DecodeTable);            GlobalVariables.AddCrypto("cameralookat", "_36_", this.m_EncodeTable, this.m_DecodeTable);            GlobalVariables.AddCrypto("camerafollow", "_37_", this.m_EncodeTable, this.m_DecodeTable);            GlobalVariables.AddCrypto("cameralookatimmediately", "_38_", this.m_EncodeTable, this.m_DecodeTable);            GlobalVariables.AddCrypto("camerafollowimmediately", "_39_", this.m_EncodeTable, this.m_DecodeTable);            GlobalVariables.AddCrypto("createnpc", "_40_", this.m_EncodeTable, this.m_DecodeTable);            GlobalVariables.AddCrypto("destroynpc", "_41_", this.m_EncodeTable, this.m_DecodeTable);            GlobalVariables.AddCrypto("npcface", "_42_", this.m_EncodeTable, this.m_DecodeTable);            GlobalVariables.AddCrypto("npcmove", "_43_", this.m_EncodeTable, this.m_DecodeTable);            GlobalVariables.AddCrypto("npcmovewithwaypoints", "_44_", this.m_EncodeTable, this.m_DecodeTable);            GlobalVariables.AddCrypto("npcpatrol", "_45_", this.m_EncodeTable, this.m_DecodeTable);            GlobalVariables.AddCrypto("npcstop", "_46_", this.m_EncodeTable, this.m_DecodeTable);            GlobalVariables.AddCrypto("npcattack", "_47_", this.m_EncodeTable, this.m_DecodeTable);            GlobalVariables.AddCrypto("enableai", "_48_", this.m_EncodeTable, this.m_DecodeTable);            GlobalVariables.AddCrypto("setcamp", "_49_", this.m_EncodeTable, this.m_DecodeTable);            GlobalVariables.AddCrypto("getcamp", "_50_", this.m_EncodeTable, this.m_DecodeTable);            GlobalVariables.AddCrypto("isenemy", "_51_", this.m_EncodeTable, this.m_DecodeTable);            GlobalVariables.AddCrypto("isfriend", "_52_", this.m_EncodeTable, this.m_DecodeTable);            GlobalVariables.AddCrypto("enableinput", "_53_", this.m_EncodeTable, this.m_DecodeTable);            GlobalVariables.AddCrypto("playerselfface", "_54_", this.m_EncodeTable, this.m_DecodeTable);            GlobalVariables.AddCrypto("playerselfmove", "_55_", this.m_EncodeTable, this.m_DecodeTable);            GlobalVariables.AddCrypto("playerselfmovewithwaypoints", "_56_", this.m_EncodeTable, this.m_DecodeTable);            GlobalVariables.AddCrypto("objface", "_57_", this.m_EncodeTable, this.m_DecodeTable);            GlobalVariables.AddCrypto("objmove", "_58_", this.m_EncodeTable, this.m_DecodeTable);            GlobalVariables.AddCrypto("objmovewithwaypoints", "_59_", this.m_EncodeTable, this.m_DecodeTable);            GlobalVariables.AddCrypto("time", "_60_", this.m_EncodeTable, this.m_DecodeTable);        }        public static int GetUnitIdByCampId(int campid)        {            int result;            if (campid == 3)            {                result = 20001;            }            else            {                result = 20002;            }            return result;        }    }}

FR:海涛高软(QQ群:386476712)

0 0
原创粉丝点击