Beispiel #1
0
 public static void ModifyEffect(GameClient client, int effectID, int talentType, int newLevel)
 {
     try
     {
         TalentData talentData = client.ClientData.MyTalentData;
         TalentInfo talentInfo = TalentManager.GetTalentInfoByID(client.ClientData.Occupation, effectID);
         if (talentInfo != null)
         {
             List <TalentEffectInfo> newItemEffectList = talentInfo.EffectList[newLevel];
             bool result = TalentManager.DBTalentEffectModify(client.ClientData.RoleID, talentType, effectID, newLevel, client.ClientData.ZoneID, client.ServerId);
             Dictionary <int, int> countList;
             (countList = talentData.CountList)[talentType] = countList[talentType] + newLevel;
             TalentEffectItem effectItemOld = TalentManager.GetOpenEffectItem(talentData, effectID);
             if (effectItemOld == null)
             {
                 effectItemOld            = new TalentEffectItem();
                 effectItemOld.ID         = effectID;
                 effectItemOld.TalentType = talentType;
                 talentData.EffectList.Add(effectItemOld);
             }
             effectItemOld.Level          = newLevel;
             effectItemOld.ItemEffectList = newItemEffectList;
         }
     }
     catch (Exception ex)
     {
         LogManager.WriteException(ex.ToString());
     }
 }
Beispiel #2
0
 public bool initialize()
 {
     TalentManager.LoadTalentExpInfo();
     TalentManager.LoadTalentSpecialData();
     TalentManager.LoadTalentInfoData();
     return(true);
 }
Beispiel #3
0
 public bool startup()
 {
     TCPCmdDispatcher.getInstance().registerProcessorEx(999, 1, 1, TalentManager.getInstance(), TCPCmdFlags.IsStringArrayParams);
     TCPCmdDispatcher.getInstance().registerProcessorEx(1000, 1, 1, TalentManager.getInstance(), TCPCmdFlags.IsStringArrayParams);
     TCPCmdDispatcher.getInstance().registerProcessorEx(1001, 1, 1, TalentManager.getInstance(), TCPCmdFlags.IsStringArrayParams);
     TCPCmdDispatcher.getInstance().registerProcessorEx(1002, 2, 2, TalentManager.getInstance(), TCPCmdFlags.IsStringArrayParams);
     TCPCmdDispatcher.getInstance().registerProcessorEx(1003, 3, 3, TalentManager.getInstance(), TCPCmdFlags.IsStringArrayParams);
     return(true);
 }
Beispiel #4
0
 private static void LoadTalentInfoData()
 {
     TalentManager._TalentInfoList.Clear();
     for (int i = 0; i < 6; i++)
     {
         Dictionary <int, TalentInfo> list = new Dictionary <int, TalentInfo>();
         string   fileName = Global.GameResPath(string.Format("Config/TianFuProperty_{0}.xml", i));
         XElement xml      = CheckHelper.LoadXml(fileName, false);
         if (null == xml)
         {
             TalentManager._TalentInfoList.Add(i, list);
         }
         else
         {
             try
             {
                 IEnumerable <XElement> xmlItems = xml.Elements();
                 foreach (XElement xmlItem in xmlItems)
                 {
                     if (xmlItem != null)
                     {
                         TalentInfo config = new TalentInfo();
                         config.ID              = Convert.ToInt32(Global.GetDefAttributeStr(xmlItem, "ID", "0"));
                         config.Type            = Convert.ToInt32(Global.GetDefAttributeStr(xmlItem, "TianFuType", "0"));
                         config.Name            = Global.GetDefAttributeStr(xmlItem, "Name", "");
                         config.NeedTalentCount = Convert.ToInt32(Global.GetDefAttributeStr(xmlItem, "NeedInputPoint", "0"));
                         config.NeedTalentID    = Convert.ToInt32(Global.GetDefAttributeStr(xmlItem, "NeedTianFu", "0"));
                         config.NeedTalentLevel = Convert.ToInt32(Global.GetDefAttributeStr(xmlItem, "NeedTianFuLevel", "0"));
                         config.LevelMax        = Convert.ToInt32(Global.GetDefAttributeStr(xmlItem, "LevelMax", "0"));
                         config.EffectType      = Convert.ToInt32(Global.GetDefAttributeStr(xmlItem, "EffectType", "0"));
                         config.EffectList      = new Dictionary <int, List <TalentEffectInfo> >();
                         string effect = Global.GetDefAttributeStr(xmlItem, "Effect1", "");
                         TalentManager.XmlGetTalentEffect(config, 1, effect);
                         effect = Global.GetDefAttributeStr(xmlItem, "Effect2", "");
                         TalentManager.XmlGetTalentEffect(config, 2, effect);
                         effect = Global.GetDefAttributeStr(xmlItem, "Effect3", "");
                         TalentManager.XmlGetTalentEffect(config, 3, effect);
                         effect = Global.GetDefAttributeStr(xmlItem, "Effect4", "");
                         TalentManager.XmlGetTalentEffect(config, 4, effect);
                         effect = Global.GetDefAttributeStr(xmlItem, "Effect5", "");
                         TalentManager.XmlGetTalentEffect(config, 5, effect);
                         list.Add(config.ID, config);
                     }
                 }
             }
             catch (Exception ex)
             {
                 LogManager.WriteLog(LogTypes.Fatal, string.Format("加载[{0}]时出错!!!{1}", fileName, ex.Message), null, true);
             }
             TalentManager._TalentInfoList.Add(i, list);
         }
     }
 }
