|
|
@@ -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);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
}
|