Esempio n. 1
0
        public AutoGuideCfg GetAutoGuidCfg(int id)
        {
            AutoGuideCfg cfg = null;

            if (autoGuidDic.TryGetValue(id, out cfg))
            {
                return(cfg);
            }
            else
            {
                NETCommon.Log("AutoGuideCfg 获取失败", NETLogLevel.Error);
                return(null);
            }
        }
Esempio n. 2
0
        public void ReqGuide(MsgPack pack)
        {
            ReqGuide data = pack.msg.reqGuide;

            GameMsg msg = new GameMsg
            {
                cmd = (int)CMD.RspGuided
            };

            // 更新任务 ID
            PlayerData pd = cacheSev.GetPlayerDataBySession(pack.session);

            if (pd.guidid == data.guidID)
            {
                switch (pd.guidid)
                {
                case 1001:
                    msg.pshTaskPrgs = TaskSystem.Instance.CalcTaskPrg(pd, 1);
                    break;
                }
                pd.guidid += 1;
                // 更新玩家数据
                AutoGuideCfg guidCfg = cfgSev.GetAutoGuidCfg(data.guidID);
                pd.coin += guidCfg.coin;
                NETCommon.CalcExp(pd, guidCfg.exp);

                if (!cacheSev.UpdatePlayerData(pd))
                {
                    msg.err = (int)ErrorCode.UpdateDBError;
                }
                else
                {
                    msg.rspGuide = new RspGuide
                    {
                        guideid = pd.guidid,
                        coin    = pd.coin,
                        lv      = pd.lv,
                        exp     = pd.exp,
                        addExp  = guidCfg.exp
                    };
                }
            }
            else
            {
                msg.err = (int)ErrorCode.ServerDataError;
            }

            pack.session.SendMsg(msg);
        }
Esempio n. 3
0
        private void InitAutoGuidCfg()
        {
            XmlDocument doc = new XmlDocument();

            doc.Load(@"F:\Unity\ARPG\Assets\Plugins\Editor\RawConfig\guide.xml");

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

            for (int i = 0; i < nodeList.Count; i++)
            {
                var ele = nodeList[i] as XmlElement;
                if (ele.GetAttribute("ID") == null)
                {
                    continue;
                }
                int          id  = int.Parse(ele.GetAttributeNode("ID").InnerText);
                AutoGuideCfg cfg = new AutoGuideCfg {
                    ID = id
                };
                foreach (XmlElement e in nodeList[i].ChildNodes)
                {
                    switch (e.Name)
                    {
                    case "coin":
                        cfg.coin = int.Parse(e.InnerText);
                        break;

                    case "exp":
                        cfg.exp = int.Parse(e.InnerText);
                        break;
                    }
                }
                autoGuidDic.Add(id, cfg);
            }
            NETCommon.Log("GuidCfg Init Done...");
        }