Beispiel #5
0
        public static void initTalentEffectProp(GameClient client)
        {
            TalentData myTalentData = TalentManager.GetTalentData(client);

            if (myTalentData != null && myTalentData.IsOpen)
            {
                TalentPropData myPropData = client.ClientData.MyTalentPropData;
                myPropData.ResetProps();
                foreach (TalentEffectItem item in myTalentData.EffectList)
                {
                    TalentInfo talentInfo = TalentManager.GetTalentInfoByID(client.ClientData.Occupation, item.ID);
                    if (talentInfo.LevelMax >= item.Level)
                    {
                        item.ItemEffectList = talentInfo.EffectList[item.Level];
                        foreach (TalentEffectInfo info in item.ItemEffectList)
                        {
                            switch (info.EffectType)
                            {
                            case 1:
                                myPropData.PropItem.BaseProps[info.EffectID] += (double)((int)info.EffectValue);
                                break;

                            case 2:
                                myPropData.PropItem.ExtProps[info.EffectID] += info.EffectValue;
                                break;

                            case 3:
                                if (myPropData.SkillOneValue.ContainsKey(info.EffectID))
                                {
                                    Dictionary <int, int> skillOneValue;
                                    int effectID;
                                    (skillOneValue = myPropData.SkillOneValue)[effectID = info.EffectID] = skillOneValue[effectID] + (int)info.EffectValue;
                                }
                                else
                                {
                                    myPropData.SkillOneValue.Add(info.EffectID, (int)info.EffectValue);
                                }
                                break;

                            case 4:
                                myPropData.SkillAllValue += (int)info.EffectValue;
                                break;
                            }
                        }
                    }
                }
                TalentManager.InitSpecialProp(client);
                client.ClientData.MyTalentData.SkillOneValue = client.ClientData.MyTalentPropData.SkillOneValue;
                client.ClientData.MyTalentData.SkillAllValue = client.ClientData.MyTalentPropData.SkillAllValue;
                TalentManager.SetTalentProp(client, TalentEffectType.PropBasic, myPropData.PropItem);
                TalentManager.SetTalentProp(client, TalentEffectType.PropExt, myPropData.PropItem);
            }
        }
Beispiel #6
0
 public bool ProcessCmdTalentGetData(GameClient client, int nID, byte[] bytes, string[] cmdParams)
 {
     try
     {
         if (!CheckHelper.CheckCmdLengthAndRole(client, nID, cmdParams, 1))
         {
             return(false);
         }
         TalentData talentData = TalentManager.GetTalentData(client);
         client.sendCmd <TalentData>(1000, talentData, false);
         return(true);
     }
     catch (Exception ex)
     {
         DataHelper.WriteFormatExceptionLog(ex, Global.GetDebugHelperInfo(client.ClientSocket), false, false);
     }
     return(false);
 }
