示例#1
0
        private void RestoreRoleCustomData(GameClient client, RoleCustomData customData)
        {
            RoleCustomDataItem roleCustomData = null;

            if (customData != null && customData.customDataList != null && customData.customDataList.Count > 0)
            {
                roleCustomData = customData.customDataList.Find((RoleCustomDataItem x) => x.Occupation == client.ClientData.Occupation);
            }
            if (null == roleCustomData)
            {
                roleCustomData = new RoleCustomDataItem();
            }
            client.ClientData.MainQuickBarKeys = roleCustomData.Main_quick_keys;
            GameManager.DBCmdMgr.AddDBCmd(10010, string.Format("{0}:{1}:{2}", client.ClientData.RoleID, 0, roleCustomData.Main_quick_keys), null, client.ServerId);
            int[] rolePoint = new int[4];
            for (int i = 0; i < 4; i++)
            {
                if (roleCustomData.RolePointList != null && i < roleCustomData.RolePointList.Count)
                {
                    rolePoint[i] = roleCustomData.RolePointList[i];
                }
            }
            client.ClientData.PropStrength = Global.GetRoleParamsInt32FromDB(client, "PropStrengthChangeless") + rolePoint[0];
            Global.SaveRoleParamsInt32ValueToDB(client, "PropStrength", client.ClientData.PropStrength, true);
            client.ClientData.PropIntelligence = Global.GetRoleParamsInt32FromDB(client, "PropIntelligenceChangeless") + rolePoint[1];
            Global.SaveRoleParamsInt32ValueToDB(client, "PropIntelligence", client.ClientData.PropIntelligence, true);
            client.ClientData.PropDexterity = Global.GetRoleParamsInt32FromDB(client, "PropDexterityChangeless") + rolePoint[2];
            Global.SaveRoleParamsInt32ValueToDB(client, "PropDexterity", client.ClientData.PropDexterity, true);
            client.ClientData.PropConstitution = Global.GetRoleParamsInt32FromDB(client, "PropConstitutionChangeless") + rolePoint[3];
            Global.SaveRoleParamsInt32ValueToDB(client, "PropConstitution", client.ClientData.PropConstitution, true);
            TalentManager.DBTalentEffectClear(client.ClientData.RoleID, client.ClientData.ZoneID, client.ServerId);
            foreach (TalentEffectItem item in roleCustomData.EffectList)
            {
                TalentManager.ModifyEffect(client, item.ID, item.TalentType, item.Level);
            }
            client.ClientData.DefaultSkillLev = roleCustomData.DefaultSkillLev;
            Global.SaveRoleParamsInt32ValueToDB(client, "DefaultSkillLev", client.ClientData.DefaultSkillLev, true);
            client.ClientData.DefaultSkillUseNum = roleCustomData.DefaultSkillUseNum;
            Global.SaveRoleParamsInt32ValueToDB(client, "DefaultSkillUseNum", client.ClientData.DefaultSkillUseNum, true);
            if (client.ClientData.FuWenTabList != null && client.ClientData.FuWenTabList.Count > 0)
            {
                for (int i = 0; i < client.ClientData.FuWenTabList.Count; i++)
                {
                    int        skillID           = 0;
                    List <int> shenShiActiveList = new List <int>();
                    if (roleCustomData.ShenShiEuipSkill != null && i < roleCustomData.ShenShiEuipSkill.Count)
                    {
                        skillID           = roleCustomData.ShenShiEuipSkill[i].SkillEquip;
                        shenShiActiveList = roleCustomData.ShenShiEuipSkill[i].ShenShiActiveList;
                    }
                    client.ClientData.FuWenTabList[i].SkillEquip        = skillID;
                    client.ClientData.FuWenTabList[i].ShenShiActiveList = shenShiActiveList;
                    Global.sendToDB <int, FuWenTabData>(20316, client.ClientData.FuWenTabList[i], 0);
                }
            }
        }
