From f4f07847775c12b338d8bccedbbabc067dc1ae2c Mon Sep 17 00:00:00 2001
From: client_linchunjie <461730578@qq.com>
Date: 星期六, 18 八月 2018 14:34:26 +0800
Subject: [PATCH] Merge branch '法宝、法宝魂修改'

---
 System/Treasure/TreasureData.cs |  514 +++++++++-----------------------------------------------
 1 files changed, 88 insertions(+), 426 deletions(-)

diff --git a/System/Treasure/TreasureData.cs b/System/Treasure/TreasureData.cs
index 3a3a23b..5eb5636 100644
--- a/System/Treasure/TreasureData.cs
+++ b/System/Treasure/TreasureData.cs
@@ -17,13 +17,6 @@
     {
         public int id { get; private set; }
 
-        int m_Level;
-        public int level
-        {
-            get { return m_Level; }
-            set { m_Level = value; }
-        }
-
         int m_Stage;
         public int stage
         {
@@ -52,7 +45,6 @@
             set { m_State = value; }
         }
 
-        #region 鏃ф暟鎹�
         int m_Progress = 0;
         public int progress
         {
@@ -86,11 +78,6 @@
             }
         }
 
-        public int unLockFunc
-        {
-            get; private set;
-        }
-
         public int unLockPrivilege
         {
             get; private set;
@@ -115,8 +102,6 @@
 
         public List<int> achievements = new List<int>();
         public Dictionary<int, AchievementGroup> achievementGroups = new Dictionary<int, AchievementGroup>();
-
-        public Item[] needItems { get; private set; }
 
         public Redpoint skillLevelUpRedpoint { get; private set; }
         public Redpoint achievementRedpoint { get; private set; }
@@ -188,29 +173,6 @@
                         tempPotentials.Add(new TreasurePotential(skillId, 0));
                     }
                 }
-
-            }
-
-            if (!string.IsNullOrEmpty(config.NeedItem))
-            {
-                try
-                {
-                    var stringSet = config.NeedItem.Split('|');
-                    needItems = new Item[stringSet.Length];
-                    for (int i = 0; i < needItems.Length; i++)
-                    {
-                        var itemStrings = stringSet[i].Split('_');
-                        needItems[i] = new Item(int.Parse(itemStrings[0]), int.Parse(itemStrings[1]));
-                    }
-                }
-                catch (Exception ex)
-                {
-                    Debug.Log(ex.StackTrace);
-                }
-            }
-            else
-            {
-                needItems = null;
             }
         }
 
@@ -269,40 +231,11 @@
 
             return configA.ReOrder < configB.ReOrder ? -1 : 1;
         }
-        #endregion
-
-        public TreasureSpecialData specialData { get; private set; }
 
         public List<TreasureStage> treasureStages = new List<TreasureStage>();
         public void UpdateTreasureStage(TreasureUpConfig _cfg)
         {
-            TreasureStage _stage;
-            if (_cfg.UnLockFuncID != 0)
-            {
-                _stage = new TreasureStage(_cfg.UnLockFuncID);
-                unLockFunc = _stage.func;
-            }
-            else if (_cfg.Privilege != 0)
-            {
-                _stage = new TreasureStage(_cfg.Privilege, TreasureStageUnlock.Privilege);
-                specialData = _stage.specialData;
-                unLockPrivilege = _stage.privilege;
-            }
-            else if (_cfg.UnLockSkill != null && _cfg.UnLockSkill.Length > 1)
-            {
-                _stage = new TreasureStage(_cfg.UnLockSkill);
-            }
-            else if (!_cfg.AddAttr.Equals(string.Empty))
-            {
-                _stage = new TreasureStage(_cfg.AddAttr);
-            }
-            else
-            {
-                _stage = new TreasureStage();
-            }
-            _stage.exp = _cfg.NeedExp;
-            _stage.stage = _cfg.LV;
-            _stage.limitLevel = _cfg.LVLimit;
+            TreasureStage _stage = new TreasureStage(_cfg);
             treasureStages.Add(_stage);
         }
 