Beispiel #7
0
        public static bool TalentAddCount(GameClient client, int count)
        {
            TalentData talentData = client.ClientData.MyTalentData;
            bool       result;

            if (!talentData.IsOpen)
            {
                result = false;
            }
            else if (!TalentManager.DBTalentModify(client.ClientData.RoleID, count, 0L, 0L, false, client.ClientData.ZoneID, client.ServerId))
            {
                result = false;
            }
            else
            {
                talentData.TotalCount = count;
                GlobalEventSource.getInstance().fireEvent(new OrnamentGoalEventObject(client, OrnamentGoalType.OGT_Talent, new int[0]));
                result = true;
            }
            return(result);
        }
Beispiel #8
0
 public bool ProcessCmdTalentWash(GameClient client, int nID, byte[] bytes, string[] cmdParams)
 {
     try
     {
         if (!CheckHelper.CheckCmdLengthAndRole(client, nID, cmdParams, 2))
         {
             return(false);
         }
         int        washType   = int.Parse(cmdParams[1]);
         int        state      = TalentManager.TalentWash(client, washType);
         TalentData talentData = TalentManager.GetTalentData(client);
         talentData.State = state;
         client.sendCmd <TalentData>(1002, talentData, false);
         return(true);
     }
     catch (Exception ex)
     {
         DataHelper.WriteFormatExceptionLog(ex, Global.GetDebugHelperInfo(client.ClientSocket), false, false);
     }
     return(false);
 }
Beispiel #9
0
        private static bool IsEffectOpen(TalentData talentData, int effectID, int level)
        {
            bool result;

            if (effectID <= 0)
            {
                result = true;
            }
            else
            {
                TalentEffectItem item = TalentManager.GetOpenEffectItem(talentData, effectID);
                if (item != null)
                {
                    if (item.Level >= level)
                    {
                        return(true);
                    }
                }
                result = false;
            }
            return(result);
        }
Beispiel #10
0
 public bool ProcessCmdTalentOther(GameClient client, int nID, byte[] bytes, string[] cmdParams)
 {
     try
     {
         if (!CheckHelper.CheckCmdLength(client, nID, cmdParams, 1))
         {
             return(false);
         }
         int        roleID      = Convert.ToInt32(cmdParams[0]);
         TalentData talentData  = null;
         GameClient otherClient = GameManager.ClientMgr.FindClient(roleID);
         if (otherClient != null)
         {
             talentData = TalentManager.GetTalentData(otherClient);
         }
         client.sendCmd <TalentData>(999, talentData, false);
         return(true);
     }
     catch (Exception ex)
     {
         DataHelper.WriteFormatExceptionLog(ex, Global.GetDebugHelperInfo(client.ClientSocket), false, false);
     }
     return(false);
 }