示例#2
0
        private void SaveRoleCustomData(GameClient client, RoleCustomData customData)
        {
            int oldIndex = -1;
            RoleCustomDataItem roleCustomDataOld = null;
            RoleCustomDataItem roleCustomData    = null;

            if (customData != null && customData.customDataList != null && customData.customDataList.Count > 0)
            {
                oldIndex = customData.customDataList.FindIndex((RoleCustomDataItem x) => x.Occupation == client.ClientData.Occupation);
                if (oldIndex >= 0)
                {
                    roleCustomDataOld = customData.customDataList[oldIndex];
                }
            }
            roleCustomData = new RoleCustomDataItem
            {
                Occupation = client.ClientData.Occupation
            };
            roleCustomData.Main_quick_keys = client.ClientData.MainQuickBarKeys;
            roleCustomData.RolePointList.Add(client.ClientData.PropStrength - Global.GetRoleParamsInt32FromDB(client, "PropStrengthChangeless"));
            roleCustomData.RolePointList.Add(client.ClientData.PropIntelligence - Global.GetRoleParamsInt32FromDB(client, "PropIntelligenceChangeless"));
            roleCustomData.RolePointList.Add(client.ClientData.PropDexterity - Global.GetRoleParamsInt32FromDB(client, "PropDexterityChangeless"));
            roleCustomData.RolePointList.Add(client.ClientData.PropConstitution - Global.GetRoleParamsInt32FromDB(client, "PropConstitutionChangeless"));
            for (int i = 0; i < roleCustomData.RolePointList.Count; i++)
            {
                if (roleCustomData.RolePointList[i] < 0)
                {
                    roleCustomData.RolePointList[i] = 0;
                }
            }
            int sum = roleCustomData.RolePointList.Sum();

            while (sum > client.ClientData.TotalPropPoint)
            {
                for (int i = 0; i < roleCustomData.RolePointList.Count; i++)
                {
                    if (roleCustomData.RolePointList[i] > 0)
                    {
                        List <int> rolePointList;
                        int        index;
                        (rolePointList = roleCustomData.RolePointList)[index = i] = rolePointList[index] - 1;
                        sum--;
                    }
                }
            }
            TalentData talentData = client.ClientData.MyTalentData;

            if (talentData != null && null != talentData.EffectList)
            {
                foreach (TalentEffectItem item in talentData.EffectList)
                {
                    roleCustomData.EffectList.Add(new TalentEffectItem
                    {
                        ID         = item.ID,
                        Level      = item.Level,
                        TalentType = item.TalentType
                    });
                }
            }
            roleCustomData.EffectList.Sort((TalentEffectItem x, TalentEffectItem y) => x.ID - y.ID);
            roleCustomData.DefaultSkillLev    = client.ClientData.DefaultSkillLev;
            roleCustomData.DefaultSkillUseNum = client.ClientData.DefaultSkillUseNum;
            if (client.ClientData.FuWenTabList != null && client.ClientData.FuWenTabList.Count > 0)
            {
                List <SkillEquipData> skillList = new List <SkillEquipData>();
                foreach (FuWenTabData item2 in client.ClientData.FuWenTabList)
                {
                    skillList.Add(new SkillEquipData
                    {
                        SkillEquip        = item2.SkillEquip,
                        ShenShiActiveList = item2.ShenShiActiveList
                    });
                }
                roleCustomData.ShenShiEuipSkill = skillList;
            }
            bool changed = false;

            if (null == roleCustomDataOld)
            {
                customData.customDataList.Add(roleCustomData);
            }
            else
            {
                if (null == roleCustomDataOld.RolePointList)
                {
                    changed = true;
                }
                else if (roleCustomDataOld.RolePointList.Count != roleCustomData.RolePointList.Count)
                {
                    changed = true;
                }
                else
                {
                    int i = 0;
                    while (i < roleCustomDataOld.RolePointList.Count && i < roleCustomData.RolePointList.Count)
                    {
                        if (roleCustomDataOld.RolePointList[i] != roleCustomData.RolePointList[i])
                        {
                            changed = true;
                            break;
                        }
                        i++;
                    }
                }
                if (null == roleCustomDataOld.EffectList)
                {
                    changed = true;
                }
                else if (roleCustomDataOld.EffectList.Count != roleCustomData.EffectList.Count)
                {
                    changed = true;
                }
                else
                {
                    roleCustomDataOld.EffectList.Sort((TalentEffectItem x, TalentEffectItem y) => x.ID - y.ID);
                    for (int i = 0; i < roleCustomDataOld.EffectList.Count; i++)
                    {
                        TalentEffectItem x2 = roleCustomDataOld.EffectList[i];
                        TalentEffectItem y2 = roleCustomData.EffectList[i];
                        if (x2.ID != y2.ID || x2.Level != y2.Level)
                        {
                            changed = true;
                            break;
                        }
                    }
                }
                if (roleCustomDataOld.Main_quick_keys != roleCustomData.Main_quick_keys)
                {
                    changed = true;
                }
                if (roleCustomData.DefaultSkillLev != roleCustomDataOld.DefaultSkillLev || roleCustomData.DefaultSkillUseNum != roleCustomDataOld.DefaultSkillUseNum)
                {
                    changed = true;
                }
                if (null != roleCustomData.ShenShiEuipSkill)
                {
                    changed = true;
                }
                if (changed)
                {
                    customData.customDataList[oldIndex] = roleCustomData;
                }
            }
            if (client.ClientData.IsMainOccupation)
            {
                customData.roleData4Selector = Global.RoleDataEx2RoleData4Selector(client.ClientData.GetRoleData());
            }
            Global.sendToDB <int, RoleCustomData>(10233, customData, client.ServerId);
        }