Exemplo n.º 1
0
        public void ReqGuide(MsgPack pack)
        {
            ReqGuide data = pack.msg.reqGuide;
            GameMsg  msg  = new GameMsg
            {
                cmd = (int)CMD.RspGuide
            };
            PlayerData pd = cacheSvc.GetPlayerDataSession(pack.session);
            GuideCfg   gc = cfgSys.GetGuideCfg(data.guideid);

            if (pd.guideid == data.guideid)
            {
                pd.guideid += 1;

                pd.coin += gc.coin;
                calcExp(pd, gc.exp);

                if (!cacheSvc.UpdatePlayerData(pd.id, pd))
                {
                    msg.err = (int)ErrorCode.UpdateDBError;
                }
                else
                {
                    msg.rspGuide = new RspGuide
                    {
                        guideid = pd.guideid,
                        coin    = pd.coin,
                        lv      = pd.lv,
                        exp     = pd.exp
                    };
                }
            }
            else
            {
                msg.err = (int)ErrorCode.ServerDataError;
            }
            pack.session.SendMsg(msg);
        }
Exemplo n.º 2
0
        private void InitGuideCfg()
        {
            XmlDocument doc = new XmlDocument();

            doc.Load(Tools.getGuidePath());

            XmlNodeList nodeList = doc.SelectSingleNode("root").ChildNodes;

            for (int i = 0; i < nodeList.Count; i++)
            {
                XmlElement ele = nodeList[i] as XmlElement;
                if (string.IsNullOrEmpty(ele.GetAttributeNode("ID").InnerText))
                {
                    continue;
                }
                int      id       = Convert.ToInt32(ele.GetAttributeNode("ID").InnerText);
                GuideCfg guideCfg = new GuideCfg
                {
                    ID = id
                };

                foreach (XmlElement e in nodeList[i].ChildNodes)
                {
                    switch (e.Name)
                    {
                    case "coin":
                        guideCfg.coin = int.Parse(e.InnerText);
                        break;

                    case "exp":
                        guideCfg.exp = int.Parse(e.InnerText);
                        break;
                    }
                }

                guideDic.Add(id, guideCfg);
            }
        }