@@ -311,18 +244,21 @@
             stage = _lv;
             exp = _exp;
             hasClickChallenge = _hasClickChallenge;
-            if ((this is HumanTreasure) && IsMaxStage())
+            if ((this is HumanTreasure))
             {
-                (this as HumanTreasure).humanState = HumanTreasureState.Potential;
+                (this as HumanTreasure).UpdateTreasureState();
             }
         }
 
-        public bool IsMaxStage()
+        public bool IsHighestStage
         {
-            return treasureStages.FindIndex((x) =>
+            get
             {
-                return x.stage >= stage + 1;
-            }) == -1;
+                return treasureStages.FindIndex((x) =>
+                {
+                    return x.stage >= stage + 1;
+                }) == -1;
+            }
         }
 
         public bool IsUnlockStage(TreasureStageUnlock _type)
@@ -362,24 +298,11 @@
             {
                 return m_State;
             }
-            set
+            private set
             {
                 m_State = value;
-                if (value == HumanTreasureState.CastSoul)
-                {
-                    if (IsMaxStage())
-                    {
-                        m_State = HumanTreasureState.Potential;
-                    }
-                }
                 ModelCenter.Instance.GetModel<TreasureModel>().HumanTreasureStateChange(base.id);
             }
-        }
-
-        public HumanTreasure(int _id)
-            : base(_id)
-        {
-
         }
 
         public HumanTreasure(int _id, int[] _potentialIds, Redpoint _skillLevelUpRedpoint, Redpoint _achievementPoint
@@ -387,6 +310,28 @@
             : base(_id, _potentialIds, _skillLevelUpRedpoint, _achievementPoint)
         {
             castSoulRedpoint = _castSoulPoint;
+        }
+
+        public void UpdateTreasureState()
+        {
+            if (state == TreasureState.Locked)
+            {
+                humanState = HumanTreasureState.Locked;
+                return;
+            }
+            if (state == TreasureState.Collecting)
+            {
+                humanState = HumanTreasureState.Challenge;
+                return;
+            }
+            if (IsHighestStage && FuncOpen.Instance.IsFuncOpen(82))
+            {
+                humanState = HumanTreasureState.Potential;
+            }
+            else
+            {
+                humanState = HumanTreasureState.CastSoul;
+            }
         }
 
         public Redpoint castSoulRedpoint { get; private set; }
@@ -600,63 +545,71 @@
         public Dictionary<int, int> propertyDict { get; private set; }
         public Dictionary<int, int> skillDict { get; private set; }
         public int func { get; private set; }
-        public int privilege { get; private set; }
+        public Item item { get; private set; }
+        public int treasure { get; private set; }
         public int exp { get; set; }
-        public TreasureSpecialData specialData { get; private set; }
         public int stateSfxId { get; private set; }
         public const int selectedSfxId = 5144;
         public string sfxGotState { get; private set; }
         public string sfxUnGotState { get; private set; }
-        public int limitLevel { get; set; }
-
-        public TreasureStage()
+        public TreasureStage(TreasureUpConfig _config)
         {
             unlockType = TreasureStageUnlock.None;
-        }
-
-        public TreasureStage(int _value, TreasureStageUnlock _type = TreasureStageUnlock.Func)
-        {
-            unlockType = _type;
-            func = _type == TreasureStageUnlock.Func ? _value : 0;
-            privilege = _type == TreasureStageUnlock.Privilege ? _value : 0;
-            stateSfxId = 5141;
-            sfxGotState = "Effect_FaBao_Icon_JiNeng_01";
-            sfxUnGotState = "Effect_FaBao_Icon_JiNeng_02";
-            //stateSfxId = _type == TreasureStageUnlock.Func ? 5140 : 5143;
-            //sfxGotState = _type == TreasureStageUnlock.Func ? "Effect_FaBao_Icon_GongNeng_01" : "Effect_FaBao_Icon_TeQuan_02";
-            //sfxUnGotState = _type == TreasureStageUnlock.Func ? "Effect_FaBao_Icon_GongNeng" : "Effect_FaBao_Icon_TeQuan";
-            if (_type == TreasureStageUnlock.Privilege)
+            if (_config.UnLockFuncID != 0)
             {
-                SetSpecial();
+                unlockType = TreasureStageUnlock.Func;
+                func = _config.UnLockFuncID;
             }
-        }
-
-        public TreasureStage(string _property)
-        {
-            unlockType = TreasureStageUnlock.Property;
-            propertyDict = ConfigParse.GetDic<int, int>(_property);
-            stateSfxId = propertyDict.ContainsKey(6) ? 5142 : 5139;
-            sfxGotState = propertyDict.ContainsKey(6) ? "Effect_FaBao_Icon_ShengMing" : "Effect_FaBao_Icon_GongJi";
-            sfxUnGotState = propertyDict.ContainsKey(6) ? "Effect_FaBao_Icon_ShengMing" : "Effect_FaBao_Icon_GongJi";
-        }
-
-        public TreasureStage(int[] _skills)
-        {
-            unlockType = TreasureStageUnlock.Skill;
-            stateSfxId = 5141;
-            sfxGotState = "Effect_FaBao_Icon_JiNeng_01";
-            sfxUnGotState = "Effect_FaBao_Icon_JiNeng_02";
-            skillDict = new Dictionary<int, int>();
-            for (int i = 0; i < _skills.Length; i++)
+            else if (_config.UnLockSkill != null && _config.UnLockSkill.Length > 1)
             {
-                skillDict.Add(i + 1, _skills[i]);
+                unlockType = TreasureStageUnlock.Skill;
+                skillDict = new Dictionary<int, int>();
+                for (int i = 0; i < _config.UnLockSkill.Length; i++)
+                {
+                    skillDict.Add(i + 1, _config.UnLockSkill[i]);
+                }
             }
-        }
+            else if (!string.IsNullOrEmpty(_config.AddAttr))
+            {
+                unlockType = TreasureStageUnlock.Property;
+                propertyDict = ConfigParse.GetDic<int, int>(_config.AddAttr);
+            }
+            else if (_config.ActiveMWID != 0)
+            {
+                unlockType = TreasureStageUnlock.Treasure;
+                treasure = _config.ActiveMWID;
+            }
+            else if (!string.IsNullOrEmpty(_config.ItemAward))
+            {
+                unlockType = TreasureStageUnlock.Item;
+                var itemArray = LitJson.JsonMapper.ToObject<int[]>(_config.ItemAward);
+                if (itemArray != null && itemArray.Length > 0)
+                {
+                    item = new Item()
+                    {
+                        id = itemArray[0],
+                        count = itemArray.Length > 1 ? itemArray[1] : 1,
+                        bind = itemArray.Length > 2 ? (itemArray[2] == 1) : false,
+                    };
+                }
+            }
 
-        public void SetSpecial()
-        {
-            var _priviligeCfg = ConfigManager.Instance.GetTemplate<TreasurePrivilegeConfig>(privilege);
-            specialData = new TreasureSpecialData((TreasurePrivilege)_priviligeCfg.PrivilegeID);
+            exp = _config.NeedExp;
+            stage = _config.LV;
+
+            switch (unlockType)
+            {
+                case TreasureStageUnlock.Property:
+                    stateSfxId = propertyDict.ContainsKey(6) ? 5142 : 5139;
+                    sfxGotState = propertyDict.ContainsKey(6) ? "Effect_FaBao_Icon_ShengMing" : "Effect_FaBao_Icon_GongJi";
+                    sfxUnGotState = propertyDict.ContainsKey(6) ? "Effect_FaBao_Icon_ShengMing" : "Effect_FaBao_Icon_GongJi";
+                    break;
+                default:
+                    stateSfxId = 5141;
+                    sfxGotState = "Effect_FaBao_Icon_JiNeng_01";
+                    sfxUnGotState = "Effect_FaBao_Icon_JiNeng_02";
+                    break;
+            }
         }
 
         public int GetSkill(int _job)
@@ -682,8 +635,6 @@
                         return _skillCfg.FightPower;
                     }
                     break;
