Selaa lähdekoodia

物品属性同步

guodong 3 vuotta sitten
vanhempi
commit
426672b89c

+ 1 - 1
GameClient/Assets/Game/CSShare

@@ -1 +1 @@
-Subproject commit 7c742ea5595ef1c3ebecc9251f33fe12a6e9f9e3
+Subproject commit 84d650339db0434da3a558c65391853049bcf8b0

+ 2 - 0
GameClient/Assets/Game/HotUpdate/Constant/ConstMessage.cs

@@ -5,6 +5,8 @@ namespace GFGGame
         public const string DRESS_UP_SCORE_CHANGED = "DRESS_UP_SCORE_CHANGED";
         public const string ROLE_GOLD_CHANGED = "ROLE_GOLD_CHANGED";
         public const string ITEM_CHANGED = "ITEM_CHANGED";
+        public const string ITEM_ATTRIBUTE_CHANGED = "ITEM_ATTRIBUTE_CHANGED";
+
         public const string SUIT_BOX_STATUS_CHANGED = "SUIT_BOX_STATUS_CHANGED";
         public const string CJ_FINISH = "CJ_FINISH";
         public const string MAIL_CHANGE = "MAIL_CHANGE";

+ 5 - 5
GameClient/Assets/Game/HotUpdate/Controller/GameController.cs

@@ -1,8 +1,6 @@
 using FairyGUI;
 using UnityEngine;
-using UI.CommonGame;
-using UI.Main;
-using UI.Common;
+using ET;
 
 namespace GFGGame
 {
@@ -157,13 +155,15 @@ namespace GFGGame
                     ViewManager.Show(ViewName.STORY_CHAPTER_VIEW, StoryDataManager.currentChapter, new object[] { ViewName.STORY_CHAPTER_LIST_VIEW });
                 }
             }
-            AfterEnterGame();
+            Timers.inst.CallLater(AfterEnterGame);
         }
 
-        private static void AfterEnterGame()
+        private static void AfterEnterGame(object param)
         {
             //GameProxy.ReqGetStoryScoreList();
             //GameProxy.ReqGetStoryStarList();
+
+            ItemHelper.GetItemAttributeInfos().Coroutine();
         }
 
         public static void PrepareUpdateTreasure()

+ 19 - 0
GameClient/Assets/Game/HotUpdate/Data/ItemDataManager.cs

@@ -106,6 +106,25 @@ namespace GFGGame
             }
         }
 
+        public static void InitServerDataItemAttribute(List<ItemAttributeProto> infos)
+        {
+            foreach(var info in infos)
+            {
+                if(_dataDic.TryGetValue(info.ConfigId, out var itemData))
+                {
+                    itemData.SetAttributes(info.Ks, info.Vs);
+                }
+            }
+        }
+
+        public static void SetAttribute(int itemId, int key, int value)
+        {
+            if (_dataDic.TryGetValue(itemId, out var itemData))
+            {
+                itemData.SetAttribute(key, value);
+            }
+        }
+
         public static void GetMainScore(int itemId, out int mainScore, out int mainScoreValue)
         {
             ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(itemId);

+ 18 - 2
GameClient/Assets/Game/HotUpdate/Data/VO/ItemData.cs

@@ -12,8 +12,7 @@ namespace GFGGame
         public int num;
         public bool isOnceBonus;
 
-        public Dictionary<int, int> AttributesDic = new Dictionary<int, int>();
-        delegate object MemberGetDelegate(ItemCfg p);
+        private Dictionary<int, int> AttributesDic = new Dictionary<int, int>();
 
         public void Reset()
         {
@@ -23,6 +22,23 @@ namespace GFGGame
             AttributesDic.Clear();
         }
 
+        public void SetAttributes(List<int> keys, List<int> values)
+        {
+            for(var i = 0; i < keys.Count; ++i)
+            {
+                SetAttribute(keys[i], values[i], false);
+            }
+        }
+
+        public void SetAttribute(int key, int value, bool dispatch = true)
+        {
+            AttributesDic[key] = value;
+            if(dispatch)
+            {
+                EventAgent.DispatchEvent(ConstMessage.ITEM_ATTRIBUTE_CHANGED, id);
+            }
+        }
+
         public int MainScore
         {
             get