Bläddra i källkod

消耗打点开发中

lcn 1 dag sedan
förälder
incheckning
af822e2660

+ 4 - 0
Assets/Scripts/Core/Event/Event/CustomEventType.cs

@@ -116,6 +116,10 @@ namespace Fort23.Core
       /// 获得道具
       /// </summary>
       AddItem,
+      /// <summary>
+      /// 消耗道具
+      /// </summary>
+      ItemCost,
       DaoYouCounUpdate,
       UpdateZuiZhongEvent,
       CancelEvent,

+ 22 - 3
Assets/Scripts/GameLogic/Bag/BagController.cs

@@ -142,12 +142,18 @@ namespace GameLogic.Bag
                 if (faaData != null)
                 {
                     // item.isSuiPian = true;
-                    //TODO 转碎片
+                    //TODO 转碎片?
+                    // ItemInfo info = new ItemInfo(item.config.associateVlaue[0], item.config.associateVlaue[2] * count);
+                    // DBManager.Instance.RecordGetItems("", info);
+                    DBManager.Instance.Source = "法宝碎片";
                     return AddItem(item.config.associateVlaue[0], item.config.associateVlaue[2] * count);
                 }
                 else
                 {
                     //TODO 完全体
+                    ItemInfo info = new ItemInfo(item.config.associateVlaue[0], item.config.associateVlaue[2] * count);
+                    DBManager.Instance.RecordGetItems("法宝本体转碎片", info);
+                    
                     faaData = new AccountFileInfo.FaBaoData();
                     faaData.id = item.config.associateVlaue[1];
                     faaData.level = 1;
@@ -168,11 +174,17 @@ namespace GameLogic.Bag
                 {
                     // item.isSuiPian = true;
                     //TODO 转碎片
+                    // ItemInfo info = new ItemInfo(item.config.associateVlaue[0], item.config.associateVlaue[2] * count);
+                    // DBManager.Instance.RecordGetItems("", info);
+                    DBManager.Instance.Source += "功法碎片";
                     return AddItem(item.config.associateVlaue[0], item.config.associateVlaue[2] * count);
                 }
                 else
                 {
-                    //TODO 完全体
+                    //TODO 法宝本体转碎片
+                    ItemInfo info = new ItemInfo(item.config.associateVlaue[0], item.config.associateVlaue[2] * count);
+                    DBManager.Instance.RecordGetItems("法宝本体转碎片", info);
+                    
                     skillData = new AccountFileInfo.SkillData();
                     skillData.id = item.config.associateVlaue[1];
                     skillData.star = 1;
@@ -194,7 +206,10 @@ namespace GameLogic.Bag
             }
             else if (item.config.itemTag == 9)
             {
-                //TODO 代金卷需要二次计算数量
+                //TODO 代金卷需要二次计算数量?
+                //ItemInfo info = new ItemInfo(item.config.associateVlaue[0], item.config.associateVlaue[1]);
+                // DBManager.Instance.RecordGetItems("", info);
+                DBManager.Instance.Source += "代金卷";
                 return AddItem(item.config.associateVlaue[0], item.config.associateVlaue[1]);
             }
             else if (item.config.itemTag == 28)
@@ -223,6 +238,9 @@ namespace GameLogic.Bag
                 if (item.count >= item.config.associateVlaue[0])
                 {
                     //TODO 合成广告卡
+                    // ItemInfo info = new ItemInfo(item.config.associateVlaue[1], 1);
+                    // DBManager.Instance.RecordGetItems("", info);
+                    DBManager.Instance.Source += "合成广告卡";
                     AddItem(item.config.associateVlaue[1], 1);
                 }
             }
@@ -438,6 +456,7 @@ namespace GameLogic.Bag
             }
 
             EventManager.Instance.Dispatch(CustomEventType.ItemUpdate, new ItemUpdateData() { ItemInfo = item });
+            EventManager.Instance.Dispatch(CustomEventType.ItemCost, new ItemUpdateData() { ItemInfo = item, Count = (int)count});
             AccountFileInfo.Instance.SaveItemData(item);
             RedDotManager.Instance.AllRedDotUpDate();
             return true;

+ 1 - 2
Assets/Scripts/GameLogic/Bag/ItemInfo.cs

@@ -14,8 +14,7 @@ namespace GameLogic.Bag
         public ItemConfig config;
 
         public bool isSuiPian = false;
