Пример #1
0
        private static void LoadTalentExpInfo()
        {
            string   fileName = Global.GameResPath("Config/TianFuDian.xml");
            XElement xml      = CheckHelper.LoadXml(fileName, true);

            if (null != xml)
            {
                try
                {
                    TalentManager._TalentExpList.Clear();
                    IEnumerable <XElement> xmlItems = xml.Elements();
                    foreach (XElement xmlItem in xmlItems)
                    {
                        if (xmlItem != null)
                        {
                            TalentExpInfo info = new TalentExpInfo();
                            info.ID  = Convert.ToInt32(Global.GetDefAttributeStr(xmlItem, "TianFuDian", "0"));
                            info.Exp = Convert.ToInt64(Global.GetDefAttributeStr(xmlItem, "NeedExp", "0"));
                            string[] level = Global.GetDefAttributeStr(xmlItem, "NeedLevel", "0,0").Split(new char[]
                            {
                                ','
                            });
                            info.RoleLevel = int.Parse(level[0]) * 100 + int.Parse(level[1]);
                            TalentManager._TalentExpList.Add(info.ID, info);
                        }
                    }
                }
                catch (Exception ex)
                {
                    LogManager.WriteLog(LogTypes.Fatal, string.Format("加载[{0}]时出错!!!", fileName), null, true);
                }
            }
        }
Пример #2
0
        /// <summary>
        /// 经验注入
        /// </summary>
        private static int TalentAddExp(GameClient client)
        {
            //开放
            if (!GlobalNew.IsGongNengOpened(client, GongNengIDs.Talent))
            {
                return(TalentResultType.EnoOpen);
            }

            // 如果1.6的功能没开放
            if (GameFuncControlManager.IsGameFuncDisabled(GameFuncType.System1Dot6))
            {
                return(TalentResultType.EnoOpen);
            }

            //没有经验
            if (client.ClientData.Experience <= 0)
            {
                return(TalentResultType.EnoExp);
            }

            TalentData talentData = client.ClientData.MyTalentData;

            //经验数据
            int talentCount = talentData.TotalCount <= 0 ? 1 : talentData.TotalCount + 1;

            if (!_TalentExpList.ContainsKey(talentCount))
            {
                return(TalentResultType.EnoOpenPoint);
            }

            //等级限制
            TalentExpInfo expInfo = _TalentExpList[talentCount];
            int           level   = client.ClientData.ChangeLifeCount * 100 + client.ClientData.Level;

            if (level < expInfo.RoleLevel)
            {
                return(TalentResultType.EnoOpenPoint);
            }

            //需要经验
            long needExp = expInfo.Exp - talentData.Exp;

            long exp     = 0;                            //注入经验
            long expAdd  = 0;                            //增加的经验
            long expRole = client.ClientData.Experience; //角色现有经验
            bool isUp    = false;

            if (needExp <= expRole)
            {
                isUp   = true;
                expAdd = needExp;
            }
            else
            {
                exp          = talentData.Exp + expRole;
                talentCount -= 1;
                expAdd       = expRole;
            }

            if (!DBTalentModify(client.ClientData.RoleID, talentCount, exp, expAdd, isUp, client.ClientData.ZoneID, client.ServerId))
            {
                return(TalentResultType.EFail);
            }

            if (isUp)
            {
                talentData.Exp                = exp;
                talentData.TotalCount        += 1;
                client.ClientData.Experience -= needExp;
            }
            else
            {
                talentData.Exp = exp;
                client.ClientData.Experience -= expRole;
            }

            //经验通知
            GameManager.ClientMgr.NotifySelfExperience(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client, -exp);

            if (isUp)
            {
                return(TalentResultType.Success);
            }
            else
            {
                return(TalentResultType.SuccessHalf);
            }
        }
Пример #3
0
        private static int TalentAddExp(GameClient client)
        {
            int result;

            if (!GlobalNew.IsGongNengOpened(client, GongNengIDs.Talent, false))
            {
                result = TalentResultType.EnoOpen;
            }
            else if (GameFuncControlManager.IsGameFuncDisabled(GameFuncType.System1Dot6))
            {
                result = TalentResultType.EnoOpen;
            }
            else if (client.ClientData.Experience <= 0L)
            {
                result = TalentResultType.EnoExp;
            }
            else
            {
                TalentData talentData  = client.ClientData.MyTalentData;
                int        talentCount = (talentData.TotalCount <= 0) ? 1 : (talentData.TotalCount + 1);
                if (!TalentManager._TalentExpList.ContainsKey(talentCount))
                {
                    result = TalentResultType.EnoOpenPoint;
                }
                else
                {
                    TalentExpInfo expInfo = TalentManager._TalentExpList[talentCount];
                    int           level   = client.ClientData.ChangeLifeCount * 100 + client.ClientData.Level;
                    if (level < expInfo.RoleLevel)
                    {
                        result = TalentResultType.EnoOpenPoint;
                    }
                    else
                    {
                        long needExp = expInfo.Exp - talentData.Exp;
                        long exp     = 0L;
                        long expRole = client.ClientData.Experience;
                        bool isUp    = false;
                        long expAdd;
                        if (needExp <= expRole)
                        {
                            isUp   = true;
                            expAdd = needExp;
                        }
                        else
                        {
                            exp = talentData.Exp + expRole;
                            talentCount--;
                            expAdd = expRole;
                        }
                        if (!TalentManager.DBTalentModify(client.ClientData.RoleID, talentCount, exp, expAdd, isUp, client.ClientData.ZoneID, client.ServerId))
                        {
                            result = TalentResultType.EFail;
                        }
                        else
                        {
                            if (isUp)
                            {
                                talentData.Exp = exp;
                                talentData.TotalCount++;
                                client.ClientData.Experience -= needExp;
                            }
                            else
                            {
                                talentData.Exp = exp;
                                client.ClientData.Experience -= expRole;
                            }
                            GameManager.ClientMgr.NotifySelfExperience(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client, -exp);
                            GlobalEventSource.getInstance().fireEvent(new OrnamentGoalEventObject(client, OrnamentGoalType.OGT_Talent, new int[0]));
                            if (isUp)
                            {
                                result = TalentResultType.Success;
                            }
                            else
                            {
                                result = TalentResultType.SuccessHalf;
                            }
                        }
                    }
                }
            }
            return(result);
        }