示例#1
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);
        }
示例#2
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);
        }