-
-      
+        
 
         public ItemInfo(int itemID, long count = 0)
         {

+ 86 - 6
Assets/Scripts/GameLogic/SDK/DBManager.cs

@@ -1,5 +1,8 @@
+using System;
 using System.Collections;
 using System.Collections.Generic;
+using Common.Utility.CombatEvent;
+using Fort23.Core;
 using GameLogic.Bag;
 using UnityEngine;
 using Utility;
@@ -8,9 +11,35 @@ public class DBManager : Singleton<DBManager>
 {
     public DBManager()
     {
+       EventManager.Instance.AddEventListener(CustomEventType.ItemUpdate, ItemUpdate);
+
+       EventManager.Instance.AddEventListener(CustomEventType.ItemCost, ItemCost);
        
     }
 
+    public string Source = "";
+
+    protected override void ProDispose()
+    {
+        EventManager.Instance.RemoveEventListener(CustomEventType.ItemUpdate, ItemUpdate);
+        EventManager.Instance.RemoveEventListener(CustomEventType.ItemCost, ItemCost);
+    }
+    
+    private void ItemCost(IEventData e)
+    {
+        ItemUpdateData data = e as ItemUpdateData;
+
+        // if (data != null) RecordCostItems(Source, data.ItemInfo);
+    }
+
+
+    private void ItemUpdate(IEventData e)
+    {
+        ItemUpdateData data = e as ItemUpdateData;
+
+        // if (data != null) RecordGetItems(Source, data.ItemInfo);
+    }
+
     /// <summary>
     /// 自定义打点
     /// </summary>
@@ -29,8 +58,19 @@ public class DBManager : Singleton<DBManager>
         
     }
 
+    private void ProcessSource(Dictionary<string, object> properties, string s)
+    {
+        if (string.IsNullOrEmpty(s))
+        {
+            properties.Add("#source", Source);
+        }
+        else {
+            properties.Add("#source", s);
+        }
+    }
+    
     /// <summary>
-    /// 记录道具获取
+    /// 获取道具记录
     /// </summary>
     /// <param name="source">来源</param>
     /// <param name="items">道具</param>
@@ -39,29 +79,51 @@ public class DBManager : Singleton<DBManager>
         Dictionary<string, object> properties = new Dictionary<string, object>();
         foreach (ItemInfo itemInfo in items)
         {
-            int id = itemInfo.config.ID;
+            int id = itemInfo.itemID;
             long count = itemInfo.count.Value;
             properties.Add(id.ToString(), count);
         }
         
-        properties.Add("#source", source);
+        ProcessSource(properties, source);
+        // properties.Add("#source", source);
+            
+        CustomEvent("#get_items", properties);
+        Source = "";
+    }
+    
+    /// <summary>
+    /// 获取道具记录
+    /// </summary>
+    /// <param name="source"></param>
+    /// <param name="itemInfo"></param>
+    public void RecordGetItems(string source, ItemInfo itemInfo)
+    {
+        Dictionary<string, object> properties = new Dictionary<string, object>();
+
+        int id = itemInfo.itemID;
+        long count = itemInfo.count.Value;
+        properties.Add(id.ToString(), count);
+        
+        // properties.Add("#source", source);
+        ProcessSource(properties, source);
             
         CustomEvent("#get_items", properties);
     }
 
     /// <summary>
-    /// 记录道具消耗
+    /// 消耗道具记录
     /// </summary>
     /// <param name="source"></param>
     /// <param name="items"></param>
     public void RecordCostItems(string source, List<ItemInfo> items)
     {
         Dictionary<string, object> properties = new Dictionary<string, object>();
-        properties.Add("#source", source);
+        // properties.Add("#source", source);
+        ProcessSource(properties, source);
         
         foreach (ItemInfo itemInfo in items)
         {
-            int id = itemInfo.config.ID;
+            int id = itemInfo.itemID;
             long count = itemInfo.count.Value;
             properties.Add(id.ToString(), count);
         }
@@ -70,4 +132,22 @@ public class DBManager : Singleton<DBManager>
         
     }
     
+    /// <summary>
+    /// 消耗道具记录
+    /// </summary>
+    /// <param name="source"></param>
+    /// <param name="itemInfo"></param>
+    public void RecordCostItems(string source, ItemInfo itemInfo)
+    {
+        Dictionary<string, object> properties = new Dictionary<string, object>();
+        // properties.Add("#source", source);
+        ProcessSource(properties, source);
+        int id = itemInfo.itemID;
+        long count = itemInfo.count.Value;
+        properties.Add(id.ToString(), count);
+        
+        CustomEvent("#cost_items", properties);
+        
+    }
+    
 }

+ 1 - 1
Assets/Scripts/GameUI/ULockWidget.cs

@@ -138,7 +138,7 @@ public class ULockWidget : MonoBehaviour, IPointerClickHandler
                     mUIButton.interactable = true;
                 }
 
-                //TODO 恢复正常颜色
+                //恢复正常颜色
                 gameObject.transform.RecoverColor();
             }