Example #1
0
        public StrongCfg GetStrongCfgData(int pos, int starLv)
        {
            StrongCfg res = null;

            if (strongCfgDic.ContainsKey(pos))
            {
                Dictionary <int, StrongCfg> dic = strongCfgDic[pos];
                if (dic.ContainsKey(starLv))
                {
                    return(dic[starLv]);
                }
            }

            if (res == null)
            {
                NETCommon.Log("StrongCfg获取失败", NETLogLevel.Error);
            }

            return(res);
        }
Example #2
0
        public void ReqStrong(MsgPack pack)
        {
            ServerSession session = pack.session;
            ReqStrong     data    = pack.msg.reqStrong;

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

            PlayerData pd      = cacheSev.GetPlayerDataBySession(session);
            int        curStar = pd.strongArr[data.pos];
            StrongCfg  nextSc  = cfgSev.GetStrongCfgData(data.pos, curStar + 1);

            // 条件判断
            if (pd.lv < nextSc.minLv)
            {
                msg.err = (int)ErrorCode.LackLevel;
                session.SendMsg(msg);
                return;
            }
            if (pd.coin < nextSc.coin)
            {
                msg.err = (int)ErrorCode.LackCoin;
                session.SendMsg(msg);
                return;
            }
            if (pd.crystal < nextSc.crystal)
            {
                msg.err = (int)ErrorCode.LackCrystal;
                session.SendMsg(msg);
                return;
            }

            // 资源扣除
            pd.coin    -= nextSc.coin;
            pd.crystal -= nextSc.crystal;

            // 属性增益
            pd.strongArr[data.pos] += 1;
            pd.hp    += nextSc.addHp;
            pd.ad    += nextSc.addHurt * (1 + 1 / (data.pos + 1));
            pd.ap    += nextSc.addHurt;
            pd.addef += nextSc.addDef;
            pd.apdef += nextSc.addDef;

            // 任务进度更新
            msg.pshTaskPrgs = TaskSystem.Instance.CalcTaskPrg(pd, 3);

            // 更新数据库
            if (!cacheSev.UpdatePlayerData(pd))
            {
                msg.err = (int)ErrorCode.UpdateDBError;
                session.SendMsg(msg);
                return;
            }

            // 返回消息
            msg.rspStrong = new RspStrong
            {
                coin      = pd.coin,
                crystal   = pd.crystal,
                hp        = pd.hp,
                ad        = pd.ad,
                ap        = pd.ap,
                adddef    = pd.addef,
                apdef     = pd.apdef,
                strongArr = pd.strongArr
            };
            session.SendMsg(msg);
        }
Example #3
0
        private void InitStrongCfg()
        {
            XmlDocument doc = new XmlDocument();

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

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

            for (int i = 0; i < nodeList.Count; i++)
            {
                XmlElement ele = nodeList[i] as XmlElement;
                if (ele.GetAttribute("ID") == null)
                {
                    continue;
                }

                int       ID = int.Parse(ele.GetAttributeNode("ID").InnerText);
                StrongCfg sc = new StrongCfg {
                    ID = ID
                };

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

                    case "starlv":
                        sc.starLv = val;
                        break;

                    case "addhp":
                        sc.addHp = val;
                        break;

                    case "adddef":
                        sc.addDef = val;
                        break;

                    case "minlv":
                        sc.minLv = val;
                        break;

                    case "coin":
                        sc.coin = val;
                        break;

                    case "crystal":
                        sc.crystal = val;
                        break;
                    }
                }

                Dictionary <int, StrongCfg> dic = null;
                if (strongCfgDic.TryGetValue(sc.pos, out dic))
                {
                    dic.Add(sc.starLv, sc);
                }
                else
                {
                    dic = new Dictionary <int, StrongCfg>();
                    dic.Add(sc.starLv, sc);
                    strongCfgDic.Add(sc.pos, dic);
                }
            }
            NETCommon.Log("StrongCfg InitDone");
        }