-                case TreasureStageUnlock.Privilege:
-                    return specialData.GetFightPower();
             }
             return 0;
         }
@@ -695,297 +646,8 @@
         Property,
         Skill,
         Func,
-        Privilege,
-    }
-
-    public enum TreasurePrivilege
-    {
-        Property = 1,
-        DemonJarAtk = 2,
-        StrengthenAdd = 3,
-        RuneBreakExpAdd = 4,
-        MountAtk = 5,
-        PetHp = 6,
-        Boss = 7,
-        Wing = 8,
-        Suit = 9,
-        Wash = 10,
-        Sign = 11,
-    }
-
-    public enum TreasurePrivilegeState
-    {
-        Doing = 0,
-        Reward = 1,
-        Complete = 2
-    }
-
-    public class TreasureSpecialData
-    {
-        public TreasurePrivilege type { get; private set; }
-        public int progress { get; private set; }
-        public int totalProgress { get; private set; }
-        public int effectValue { get; private set; }
-        public List<AwardItem> items { get; private set; }
-        public Dictionary<int, int> propertyDict { get; private set; }
-        public Redpoint privilegeRedpoint { get; private set; }
-
-        private TreasurePrivilegeState m_State = TreasurePrivilegeState.Doing;
-        public TreasurePrivilegeState state
-        {
-            get { return m_State; }
-            set { m_State = value; }
-        }
-
-        public int presentFinishCount { get; set; }
-        public int presentGetCount { get; set; }
-        public bool itemGet { get; set; }
-
-        public TreasureSpecialData(TreasurePrivilege _type)
-        {
-            type = _type;
-            var config = ConfigManager.Instance.GetTemplate<TreasurePrivilegeConfig>((int)_type);
-            progress = Mathf.Max(1, config.singleValue);
-            totalProgress = config.maxValue;
-            var _effectValue = 0;
-            int.TryParse(config.EffectValue, out _effectValue);
-            effectValue = _effectValue;
-            if (!string.IsNullOrEmpty(config.attr))
-            {
-                var propertyJson = LitJson.JsonMapper.ToObject(config.attr);
-                propertyDict = new Dictionary<int, int>();
-                foreach (var _key in propertyJson.Keys)
-                {
-                    var _property = int.Parse(_key);
-                    var _value = int.Parse(propertyJson[_key].ToJson());
-                    propertyDict.Add(_property, _value);
-                }
-            }
-            if (!string.IsNullOrEmpty(config.itemAward))
-            {
-                var itemArray = LitJson.JsonMapper.ToObject<int[][]>(config.itemAward);
-                if (itemArray != null && itemArray.Length > 0)
-                {
-                    items = new List<AwardItem>();
-                    for (int i = 0; i < itemArray.Length; i++)
-                    {
-                        var _array = itemArray[i];
-                        items.Add(new AwardItem()
-                        {
-                            isBind = _array[2],
-                            item = new Item()
-                            {
-                                id = _array[0],
-                                count = _array[1],
-                            },
-                        });
-                    }
-                }
-            }
-
-            if (type == TreasurePrivilege.PetHp)
-            {
-                var petCount = ConfigManager.Instance.GetAllValues<PetInfoConfig>().Count;
-                totalProgress = petCount;
-            }
-            else if (type == TreasurePrivilege.MountAtk)
-            {
-                var mountConfigs = ConfigManager.Instance.GetAllValues<HorseConfig>();
-                var maxlv = 0;
-                for (int i = 0; i < mountConfigs.Count; i++)
-                {
-                    maxlv += mountConfigs[i].MaxLV;
-                }
-                totalProgress = maxlv;
-            }
-            else if (type == TreasurePrivilege.StrengthenAdd)
-            {
-                var configs = ConfigManager.Instance.GetAllValues<ItemPlusSumAttrConfig>();
-                totalProgress = configs[configs.Count - 1].countNeed;
-            }
-
-            switch (_type)
-            {
-                case TreasurePrivilege.DemonJarAtk:
-                case TreasurePrivilege.StrengthenAdd:
-                case TreasurePrivilege.MountAtk:
-                case TreasurePrivilege.PetHp:
-                case TreasurePrivilege.Boss:
-                case TreasurePrivilege.Wash:
-                    privilegeRedpoint = new Redpoint(TreasureModel.TREASURE_SOUL_ID, TreasureModel.TREASURE_SOUL_ID * 100 + (int)type);
-                    break;
-            }
-        }
-
-        public int GetPrivilegeValue(int _index = 0)
-        {
-            switch (type)
-            {
-                case TreasurePrivilege.RuneBreakExpAdd:
-                    return effectValue;
-                case TreasurePrivilege.DemonJarAtk:
-                case TreasurePrivilege.Suit:
-                    return effectValue;
-                case TreasurePrivilege.Wing:
-                case TreasurePrivilege.StrengthenAdd:
-                    return effectValue;
-            }
-            return 0;
-        }
-
-        public void UpdateState()
-        {
-            switch (type)
-            {
-                case TreasurePrivilege.Property:
-                case TreasurePrivilege.RuneBreakExpAdd:
-                case TreasurePrivilege.Wing:
-                case TreasurePrivilege.Suit:
-                    state = TreasurePrivilegeState.Complete;
-                    break;
-                case TreasurePrivilege.Boss:
-                case TreasurePrivilege.DemonJarAtk:
-                case TreasurePrivilege.PetHp:
-                case TreasurePrivilege.MountAtk:
-                    privilegeRedpoint.state = RedPointState.None;
-                    if (presentFinishCount >= totalProgress && (presentGetCount / progress) >= (totalProgress / progress))
-                    {
-                        state = TreasurePrivilegeState.Complete;
-                    }
-                    else if (presentGetCount > 0 && presentFinishCount / progress < presentGetCount / progress)
-                    {
-                        state = TreasurePrivilegeState.Reward;
-                        privilegeRedpoint.state = RedPointState.Simple;
-                    }
-                    else
-                    {
-                        state = TreasurePrivilegeState.Doing;
-                    }
-                    break;
-                case TreasurePrivilege.Wash:
-                    privilegeRedpoint.state = itemGet ? RedPointState.None : RedPointState.Simple;
-                    state = itemGet ? TreasurePrivilegeState.Doing : TreasurePrivilegeState.Reward;
-                    break;
-                case TreasurePrivilege.StrengthenAdd:
-                    privilegeRedpoint.state = RedPointState.None;
-                    var strengthen = ModelCenter.Instance.GetModel<PlayerStrengthengDatas>();
-                    var playerpack = ModelCenter.Instance.GetModel<PlayerPackModel>();
-                    presentGetCount = 0;
-                    foreach (var value in strengthen._EqInfo.Values)
-                    {
-                        ItemModel itemModel = playerpack.GetItemModelByIndex(PackType.rptEquip, value.EquipIndex);
-                        if (itemModel != null)
-                        {
-                            presentGetCount += value.EquipPartStarLV;
-                        }
-                    }
-                    var configs = ConfigManager.Instance.GetAllValues<ItemPlusSumAttrConfig>();
-                    bool contains = configs.FindIndex((x) =>
-                    {
-                        return x.countNeed > presentFinishCount && presentGetCount >= x.countNeed;
-                    }) != -1;
-                    if (presentFinishCount >= totalProgress && presentGetCount >= totalProgress)
-                    {
-                        state = TreasurePrivilegeState.Complete;
-                    }
-                    else if (contains)
-                    {
-                        state = TreasurePrivilegeState.Reward;
-                        privilegeRedpoint.state = RedPointState.Simple;
-                    }
-                    else
-                    {
-                        state = TreasurePrivilegeState.Doing;
-                    }
-                    break;
-            }
-        }
-
-        public string ProgressDisplay()
-        {
-            switch (type)
-            {
-                case TreasurePrivilege.DemonJarAtk:
-                case TreasurePrivilege.PetHp:
-                case TreasurePrivilege.MountAtk:
-                case TreasurePrivilege.Boss:
-                    if (state == TreasurePrivilegeState.Complete) { return UIHelper.GetTextColorByItemColor(TextColType.Green, totalProgress.ToString(), true); }
-                    else if (state == TreasurePrivilegeState.Doing)
-                    {
-                        return StringUtility.Contact(UIHelper.GetTextColorByItemColor(TextColType.Red, presentGetCount.ToString(), true), "/", (presentFinishCount / progress + 1) * progress);
-                    }
-                    else if (state == TreasurePrivilegeState.Reward)
-                    {
-                        var _completeCount = (presentFinishCount / progress + 1) * progress;
-                        return StringUtility.Contact(UIHelper.GetTextColorByItemColor(TextColType.Green, presentGetCount.ToString(), true), "/", _completeCount);
-                    }
-                    break;
-                case TreasurePrivilege.StrengthenAdd:
-                    var configs = ConfigManager.Instance.GetAllValues<ItemPlusSumAttrConfig>();
-                    var next = configs.Count - 1;
-                    for (int i = 0; i < configs.Count; i++)
-                    {
-                        if (configs[i].countNeed > presentFinishCount)
-                        {
-                            next = i;
-                            break;
-                        }
-                    }
-                    if (state == TreasurePrivilegeState.Complete) { return totalProgress.ToString(); }
-                    else if (state == TreasurePrivilegeState.Doing
-                        || state == TreasurePrivilegeState.Reward)
-                    {
-                        var colortype = presentGetCount >= configs[next].countNeed ? TextColType.Green : TextColType.Red;
-                        return StringUtility.Contact(UIHelper.GetTextColorByItemColor(colortype, presentGetCount.ToString(), true), "/", configs[next].countNeed);
-                    }
-                    break;
-            }
-            return string.Empty;
-        }
-
-        public void GetReward()
-        {
-            switch (type)
-            {
-                case TreasurePrivilege.MountAtk:
-                case TreasurePrivilege.DemonJarAtk:
-                case TreasurePrivilege.PetHp:
-                case TreasurePrivilege.Boss:
-                case TreasurePrivilege.Wash:
-                    var _pak = new CA504_tagCMPlayerGetReward();
-                    _pak.RewardType = (int)GotServerRewardType.Def_RewardType_TreasureSoul;
-                    _pak.DataEx = (uint)type;
-                    _pak.DataExStrLen = 0;
-                    _pak.DataExStr = string.Empty;
-                    GameNetSystem.Instance.SendInfo(_pak);
-                    break;
-                case TreasurePrivilege.StrengthenAdd:
-                    var configs = ConfigManager.Instance.GetAllValues<ItemPlusSumAttrConfig>();
-                    var present = 0;
-                    for (int i = 0; i < configs.Count; i++)
-                    {
-                        if (presentGetCount >= configs[i].countNeed)
-                        {
-                            present = i;
-                        }
-                    }
-                    CA503_tagCMActiveAllEquipAttr pak = new CA503_tagCMActiveAllEquipAttr();
-                    pak.Type = 0;
-                    pak.Cnt = (uint)configs[present].countNeed;
-                    GameNetSystem.Instance.SendInfo(pak);
-                    break;
-            }
-        }
-
-        public int GetFightPower()
-        {
-            var _fightPower = 0;
-            if (propertyDict != null)
-            {
-                _fightPower += UIHelper.GetFightPower(propertyDict);
-            }
-            return _fightPower;
-        }
+        Item,
+        Treasure,
     }
 }
 

--
Gitblit v1.8.0