Beispiel #11
0
        private static int TalentAddEffect(GameClient client, int effectID, int addCount)
        {
            int result;

            if (!GlobalNew.IsGongNengOpened(client, GongNengIDs.Talent, false))
            {
                result = TalentResultType.EnoOpen;
            }
            else if (GameFuncControlManager.IsGameFuncDisabled(GameFuncType.System1Dot6))
            {
                result = TalentResultType.EnoOpen;
            }
            else
            {
                TalentInfo talentInfo = TalentManager.GetTalentInfoByID(client.ClientData.Occupation, effectID);
                if (talentInfo == null)
                {
                    result = TalentResultType.EnoEffect;
                }
                else
                {
                    TalentData talentData      = client.ClientData.MyTalentData;
                    int        talentCountLeft = talentData.TotalCount - TalentManager.GetTalentUseCount(talentData);
                    if (talentCountLeft < addCount)
                    {
                        result = TalentResultType.EnoTalentCount;
                    }
                    else if (!TalentManager.IsEffectOpen(talentData, talentInfo.NeedTalentID, talentInfo.NeedTalentLevel))
                    {
                        result = TalentResultType.EnoOpenPreEffect;
                    }
                    else if (talentInfo.NeedTalentCount > 0 && talentInfo.NeedTalentCount > talentData.CountList[talentInfo.Type])
                    {
                        result = TalentResultType.EnoOpenPreCount;
                    }
                    else
                    {
                        int newLevel = 0;
                        TalentEffectItem effectItemOld = TalentManager.GetOpenEffectItem(talentData, effectID);
                        if (effectItemOld != null)
                        {
                            if (effectItemOld.Level >= talentInfo.LevelMax)
                            {
                                return(TalentResultType.EisMaxLevel);
                            }
                            newLevel = effectItemOld.Level;
                        }
                        newLevel += addCount;
                        List <TalentEffectInfo> newItemEffectList = talentInfo.EffectList[newLevel];
                        if (newLevel > talentInfo.LevelMax)
                        {
                            result = TalentResultType.EisMaxLevel;
                        }
                        else if (!TalentManager.DBTalentEffectModify(client.ClientData.RoleID, talentInfo.Type, effectID, newLevel, client.ClientData.ZoneID, client.ServerId))
                        {
                            result = TalentResultType.EFail;
                        }
                        else
                        {
                            Dictionary <int, int> countList;
                            int type;
                            (countList = talentData.CountList)[type = talentInfo.Type] = countList[type] + addCount;
                            if (effectItemOld == null)
                            {
                                effectItemOld            = new TalentEffectItem();
                                effectItemOld.ID         = effectID;
                                effectItemOld.TalentType = talentInfo.Type;
                                talentData.EffectList.Add(effectItemOld);
                            }
                            effectItemOld.Level          = newLevel;
                            effectItemOld.ItemEffectList = newItemEffectList;
                            TalentManager.initTalentEffectProp(client);
                            TalentManager.RefreshProp(client);
                            result = TalentResultType.Success;
                        }
                    }
                }
            }
            return(result);
        }
Beispiel #12
0
        private static int TalentWash(GameClient client, int washType)
        {
            int result;

            if (!GlobalNew.IsGongNengOpened(client, GongNengIDs.Talent, false))
            {
                result = TalentResultType.EnoOpen;
            }
            else if (GameFuncControlManager.IsGameFuncDisabled(GameFuncType.System1Dot6))
            {
                result = TalentResultType.EnoOpen;
            }
            else
            {
                TalentData talentData = client.ClientData.MyTalentData;
                int        washCount  = TalentManager.GetTalentUseCount(talentData);
                if (washCount <= 0)
                {
                    result = TalentResultType.EnoTalentCount;
                }
                else
                {
                    if (washType == 0)
                    {
                        int needDiamond = TalentManager.GetWashDiamond(washCount);
                        if (!GameManager.ClientMgr.SubUserMoney(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, needDiamond, "天赋洗点", true, true, false, DaiBiSySType.TianFuXiDian))
                        {
                            return(TalentResultType.EnoDiamond);
                        }
                    }
                    else
                    {
                        int goodsId    = 0;
                        int goodsCount = 0;
                        TalentManager.GetWashGoods(out goodsId, out goodsCount);
                        GoodsData goodsData = Global.GetGoodsByID(client, goodsId);
                        if (goodsData == null)
                        {
                            return(TalentResultType.EnoWash);
                        }
                        if (!GameManager.ClientMgr.NotifyUseGoods(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, goodsData, goodsCount, false, false))
                        {
                            return(TalentResultType.EnoWash);
                        }
                    }
                    if (!TalentManager.DBTalentEffectClear(client.ClientData.RoleID, client.ClientData.ZoneID, client.ServerId))
                    {
                        result = TalentResultType.EFail;
                    }
                    else
                    {
                        talentData.CountList[1] = 0;
                        talentData.CountList[2] = 0;
                        talentData.CountList[3] = 0;
                        talentData.EffectList   = new List <TalentEffectItem>();
                        TalentPropData propData = client.ClientData.MyTalentPropData;
                        propData.ResetProps();
                        TalentManager.SetTalentProp(client, TalentEffectType.PropBasic, propData.PropItem);
                        TalentManager.SetTalentProp(client, TalentEffectType.PropExt, propData.PropItem);
                        TalentManager.RefreshProp(client);
                        result = TalentResultType.Success;
                    }
                }
            }
            return(result);
        }
Beispiel #13
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);
        }