fix:1、修复bug。 2、1.0.8版本提审
This commit is contained in:
@@ -1,281 +0,0 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using DataEyeAnalytics;
|
||||
using Newtonsoft.Json;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BallKingdomCrush
|
||||
{
|
||||
public class BIManager : MonoBehaviour
|
||||
{
|
||||
private static BIManager _instance;
|
||||
private static readonly object _initLock = new object();
|
||||
|
||||
// 状态标志
|
||||
private bool _initialized = false; // 仅在初始化成功后为 true
|
||||
private bool _initializing = false; // 防止并发多次尝试初始化
|
||||
|
||||
|
||||
private string ntpServer = "time.windows.com";
|
||||
private string defaultChannel = "gp";
|
||||
private int maxInitRetries = 6;
|
||||
private float retryIntervalSeconds = 0.5f;
|
||||
|
||||
public static BIManager Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_instance == null)
|
||||
{
|
||||
var go = new GameObject("BIManager");
|
||||
DontDestroyOnLoad(go);
|
||||
_instance = go.AddComponent<BIManager>();
|
||||
}
|
||||
|
||||
return _instance;
|
||||
}
|
||||
}
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
// 单例保护:如果场景里已有实例,销毁重复的
|
||||
if (_instance == null)
|
||||
{
|
||||
_instance = this;
|
||||
DontDestroyOnLoad(gameObject);
|
||||
}
|
||||
else if (_instance != this)
|
||||
{
|
||||
Destroy(gameObject);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
// Start 调用 InitBI 是安全的:InitBI 本身是幂等且线程安全的
|
||||
InitBI();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 对外统一初始化入口(幂等、线程安全)
|
||||
/// </summary>
|
||||
public void InitBI()
|
||||
{
|
||||
// 快速检查
|
||||
if (_initialized) return;
|
||||
|
||||
lock (_initLock)
|
||||
{
|
||||
if (_initialized || _initializing)
|
||||
{
|
||||
// 已经初始化或正在初始化,直接返回
|
||||
return;
|
||||
}
|
||||
|
||||
_initializing = true;
|
||||
}
|
||||
|
||||
// 使用协程执行初始化(必要时可以做重试)
|
||||
StartCoroutine(DoInitCoroutine());
|
||||
}
|
||||
|
||||
private IEnumerator DoInitCoroutine()
|
||||
{
|
||||
try
|
||||
{
|
||||
int attempt = 0;
|
||||
Exception lastException = null;
|
||||
|
||||
while (attempt < maxInitRetries)
|
||||
{
|
||||
attempt++;
|
||||
try
|
||||
{
|
||||
// 这里不主动调用 DataEyeAnalyticsAPI.Init(...) 假设你使用的是场景里的 DataEyeAnalytics 预制体,
|
||||
// SDK 会在预制体 Awake/Start 里初始化。如果你的流程是手动 Init,请在这里调用 Init(appId)。
|
||||
|
||||
// 1) 校准时间(默认实例)
|
||||
DataEyeAnalyticsAPI.CalibrateTimeWithNtp(ntpServer);
|
||||
|
||||
// 2) 设置超参数
|
||||
var superProperties = new Dictionary<string, object>
|
||||
{
|
||||
{ "channel", defaultChannel }
|
||||
};
|
||||
DataEyeAnalyticsAPI.SetSuperProperties(superProperties);
|
||||
|
||||
// 3) 开启自动采集
|
||||
DataEyeAnalyticsAPI.EnableAutoTrack(AUTO_TRACK_EVENTS.ALL);
|
||||
|
||||
// 如果上面没有抛异常,认为初始化成功
|
||||
_initialized = true;
|
||||
Debug.Log($"[BIManager] InitBI succeeded on attempt {attempt}");
|
||||
yield break;
|
||||
}
|
||||
catch (ArgumentNullException ane)
|
||||
{
|
||||
// 典型:DataEye 内部 instance 还没创建(appId 为 null) -> retry
|
||||
lastException = ane;
|
||||
Debug.LogWarning(
|
||||
$"[BIManager] DataEye not ready (attempt {attempt}), will retry. msg={ane.Message}");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// 其他异常,记录并决定是否重试
|
||||
lastException = ex;
|
||||
Debug.LogWarning($"[BIManager] InitBI attempt {attempt} threw: {ex.Message}");
|
||||
}
|
||||
|
||||
// 等待后重试
|
||||
yield return new WaitForSeconds(retryIntervalSeconds);
|
||||
}
|
||||
|
||||
// 重试用尽仍失败 —— 打日志(不再抛异常以免影响游戏流程)
|
||||
Debug.LogError("[BIManager] InitBI failed after retries. Last exception: " +
|
||||
(lastException?.ToString() ?? "null"));
|
||||
}
|
||||
finally
|
||||
{
|
||||
lock (_initLock)
|
||||
{
|
||||
_initializing = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ================= 通用埋点 =================
|
||||
public void TrackEvent(string eventName, Dictionary<string, object> properties = null)
|
||||
{
|
||||
// if (properties == null)
|
||||
// properties = new Dictionary<string, object>();
|
||||
//
|
||||
// DataEyeAnalyticsAPI.Track(eventName, properties);
|
||||
// DataEyeAnalyticsAPI.Flush();
|
||||
//
|
||||
// Debug.Log($"[BI] 事件上报: {eventName}, 属性={JsonConvert.SerializeObject(properties)}");
|
||||
}
|
||||
|
||||
// ================= 预制事件封装 =================
|
||||
|
||||
/// <summary>
|
||||
/// 上报广告事件
|
||||
/// </summary>
|
||||
/// <param name="eventName"></param>
|
||||
/// <param name="adType">Native,RewardedVideo,Banner,Interstitial,Splash</param>
|
||||
/// <param name="placementId">聚合广告位id</param>
|
||||
/// <param name="networkFirmId">广告网络ID</param>
|
||||
public void TrackAdEvent(string eventName, string adType, string placementId = null,
|
||||
string networkFirmId = null, double revenue = 0, string scene = null, string currency = "USD")
|
||||
{
|
||||
var props = new Dictionary<string, object>
|
||||
{
|
||||
{ "ad_type", adType }
|
||||
};
|
||||
|
||||
if (!string.IsNullOrEmpty(placementId))
|
||||
props["PlacementId"] = placementId;
|
||||
|
||||
if (!string.IsNullOrEmpty(networkFirmId))
|
||||
props["NetworkFirmId"] = networkFirmId;
|
||||
|
||||
if (revenue > 0)
|
||||
{
|
||||
props["Revenue"] = revenue;
|
||||
props["Ecpm"] = revenue * 1000;
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(scene))
|
||||
props["scene"] = scene;
|
||||
|
||||
if (!string.IsNullOrEmpty(currency))
|
||||
props["Currency"] = currency;
|
||||
|
||||
|
||||
TrackEvent(eventName, props);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 上报内购事件
|
||||
/// </summary>
|
||||
/// <param name="revenue">收入</param>
|
||||
/// <param name="currency">币种</param>
|
||||
/// <param name="payType">支付方式 0=商店支付,1=三方支付</param>
|
||||
/// <param name="itemId">sku</param>
|
||||
/// <param name="status">order:下单 paid:付费成功 paid_err:扣款失败</param>
|
||||
/// <param name="itemName">商品名称</param>
|
||||
/// <param name="msg">如果遇到异常或相关情况,将err_msg进行上报</param>
|
||||
public void TrackPurchase(double revenue, string currency, string payType, string itemId,
|
||||
string status, string itemName = null, string msg = null)
|
||||
{
|
||||
var props = new Dictionary<string, object>
|
||||
{
|
||||
{ "Revenue", revenue },
|
||||
{ "Currency", currency },
|
||||
{ "type", payType },
|
||||
{ "item_id", itemId },
|
||||
{ "purchase_status", status }
|
||||
};
|
||||
|
||||
if (!string.IsNullOrEmpty(itemName))
|
||||
props["item_name"] = itemName;
|
||||
if (!string.IsNullOrEmpty(msg))
|
||||
props["msg"] = msg;
|
||||
|
||||
TrackEvent(BIEvent.PURCHASE, props);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 上报页面浏览
|
||||
/// </summary>
|
||||
public void TrackPageView(string pageName)
|
||||
{
|
||||
var props = new Dictionary<string, object>
|
||||
{
|
||||
{ "page_name", pageName } // 例如 "loading"、"game"
|
||||
};
|
||||
|
||||
TrackEvent(BIEvent.PAGE_VIEW, props);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// AB 分组埋点
|
||||
/// </summary>
|
||||
public void TrackABConfig(int responseTime)
|
||||
{
|
||||
var props = new Dictionary<string, object>
|
||||
{
|
||||
{ "response_time", responseTime }
|
||||
};
|
||||
|
||||
TrackEvent(BIEvent.AB_CONFIG, props);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class BIEvent
|
||||
{
|
||||
// 自动采集(SDK 开启自动采集即可,不需要手动埋点)
|
||||
public const string APP_INSTALL = "app_install";
|
||||
public const string APP_START = "app_start";
|
||||
public const string APP_END = "app_end";
|
||||
public const string APP_VIEW = "app_view";
|
||||
public const string APP_CRASH = "app_crash";
|
||||
|
||||
// 内部预制事件
|
||||
public const string AD_REQUEST = "ad_request"; // 广告请求
|
||||
public const string AD_INVENTORY = "ad_inventory"; // 广告填充的时候
|
||||
public const string AD_IMP = "ad_imp"; // 广告展示
|
||||
public const string AD_CLICK = "ad_click"; // 广告点击
|
||||
|
||||
public const string PURCHASE = "purchase"; // 内购
|
||||
|
||||
// 页面相关
|
||||
public const string PAGE_VIEW = "page_view_customize";
|
||||
|
||||
// 其他业务事件(AB 测试等)
|
||||
public const string AB_CONFIG = "config"; // AB
|
||||
}
|
||||
@@ -64,9 +64,12 @@ public class CreatAnimalCard : MonoBehaviour
|
||||
card_item_list.Clear();
|
||||
|
||||
// ---------- 新增:先从0~15中挑选 card_type_max 个不同的类型 ----------
|
||||
List<int> allTypes = Enumerable.Range(0, 15).ToList(); // [0,1,2,...,15]
|
||||
List<int> allTypes = Enumerable.Range(0, 15).ToList(); // [0,1,2,...,14]
|
||||
List<int> chosenTypes = new List<int>();
|
||||
for (int i = 0; i < card_type_max; i++)
|
||||
|
||||
int actualTypeMax = Mathf.Min(card_type_max, allTypes.Count);
|
||||
|
||||
for (int i = 0; i < actualTypeMax; i++)
|
||||
{
|
||||
int idx = UnityEngine.Random.Range(0, allTypes.Count);
|
||||
chosenTypes.Add(allTypes[idx]);
|
||||
|
||||
+274
-89
@@ -6,6 +6,7 @@
|
||||
// 请将商品 ID 替换为你在 App Store Connect / Google Play Console 中配置的真实 ID。
|
||||
// ============================================================
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using SDK_IAP;
|
||||
@@ -196,7 +197,7 @@ namespace BallKingdomCrush
|
||||
if (result.success)
|
||||
{
|
||||
Debug.Log($"[IAP Google] 订阅成功: {subscriptionName} ({result.productId}) | tid={result.transactionId}");
|
||||
ShowSubscriptionInfo();
|
||||
// ShowSubscriptionInfo();
|
||||
onSuccess?.Invoke();
|
||||
}
|
||||
else
|
||||
@@ -269,20 +270,59 @@ namespace BallKingdomCrush
|
||||
// ──────────────────────────────────────────────────────────
|
||||
// 订阅信息查询
|
||||
// ──────────────────────────────────────────────────────────
|
||||
public void ShowSubscriptionInfo()
|
||||
/// <summary>显示指定商品的订阅信息</summary>
|
||||
/// <param name="productId">商品ID</param>
|
||||
public void ShowSubscriptionInfo(string productId)
|
||||
{
|
||||
var info = IAPManager.GetSubscriptionInfo(PRODUCT_VIP_MONTH);
|
||||
Debug.Log($"[IAP Google] VIP 订阅状态:");
|
||||
var info = IAPManager.GetSubscriptionInfo(productId);
|
||||
Debug.Log($"[IAP Google] VIP 订阅状态 ({productId}):");
|
||||
Debug.Log($" isSubscribed = {info.isSubscribed}");
|
||||
Debug.Log($" isExpired = {info.isExpired}");
|
||||
Debug.Log($" expireDate = {info.expireDate:yyyy-MM-dd HH:mm:ss}");
|
||||
Debug.Log($" expireDate = {info.expireDate}");
|
||||
Debug.Log($" isAutoRenewing= {info.isAutoRenewing}");
|
||||
|
||||
if (info.isSubscribed && !info.isExpired)
|
||||
{
|
||||
int vipLevel = GetVipLevelByProductId(productId);
|
||||
if (vipLevel > 0)
|
||||
{
|
||||
DataMgr.VipLevel.Value = vipLevel;
|
||||
Debug.Log($"[IAP Google] 设置 VIP 等级: {vipLevel}");
|
||||
}
|
||||
|
||||
if (info.expireDate.Year > 1970 && info.expireDate.Year < 10000)
|
||||
{
|
||||
var expireTimestamp = ((DateTimeOffset)info.expireDate).ToUnixTimeSeconds();
|
||||
Debug.Log($"Expire timestamp: {expireTimestamp}");
|
||||
DataMgr.VipExpirationTime.Value = Math.Max(DataMgr.VipExpirationTime.Value, expireTimestamp);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning($"[IAP Google] 无效的到期时间: {info.expireDate}");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log($"[IAP Google] 用户未订阅或订阅已过期");
|
||||
}
|
||||
}
|
||||
/// <summary>根据商品ID获取VIP等级</summary>
|
||||
/// <param name="productId">商品ID</param>
|
||||
/// <returns>VIP等级:周订阅=1,月订阅=2,年订阅=3,其他=0</returns>
|
||||
private int GetVipLevelByProductId(string productId)
|
||||
{
|
||||
if (productId == PRODUCT_VIP_WEEK)
|
||||
return 1;
|
||||
else if (productId == PRODUCT_VIP_MONTH)
|
||||
return 2;
|
||||
else if (productId == PRODUCT_VIP_YEAR)
|
||||
return 3;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// ──────────────────────────────────────────────────────────
|
||||
// 全局发货处理(OnDeliver 事件接收)
|
||||
// ──────────────────────────────────────────────────────────
|
||||
|
||||
/// <summary>
|
||||
/// 统一发货处理入口。
|
||||
/// 无论是新购买、补单、还是恢复购买,都会触发此方法。
|
||||
@@ -290,97 +330,242 @@ namespace BallKingdomCrush
|
||||
/// </summary>
|
||||
private void HandleDeliver(string productId)
|
||||
{
|
||||
|
||||
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.PayloadingUI_Close);
|
||||
|
||||
if (!IsValidProduct(productId))
|
||||
{
|
||||
Debug.LogWarning($"[IAP Google] 非法商品ID,拒绝发货: {productId}");
|
||||
return;
|
||||
}
|
||||
Debug.Log($"[IAP Google] 发货通知: {productId}");
|
||||
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.IAP_PAY_SUCCESS, productId);
|
||||
|
||||
PurchasingManager.SendEventClickByName(productId,"open");
|
||||
PurchasingManager.SendEventClickByName(productId,"success");
|
||||
|
||||
// switch (productId)
|
||||
// {
|
||||
// // 消耗品
|
||||
// case PRODUCT_FIRST_GIFT:
|
||||
// Debug.Log("[IAP Google] 发放首充礼包 - 100金币");
|
||||
// // GoldManager.Add(100);
|
||||
// break;
|
||||
//
|
||||
// case PRODUCT_REMOVE_ADS:
|
||||
// Debug.Log("[IAP Google] 发放移除广告权益");
|
||||
// // AdsManager.Disable();
|
||||
// break;
|
||||
//
|
||||
// case PRODUCT_PASS_BONUS:
|
||||
// Debug.Log("[IAP Google] 发放通行证礼包");
|
||||
// // PassBonusManager.Grant();
|
||||
// break;
|
||||
//
|
||||
// case PRODUCT_SHOP_1:
|
||||
// Debug.Log("[IAP Google] 发放商店档位1奖励");
|
||||
// // ShopManager.GrantReward(1);
|
||||
// break;
|
||||
//
|
||||
// case PRODUCT_SHOP_2:
|
||||
// Debug.Log("[IAP Google] 发放商店档位2奖励");
|
||||
// // ShopManager.GrantReward(2);
|
||||
// break;
|
||||
//
|
||||
// case PRODUCT_SHOP_3:
|
||||
// Debug.Log("[IAP Google] 发放商店档位3奖励");
|
||||
// // ShopManager.GrantReward(3);
|
||||
// break;
|
||||
//
|
||||
// case PRODUCT_SHOP_4:
|
||||
// Debug.Log("[IAP Google] 发放商店档位4奖励");
|
||||
// // ShopManager.GrantReward(4);
|
||||
// break;
|
||||
//
|
||||
// case PRODUCT_SHOP_5:
|
||||
// Debug.Log("[IAP Google] 发放商店档位5奖励");
|
||||
// // ShopManager.GrantReward(5);
|
||||
// break;
|
||||
//
|
||||
// case PRODUCT_THREE_DAY:
|
||||
// Debug.Log("[IAP Google] 发放三天礼包");
|
||||
// // ThreeDayManager.Grant();
|
||||
// break;
|
||||
//
|
||||
// // 非消耗品
|
||||
// case PRODUCT_SPACE_BONUS:
|
||||
// Debug.Log("[IAP Google] 增加背包空间一格");
|
||||
// // InventoryManager.AddSpace(1);
|
||||
// break;
|
||||
//
|
||||
// // 订阅
|
||||
// case PRODUCT_VIP_WEEK:
|
||||
// Debug.Log("[IAP Google] 激活VIP周卡");
|
||||
// // VipManager.Activate(7);
|
||||
// break;
|
||||
//
|
||||
// case PRODUCT_VIP_MONTH:
|
||||
// Debug.Log("[IAP Google] 激活VIP月卡");
|
||||
// // VipManager.Activate(30);
|
||||
// break;
|
||||
//
|
||||
// case PRODUCT_VIP_YEAR:
|
||||
// Debug.Log("[IAP Google] 激活VIP年卡");
|
||||
// // VipManager.Activate(365);
|
||||
// break;
|
||||
//
|
||||
// default:
|
||||
// Debug.LogWarning($"[IAP Google] 未知商品 ID: {productId}");
|
||||
// break;
|
||||
// }
|
||||
if (productId == PRODUCT_VIP_WEEK || productId == PRODUCT_VIP_MONTH || productId == PRODUCT_VIP_YEAR)
|
||||
{
|
||||
// 订阅商品:需要先获取有效的订阅信息,成功后才会分发支付成功消息
|
||||
StartCoroutine(DelayedGetSubscriptionInfo(productId));
|
||||
}
|
||||
else
|
||||
{
|
||||
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.PayloadingUI_Close);
|
||||
|
||||
// 非订阅商品(消耗品):直接发货
|
||||
Debug.Log($"[IAP Google] 发货通知: {productId}");
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.IAP_PAY_SUCCESS, productId);
|
||||
PurchasingManager.SendEventClickByName(productId, "open");
|
||||
PurchasingManager.SendEventClickByName(productId, "success");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private IEnumerator DelayedGetSubscriptionInfo(string productId)
|
||||
{
|
||||
Debug.Log($"[IAP Google] 开始获取订阅信息: {productId}");
|
||||
|
||||
// 先尝试立即获取一次
|
||||
var immediateInfo = IAPManager.GetSubscriptionInfo(productId);
|
||||
|
||||
// 检查是否是无效数据
|
||||
bool isInvalid = immediateInfo.expireDate == default(DateTime) ||
|
||||
(immediateInfo.expireDate.Year == 1 && !immediateInfo.isSubscribed);
|
||||
|
||||
if (!isInvalid && immediateInfo.isSubscribed)
|
||||
{
|
||||
// 立即获取到了有效数据,直接处理
|
||||
bool success = ProcessSubscriptionInfo(immediateInfo, productId);
|
||||
if (success)
|
||||
{
|
||||
DispatchPaySuccess(productId);
|
||||
}
|
||||
yield break;
|
||||
}
|
||||
|
||||
// 无效数据,开始重试
|
||||
Debug.Log($"[IAP Google] 订阅信息未就绪,开始重试...");
|
||||
|
||||
int maxRetries = 5;
|
||||
float waitTime = 1.5f;
|
||||
for (int i = 0; i < maxRetries; i++)
|
||||
{
|
||||
yield return new WaitForSeconds(waitTime); // 每次等待0.5秒
|
||||
|
||||
var info = IAPManager.GetSubscriptionInfo(productId);
|
||||
|
||||
if (info.isSubscribed && !info.isExpired && info.expireDate.Year > 1970)
|
||||
{
|
||||
Debug.Log($"[IAP Google] 订阅信息获取成功 (重试 {i + 1} 次)");
|
||||
bool success = ProcessSubscriptionInfo(info, productId);
|
||||
if (success)
|
||||
{
|
||||
DispatchPaySuccess(productId);
|
||||
}
|
||||
yield break;
|
||||
}
|
||||
|
||||
Debug.Log($"[IAP Google] 第 {i + 1} 次重试: isSubscribed={info.isSubscribed}, isExpired={info.isExpired}, expireDate={info.expireDate}");
|
||||
}
|
||||
|
||||
// 所有重试都失败了,使用降级方案
|
||||
Debug.LogError($"[IAP Google] 无法获取订阅信息,使用降级方案");
|
||||
bool fallbackSuccess = ProcessFallbackSubscription(productId);
|
||||
if (fallbackSuccess)
|
||||
{
|
||||
DispatchPaySuccess(productId);
|
||||
}
|
||||
else
|
||||
{
|
||||
// 降级也失败了,上报错误,不分发支付成功
|
||||
Debug.LogError($"[IAP Google] 降级方案也失败,支付成功消息将不分发,请检查配置");
|
||||
PurchasingManager.SendEventClickByName(productId, "open");
|
||||
// 可选:向用户显示错误提示
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 处理订阅信息,设置VIP等级和过期时间
|
||||
/// </summary>
|
||||
/// <returns>是否设置成功</returns>
|
||||
private bool ProcessSubscriptionInfo(SubscriptionInfoLite info, string productId)
|
||||
{
|
||||
try
|
||||
{
|
||||
Debug.Log($"[IAP Google] VIP 订阅状态 ({productId}):");
|
||||
Debug.Log($" isSubscribed = {info.isSubscribed}");
|
||||
Debug.Log($" isExpired = {info.isExpired}");
|
||||
Debug.Log($" expireDate = {info.expireDate}");
|
||||
Debug.Log($" isAutoRenewing= {info.isAutoRenewing}");
|
||||
|
||||
// 获取VIP等级
|
||||
int vipLevel = GetVipLevelByProductId(productId);
|
||||
if (vipLevel <= 0)
|
||||
{
|
||||
Debug.LogError($"[IAP Google] 无法获取VIP等级,商品ID: {productId}");
|
||||
return false;
|
||||
}
|
||||
|
||||
// 获取过期时间戳
|
||||
long expireTimestamp = 0;
|
||||
if (info.expireDate.Year > 1970 && info.expireDate.Year < 10000)
|
||||
{
|
||||
expireTimestamp = ((DateTimeOffset)info.expireDate).ToUnixTimeSeconds();
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning($"[IAP Google] 无效的到期时间: {info.expireDate},使用预估时间");
|
||||
expireTimestamp = GetEstimatedExpireTimestamp(productId);
|
||||
}
|
||||
|
||||
if (expireTimestamp <= 0)
|
||||
{
|
||||
Debug.LogError($"[IAP Google] 无法获取有效的过期时间戳");
|
||||
return false;
|
||||
}
|
||||
|
||||
// 保存数据(使用前后对比,确保设置成功)
|
||||
int oldVipLevel = DataMgr.VipLevel.Value;
|
||||
long oldExpireTime = DataMgr.VipExpirationTime.Value;
|
||||
|
||||
DataMgr.VipLevel.Value = Math.Max(DataMgr.VipLevel.Value, vipLevel);
|
||||
DataMgr.VipExpirationTime.Value = Math.Max(DataMgr.VipExpirationTime.Value, expireTimestamp);
|
||||
|
||||
// 验证设置是否成功
|
||||
bool vipLevelSuccess = DataMgr.VipLevel.Value >= vipLevel;
|
||||
bool expireTimeSuccess = DataMgr.VipExpirationTime.Value >= expireTimestamp;
|
||||
|
||||
if (vipLevelSuccess && expireTimeSuccess)
|
||||
{
|
||||
Debug.Log($"[IAP Google] VIP设置成功 - 等级: {vipLevel} (原:{oldVipLevel}), 过期时间: {expireTimestamp} (原:{oldExpireTime})");
|
||||
|
||||
// 可选:触发VIP状态更新事件
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError($"[IAP Google] VIP设置失败 - 等级设置: {vipLevelSuccess}, 过期时间设置: {expireTimeSuccess}");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogError($"[IAP Google] 处理订阅信息时发生异常: {e.Message}\n{e.StackTrace}");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 降级方案:当无法从商店获取订阅信息时,根据商品类型估算VIP信息
|
||||
/// </summary>
|
||||
private bool ProcessFallbackSubscription(string productId)
|
||||
{
|
||||
try
|
||||
{
|
||||
Debug.LogWarning($"[IAP Google] 执行降级方案: {productId}");
|
||||
|
||||
int vipLevel = GetVipLevelByProductId(productId);
|
||||
if (vipLevel <= 0)
|
||||
{
|
||||
Debug.LogError($"[IAP Google] 降级方案失败 - 无法获取VIP等级");
|
||||
return false;
|
||||
}
|
||||
|
||||
long expireTimestamp = GetEstimatedExpireTimestamp(productId);
|
||||
if (expireTimestamp <= 0)
|
||||
{
|
||||
Debug.LogError($"[IAP Google] 降级方案失败 - 无法获取预估过期时间");
|
||||
return false;
|
||||
}
|
||||
|
||||
// 设置VIP信息
|
||||
DataMgr.VipLevel.Value = Math.Max(DataMgr.VipLevel.Value, vipLevel);
|
||||
DataMgr.VipExpirationTime.Value = Math.Max(DataMgr.VipExpirationTime.Value, expireTimestamp);
|
||||
|
||||
Debug.Log($"[IAP Google] 降级方案成功 - 等级: {vipLevel}, 过期时间: {expireTimestamp}");
|
||||
return true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogError($"[IAP Google] 降级方案异常: {e.Message}");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取预估的过期时间戳
|
||||
/// </summary>
|
||||
private long GetEstimatedExpireTimestamp(string productId)
|
||||
{
|
||||
TimeSpan duration;
|
||||
if (productId == PRODUCT_VIP_WEEK)
|
||||
{
|
||||
duration = TimeSpan.FromDays(7);
|
||||
}
|
||||
else if (productId == PRODUCT_VIP_MONTH)
|
||||
{
|
||||
duration = TimeSpan.FromDays(30);
|
||||
}
|
||||
else if (productId == PRODUCT_VIP_YEAR)
|
||||
{
|
||||
duration = TimeSpan.FromDays(365);
|
||||
}
|
||||
else
|
||||
{
|
||||
duration = TimeSpan.FromDays(30);
|
||||
}
|
||||
|
||||
var expireDate = DateTime.UtcNow.Add(duration);
|
||||
return ((DateTimeOffset)expireDate).ToUnixTimeSeconds();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 分发支付成功消息(统一出口)
|
||||
/// </summary>
|
||||
private void DispatchPaySuccess(string productId)
|
||||
{
|
||||
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.PayloadingUI_Close);
|
||||
|
||||
Debug.Log($"[IAP Google] 支付成功并完成发货: {productId}");
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.IAP_PAY_SUCCESS, productId);
|
||||
PurchasingManager.SendEventClickByName(productId, "open");
|
||||
PurchasingManager.SendEventClickByName(productId, "success");
|
||||
}
|
||||
|
||||
|
||||
/// <summary>验证商品ID是否为已定义的有效商品</summary>
|
||||
/// <param name="productId">商品ID</param>
|
||||
/// <returns>是否为有效商品</returns>
|
||||
|
||||
@@ -38,8 +38,8 @@ public class LoveLegendRoot : MonoBehaviour
|
||||
App.InitApplication(SuperApplication.Instance);
|
||||
NetworkManager.haveSimCard = HasSIMCard();
|
||||
|
||||
MarkdownKit.Instance.LoadText("privacy", "https://official.piggyhydration.com/privacy.md");
|
||||
MarkdownKit.Instance.LoadText("user", "https://official.piggyhydration.com/user.md");
|
||||
MarkdownKit.Instance.LoadText("privacy", "https://www.ballcrushbest.com/privacy.md");
|
||||
MarkdownKit.Instance.LoadText("user", "https://www.ballcrushbest.com/user.md");
|
||||
}
|
||||
|
||||
private static string adInfoLabel = "";
|
||||
|
||||
@@ -537,7 +537,7 @@ public class MaxPayManager
|
||||
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.PayloadingUI_Close);
|
||||
// Debug.LogWarning("OnPurchaseFailedproduct:" + product.transactionID + " failureReason:" + failureReason);
|
||||
|
||||
BIManager.Instance.TrackPurchase(paydata.amount, paydata.currency, "1", paydata.sku, "paid_err");
|
||||
// BIManager.Instance.TrackPurchase(paydata.amount, paydata.currency, "1", paydata.sku, "paid_err");
|
||||
|
||||
DOVirtual.DelayedCall(1, () => { SaveData.GetSaveObject().max_pay_object = null; });
|
||||
}
|
||||
|
||||
@@ -1,462 +1,462 @@
|
||||
|
||||
using FGUI.ZM_Common_01;
|
||||
using UnityEngine;
|
||||
using FairyGUI;
|
||||
using System.Collections.Generic;
|
||||
using FGUI.LG_albums;
|
||||
using FGUI.LG_Common;
|
||||
using SGModule.DataStorage;
|
||||
using DG.Tweening;
|
||||
using SGModule.Common.Extensions;
|
||||
using System.Linq;
|
||||
using SGModule.NetKit;
|
||||
namespace BallKingdomCrush
|
||||
{
|
||||
public class AlbumDetailUI : BaseUI
|
||||
{
|
||||
private AlbumDetailUICtrl ctrl;
|
||||
private AlbumDetailModel model;
|
||||
private FGUI.LG_albums.com_albumsDetail ui;
|
||||
|
||||
public AlbumDetailUI(AlbumDetailUICtrl ctrl) : base(ctrl)
|
||||
{
|
||||
uiName = UIConst.AlbumDetailUI;
|
||||
this.ctrl = ctrl;
|
||||
}
|
||||
|
||||
protected override void SetUIInfo(UIInfo uiInfo)
|
||||
{
|
||||
uiInfo.packageName = "LG_albums";
|
||||
uiInfo.assetName = "com_albumsDetail";
|
||||
uiInfo.layerType = UILayerType.Popup;
|
||||
uiInfo.isNeedOpenAnim = false;
|
||||
uiInfo.isNeedCloseAnim = false;
|
||||
uiInfo.isNeedUIMask = true;
|
||||
}
|
||||
|
||||
#region 生命周期
|
||||
protected override void OnInit()
|
||||
{
|
||||
//model = ModuleManager.Instance.GetModel(ModelConst.AlbumDetailModel) as AlbumDetailModel;
|
||||
}
|
||||
|
||||
protected override void OnClose()
|
||||
{
|
||||
if (loader != null && !loader.isDisposed && loader.texture != null)
|
||||
{
|
||||
loader.texture.Dispose();
|
||||
loader.texture = null;
|
||||
}
|
||||
loader = null;
|
||||
|
||||
if (new_index != -1)
|
||||
{
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.UnlockAlbums, index);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnBind()
|
||||
{
|
||||
ui = baseUI as FGUI.LG_albums.com_albumsDetail;
|
||||
}
|
||||
private List<LevelUnlock> LevelData;
|
||||
private int new_index = -1;
|
||||
private int index;
|
||||
|
||||
private GLoader loader = new GLoader();
|
||||
protected override void OnOpenBefore(object args)
|
||||
{
|
||||
index = (int)args;
|
||||
Debug.Log(index);
|
||||
ui.btn_close.SetClick(() =>
|
||||
{
|
||||
CtrlCloseUI();
|
||||
});
|
||||
LevelData = ConfigSystem.GetConfig<LevelUnlock>();
|
||||
// ui.list_.SetVirtual();
|
||||
// ui.list_.itemRenderer = RendererList;
|
||||
// ui.list_.numItems = GameHelper.GetLevel() - 1;
|
||||
// ui.list_.ScrollToView(new_index);
|
||||
|
||||
RendererList();
|
||||
}
|
||||
|
||||
protected override void OnOpen(object args)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnHide()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnDisplay(object args)
|
||||
{
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 消息
|
||||
protected override void AddListener()
|
||||
{
|
||||
GameDispatcher.Instance.AddListener(GameMsg.BuyVip, refrsh);
|
||||
}
|
||||
protected override void RemoveListener()
|
||||
{
|
||||
GameDispatcher.Instance.RemoveListener(GameMsg.BuyVip, refrsh);
|
||||
}
|
||||
#endregion
|
||||
|
||||
//初始化页面逻辑
|
||||
private void refrsh(object a = null)
|
||||
{
|
||||
DOVirtual.DelayedCall(0.5f, () =>
|
||||
{
|
||||
// ui.list_.numItems = GameHelper.GetLevel() - 1;
|
||||
RendererList();
|
||||
});
|
||||
|
||||
}
|
||||
// void RendererList(int index, GObject obj)
|
||||
void RendererList()
|
||||
{
|
||||
|
||||
item_albumsDetails item = (item_albumsDetails)ui.com_item;
|
||||
|
||||
loader = item.com_loader.GetChild("loader") as GLoader;
|
||||
|
||||
// if (GameHelper.GetVipPrivilege(Subscription.VipLevel.As<int>()))
|
||||
// {
|
||||
// (item.btn_vip as btn_claim_2).have_vip.selectedIndex = 1;
|
||||
|
||||
// }
|
||||
// if (GameHelper.GetVipPrivilege(Subscription.SLVLevel.As<int>()))
|
||||
// {
|
||||
// (item.btn_watch as btn_claim_1).have_vip.selectedIndex = 1;
|
||||
|
||||
// }
|
||||
|
||||
|
||||
var downloadCoinNum = ConfigSystem.GetCommonConf().CoinsDownload;
|
||||
var btn_down_coin = (FGUI.LG_Common.btn_unlock)item.btn_download_coin;
|
||||
btn_down_coin.title = downloadCoinNum.As<string>();
|
||||
btn_down_coin.down_load.selectedIndex = GameHelper.GetVipLevel() >= 1 ? 0 : 1;
|
||||
|
||||
|
||||
if (GameHelper.GetVipLevel() > 0)
|
||||
{
|
||||
(item.btn_download as FGUI.LG_Common.btn_claim).have_vip.selectedIndex = 1;
|
||||
item.is_vip.selectedIndex = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
item.is_vip.selectedIndex = 0;
|
||||
}
|
||||
if (index < GameHelper.GetCommonModel().MultiModal - 1)
|
||||
{
|
||||
TextureHelper.SetImgLoader(item.com_loader.GetChild("loader") as GLoader, LevelData[index].Name, null, "LevelAlbums/", FolderNames.AlbumName);
|
||||
item.btn_download.SetClick(() =>
|
||||
{
|
||||
|
||||
if (GameHelper.GetVipLevel() > 0)
|
||||
{
|
||||
TextureHelper.SaveImageToAlbum(LevelData[index].Name, FolderNames.AlbumName, CtrlCloseUI);
|
||||
}
|
||||
else
|
||||
{
|
||||
GameHelper.ShowVideoAd("DownloadImage", isSuccess =>
|
||||
{
|
||||
if (isSuccess)
|
||||
{
|
||||
TextureHelper.SaveImageToAlbum(LevelData[index].Name, FolderNames.AlbumName, CtrlCloseUI);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
btn_down_coin.SetClick(() =>
|
||||
{
|
||||
if (GameHelper.Get101() >= downloadCoinNum)
|
||||
{
|
||||
DataMgr.Coin.Value -= downloadCoinNum;
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.Update101);
|
||||
TextureHelper.SaveImageToAlbum(LevelData[index].Name, FolderNames.AlbumName, CtrlCloseUI);
|
||||
TrackKit.SendEvent(ADEventTrack.Coinsbuy, ADEventTrack.Property.download);
|
||||
}
|
||||
else
|
||||
{
|
||||
GameHelper.ShowTips("no_enough_gold", true);
|
||||
|
||||
uiCtrlDispatcher.Dispatch(UICtrlMsg.BuygoldUI_Open);
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
Levelunlock levelunlock_ = DataMgr.LevelUnlockListNew.Value.FirstOrDefault(x => x.level_ == index + 1);
|
||||
string file_name = "";
|
||||
if (levelunlock_ != null)
|
||||
{
|
||||
if (levelunlock_.type == 0)
|
||||
{
|
||||
if (levelunlock_.config_index >= ConfigSystem.GetConfig<FreeImageLibrary>().Count) levelunlock_.config_index = ConfigSystem.GetConfig<FreeImageLibrary>().Count - 1;
|
||||
FreeImageLibrary _leveldata = ConfigSystem.GetConfig<FreeImageLibrary>()[levelunlock_.config_index];
|
||||
TextureHelper.SetImgLoader(item.com_loader.GetChild("loader") as GLoader, _leveldata.Name, null, "LevelAlbums/", FolderNames.AlbumName);
|
||||
file_name = _leveldata.Name;
|
||||
}
|
||||
else if (levelunlock_.type == 1)
|
||||
{
|
||||
if (levelunlock_.config_index >= ConfigSystem.GetConfig<ADImageLibrary>().Count) levelunlock_.config_index = ConfigSystem.GetConfig<ADImageLibrary>().Count - 1;
|
||||
ADImageLibrary _leveldata = ConfigSystem.GetConfig<ADImageLibrary>()[levelunlock_.config_index];
|
||||
TextureHelper.SetImgLoader(item.com_loader.GetChild("loader") as GLoader, _leveldata.Name, null, "LevelAlbums/", FolderNames.AlbumName);
|
||||
file_name = _leveldata.Name;
|
||||
}
|
||||
else if (levelunlock_.type == 2)
|
||||
{
|
||||
if (levelunlock_.config_index >= ConfigSystem.GetConfig<SpecialImageLibrary>().Count) levelunlock_.config_index = ConfigSystem.GetConfig<SpecialImageLibrary>().Count - 1;
|
||||
SpecialImageLibrary _leveldata = ConfigSystem.GetConfig<SpecialImageLibrary>()[levelunlock_.config_index];
|
||||
TextureHelper.SetImgLoader(item.com_loader.GetChild("loader") as GLoader, _leveldata.Name, null, "LevelAlbums/", FolderNames.AlbumName);
|
||||
file_name = _leveldata.Name;
|
||||
}
|
||||
else if (levelunlock_.type == 3)
|
||||
{
|
||||
if (levelunlock_.config_index >= ConfigSystem.GetConfig<VIPImageLibrary>().Count) levelunlock_.config_index = ConfigSystem.GetConfig<VIPImageLibrary>().Count - 1;
|
||||
VIPImageLibrary _leveldata = ConfigSystem.GetConfig<VIPImageLibrary>()[levelunlock_.config_index];
|
||||
TextureHelper.SetImgLoader(item.com_loader.GetChild("loader") as GLoader, _leveldata.Name, null, "LevelAlbums/", FolderNames.AlbumName);
|
||||
file_name = _leveldata.Name;
|
||||
}
|
||||
item.btn_download.SetClick(() =>
|
||||
{
|
||||
|
||||
if (GameHelper.GetVipLevel() > 0)
|
||||
{
|
||||
TextureHelper.SaveImageToAlbum(file_name, FolderNames.AlbumName, CtrlCloseUI);
|
||||
}
|
||||
else
|
||||
{
|
||||
GameHelper.ShowVideoAd("DownloadImage", isSuccess =>
|
||||
{
|
||||
if (isSuccess)
|
||||
{
|
||||
TextureHelper.SaveImageToAlbum(file_name, FolderNames.AlbumName, CtrlCloseUI);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
btn_down_coin.SetClick(() =>
|
||||
{
|
||||
if (GameHelper.Get101() >= downloadCoinNum)
|
||||
{
|
||||
DataMgr.Coin.Value -= downloadCoinNum;
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.Update101);
|
||||
TextureHelper.SaveImageToAlbum(file_name, FolderNames.AlbumName, CtrlCloseUI);
|
||||
TrackKit.SendEvent(ADEventTrack.Coinsbuy, ADEventTrack.Property.download);
|
||||
}
|
||||
else
|
||||
{
|
||||
GameHelper.ShowTips("no_enough_gold", true);
|
||||
|
||||
uiCtrlDispatcher.Dispatch(UICtrlMsg.BuygoldUI_Open);
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
TextureHelper.SetImgLoader(item.com_loader.GetChild("loader") as GLoader, LevelData[index].Name, null, "LevelAlbums/", FolderNames.AlbumName);
|
||||
item.btn_download.SetClick(() =>
|
||||
{
|
||||
|
||||
if (GameHelper.GetVipLevel() > 0)
|
||||
{
|
||||
TextureHelper.SaveImageToAlbum(LevelData[index].Name, FolderNames.AlbumName, CtrlCloseUI);
|
||||
}
|
||||
else
|
||||
{
|
||||
GameHelper.ShowVideoAd("DownloadImage", isSuccess =>
|
||||
{
|
||||
if (isSuccess)
|
||||
{
|
||||
TextureHelper.SaveImageToAlbum(LevelData[index].Name, FolderNames.AlbumName, CtrlCloseUI);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
btn_down_coin.SetClick(() =>
|
||||
{
|
||||
if (GameHelper.Get101() >= downloadCoinNum)
|
||||
{
|
||||
DataMgr.Coin.Value -= downloadCoinNum;
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.Update101);
|
||||
TextureHelper.SaveImageToAlbum(LevelData[index].Name, FolderNames.AlbumName, CtrlCloseUI);
|
||||
TrackKit.SendEvent(ADEventTrack.Coinsbuy, ADEventTrack.Property.download);
|
||||
}
|
||||
else
|
||||
{
|
||||
GameHelper.ShowTips("no_enough_gold", true);
|
||||
|
||||
uiCtrlDispatcher.Dispatch(UICtrlMsg.BuygoldUI_Open);
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// if (LevelData[index].LeveType == 0)
|
||||
// {
|
||||
// TextureHelper.SetImgLoader(item.com_loader.GetChild("loader") as GLoader, LevelData[index].Name, null, "LevelAlbums/");
|
||||
// item.type.selectedIndex = 0;
|
||||
// }
|
||||
// else if (LevelData[index].LeveType == 1) //特殊关
|
||||
// {
|
||||
// if (DataMgr.LevelUnlockList.Value.Contains(index))
|
||||
// {
|
||||
// TextureHelper.SetImgLoader(item.com_loader.GetChild("loader") as GLoader, LevelData[index].Name, null, "LevelAlbums/");
|
||||
// item.type.selectedIndex = 0;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// item.type.selectedIndex = 1;
|
||||
// item.btn_pay.title = LevelData[index].PassCoins.ToString();
|
||||
// TextureHelper.SetImgLoader(item.com_loader.GetChild("loader") as GLoader, LevelData[index].Name, (s) =>
|
||||
// {
|
||||
// TextureHelper.SetImageBlur(item.com_loader.GetChild("loader") as GLoader);
|
||||
// }, "LevelAlbums/");
|
||||
// item.btn_pay.SetClick(() =>
|
||||
// {
|
||||
// if (DataMgr.Coin.Value >= LevelData[index].PassCoins)
|
||||
// {
|
||||
// new_index = index;
|
||||
// DataMgr.Coin.Value -= LevelData[index].PassCoins;
|
||||
// GameDispatcher.Instance.Dispatch(GameMsg.Gold_refresh);
|
||||
// DataMgr.LevelUnlockList.Value.Add(index);
|
||||
// GameHelper.ShowTips("Unlocked!");
|
||||
// DataMgr.LevelUnlockList.Save();
|
||||
// GameDispatcher.Instance.Dispatch(GameMsg.UnlockLevelsuccess);
|
||||
// CtrlCloseUI();
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// GameHelper.ShowTips("Not enough golds");
|
||||
// }
|
||||
// });
|
||||
// item.btn_watch.SetClick(() =>
|
||||
// {
|
||||
// if (GameHelper.GetVipPrivilege(Subscription.SLVLevel.As<int>()))
|
||||
// {
|
||||
// new_index = index;
|
||||
// DataMgr.LevelUnlockList.Value.Add(index);
|
||||
// GameHelper.ShowTips("Unlocked!");
|
||||
// DataMgr.LevelUnlockList.Save();
|
||||
// GameDispatcher.Instance.Dispatch(GameMsg.UnlockLevelsuccess);
|
||||
// CtrlCloseUI();
|
||||
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// GameHelper.ShowVideoAd("UnlockSpecialLevel", isSuccess =>
|
||||
// {
|
||||
// if (isSuccess)
|
||||
// {
|
||||
// new_index = index;
|
||||
// DataMgr.LevelUnlockList.Value.Add(index);
|
||||
// GameHelper.ShowTips("Unlocked!");
|
||||
// DataMgr.LevelUnlockList.Save();
|
||||
// GameDispatcher.Instance.Dispatch(GameMsg.UnlockLevelsuccess);
|
||||
// CtrlCloseUI();
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
|
||||
// });
|
||||
// }
|
||||
|
||||
|
||||
// }
|
||||
// else if (LevelData[index].LeveType == 2)//vip关
|
||||
// {
|
||||
// if (DataMgr.LevelUnlockList.Value.Contains(index))
|
||||
// {
|
||||
// TextureHelper.SetImgLoader(item.com_loader.GetChild("loader") as GLoader, LevelData[index].Name, null, "LevelAlbums/");
|
||||
// item.type.selectedIndex = 0;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// item.type.selectedIndex = 2;
|
||||
// item.btn_pay.title = LevelData[index].PassCoins.ToString();
|
||||
// TextureHelper.SetImgLoader(item.com_loader.GetChild("loader") as GLoader, LevelData[index].Name, (s) =>
|
||||
// {
|
||||
// TextureHelper.SetImageBlur(item.com_loader.GetChild("loader") as GLoader);
|
||||
// }, "LevelAlbums/");
|
||||
// item.btn_pay.SetClick(() =>
|
||||
// {
|
||||
// if (DataMgr.Coin.Value >= LevelData[index].PassCoins)
|
||||
// {
|
||||
// new_index = index;
|
||||
// DataMgr.Coin.Value -= LevelData[index].PassCoins;
|
||||
// GameDispatcher.Instance.Dispatch(GameMsg.Gold_refresh);
|
||||
// DataMgr.LevelUnlockList.Value.Add(index);
|
||||
// GameHelper.ShowTips("Unlocked!");
|
||||
// DataMgr.LevelUnlockList.Save();
|
||||
// GameDispatcher.Instance.Dispatch(GameMsg.UnlockLevelsuccess);
|
||||
// CtrlCloseUI();
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// GameHelper.ShowTips("Not enough golds");
|
||||
// }
|
||||
// });
|
||||
// item.btn_vip.SetClick(() =>
|
||||
// {
|
||||
// if (GameHelper.GetVipPrivilege(Subscription.VipLevel.As<int>()))
|
||||
// {
|
||||
// new_index = index;
|
||||
// DataMgr.LevelUnlockList.Value.Add(index);
|
||||
// GameHelper.ShowTips("Unlocked!");
|
||||
// DataMgr.LevelUnlockList.Save();
|
||||
// GameDispatcher.Instance.Dispatch(GameMsg.UnlockLevelsuccess);
|
||||
// CtrlCloseUI();
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// uiCtrlDispatcher.Dispatch(UICtrlMsg.VipClubViewUI_Open, 2);
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
|
||||
|
||||
|
||||
// }
|
||||
|
||||
// if (item.type.selectedIndex == 0)
|
||||
// {
|
||||
// if (GameHelper.GetVipPrivilege(Subscription.FreeDownImage.As<int>()))
|
||||
// {
|
||||
// (item.btn_download as FGUI.LG_Common.btn_claim).have_vip.selectedIndex = 1;
|
||||
// item.is_vip.selectedIndex = 1;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// item.is_vip.selectedIndex = 0;
|
||||
// }
|
||||
// }
|
||||
// else if (item.type.selectedIndex == 1)
|
||||
// {
|
||||
// if (GameHelper.GetVipPrivilege(Subscription.SLVLevel.As<int>()))
|
||||
// {
|
||||
// item.is_vip.selectedIndex = 1;
|
||||
// }
|
||||
// else item.is_vip.selectedIndex = 0;
|
||||
|
||||
// }
|
||||
// else if (item.type.selectedIndex == 2)
|
||||
// {
|
||||
// if (GameHelper.GetVipPrivilege(Subscription.VipLevel.As<int>()))
|
||||
// {
|
||||
// item.is_vip.selectedIndex = 1;
|
||||
// }
|
||||
// else item.is_vip.selectedIndex = 0;
|
||||
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
using FGUI.ZM_Common_01;
|
||||
using UnityEngine;
|
||||
using FairyGUI;
|
||||
using System.Collections.Generic;
|
||||
using FGUI.LG_albums;
|
||||
using FGUI.LG_Common;
|
||||
using SGModule.DataStorage;
|
||||
using DG.Tweening;
|
||||
using SGModule.Common.Extensions;
|
||||
using System.Linq;
|
||||
using SGModule.NetKit;
|
||||
namespace BallKingdomCrush
|
||||
{
|
||||
public class AlbumDetailUI : BaseUI
|
||||
{
|
||||
private AlbumDetailUICtrl ctrl;
|
||||
private AlbumDetailModel model;
|
||||
private FGUI.LG_albums.com_albumsDetail ui;
|
||||
|
||||
public AlbumDetailUI(AlbumDetailUICtrl ctrl) : base(ctrl)
|
||||
{
|
||||
uiName = UIConst.AlbumDetailUI;
|
||||
this.ctrl = ctrl;
|
||||
}
|
||||
|
||||
protected override void SetUIInfo(UIInfo uiInfo)
|
||||
{
|
||||
uiInfo.packageName = "LG_albums";
|
||||
uiInfo.assetName = "com_albumsDetail";
|
||||
uiInfo.layerType = UILayerType.Popup;
|
||||
uiInfo.isNeedOpenAnim = false;
|
||||
uiInfo.isNeedCloseAnim = false;
|
||||
uiInfo.isNeedUIMask = true;
|
||||
}
|
||||
|
||||
#region 生命周期
|
||||
protected override void OnInit()
|
||||
{
|
||||
//model = ModuleManager.Instance.GetModel(ModelConst.AlbumDetailModel) as AlbumDetailModel;
|
||||
}
|
||||
|
||||
protected override void OnClose()
|
||||
{
|
||||
if (loader != null && !loader.isDisposed && loader.texture != null)
|
||||
{
|
||||
loader.texture.Dispose();
|
||||
loader.texture = null;
|
||||
}
|
||||
loader = null;
|
||||
|
||||
if (new_index != -1)
|
||||
{
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.UnlockAlbums, index);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnBind()
|
||||
{
|
||||
ui = baseUI as FGUI.LG_albums.com_albumsDetail;
|
||||
}
|
||||
private List<LevelUnlock> LevelData;
|
||||
private int new_index = -1;
|
||||
private int index;
|
||||
|
||||
private GLoader loader = new GLoader();
|
||||
protected override void OnOpenBefore(object args)
|
||||
{
|
||||
index = (int)args;
|
||||
Debug.Log(index);
|
||||
ui.btn_close.SetClick(() =>
|
||||
{
|
||||
CtrlCloseUI();
|
||||
});
|
||||
LevelData = ConfigSystem.GetLevelUnlockConfig();
|
||||
// ui.list_.SetVirtual();
|
||||
// ui.list_.itemRenderer = RendererList;
|
||||
// ui.list_.numItems = GameHelper.GetLevel() - 1;
|
||||
// ui.list_.ScrollToView(new_index);
|
||||
|
||||
RendererList();
|
||||
}
|
||||
|
||||
protected override void OnOpen(object args)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnHide()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnDisplay(object args)
|
||||
{
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 消息
|
||||
protected override void AddListener()
|
||||
{
|
||||
GameDispatcher.Instance.AddListener(GameMsg.BuyVip, refrsh);
|
||||
}
|
||||
protected override void RemoveListener()
|
||||
{
|
||||
GameDispatcher.Instance.RemoveListener(GameMsg.BuyVip, refrsh);
|
||||
}
|
||||
#endregion
|
||||
|
||||
//初始化页面逻辑
|
||||
private void refrsh(object a = null)
|
||||
{
|
||||
DOVirtual.DelayedCall(0.5f, () =>
|
||||
{
|
||||
// ui.list_.numItems = GameHelper.GetLevel() - 1;
|
||||
RendererList();
|
||||
});
|
||||
|
||||
}
|
||||
// void RendererList(int index, GObject obj)
|
||||
void RendererList()
|
||||
{
|
||||
|
||||
item_albumsDetails item = (item_albumsDetails)ui.com_item;
|
||||
|
||||
loader = item.com_loader.GetChild("loader") as GLoader;
|
||||
|
||||
// if (GameHelper.GetVipPrivilege(Subscription.VipLevel.As<int>()))
|
||||
// {
|
||||
// (item.btn_vip as btn_claim_2).have_vip.selectedIndex = 1;
|
||||
|
||||
// }
|
||||
// if (GameHelper.GetVipPrivilege(Subscription.SLVLevel.As<int>()))
|
||||
// {
|
||||
// (item.btn_watch as btn_claim_1).have_vip.selectedIndex = 1;
|
||||
|
||||
// }
|
||||
|
||||
|
||||
var downloadCoinNum = ConfigSystem.GetCommonConf().CoinsDownload;
|
||||
var btn_down_coin = (FGUI.LG_Common.btn_unlock)item.btn_download_coin;
|
||||
btn_down_coin.title = downloadCoinNum.As<string>();
|
||||
btn_down_coin.down_load.selectedIndex = GameHelper.GetVipLevel() >= 1 ? 0 : 1;
|
||||
|
||||
|
||||
if (GameHelper.GetVipLevel() > 0)
|
||||
{
|
||||
(item.btn_download as FGUI.LG_Common.btn_claim).have_vip.selectedIndex = 1;
|
||||
item.is_vip.selectedIndex = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
item.is_vip.selectedIndex = 0;
|
||||
}
|
||||
if (index < GameHelper.GetCommonModel().MultiModal - 1)
|
||||
{
|
||||
TextureHelper.SetImgLoader(item.com_loader.GetChild("loader") as GLoader, LevelData[index].Name, null, "LevelAlbums/", FolderNames.AlbumName);
|
||||
item.btn_download.SetClick(() =>
|
||||
{
|
||||
|
||||
if (GameHelper.GetVipLevel() > 0)
|
||||
{
|
||||
TextureHelper.SaveImageToAlbum(LevelData[index].Name, FolderNames.AlbumName, CtrlCloseUI);
|
||||
}
|
||||
else
|
||||
{
|
||||
GameHelper.ShowVideoAd("DownloadImage", isSuccess =>
|
||||
{
|
||||
if (isSuccess)
|
||||
{
|
||||
TextureHelper.SaveImageToAlbum(LevelData[index].Name, FolderNames.AlbumName, CtrlCloseUI);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
btn_down_coin.SetClick(() =>
|
||||
{
|
||||
if (GameHelper.Get101() >= downloadCoinNum)
|
||||
{
|
||||
DataMgr.Coin.Value -= downloadCoinNum;
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.Update101);
|
||||
TextureHelper.SaveImageToAlbum(LevelData[index].Name, FolderNames.AlbumName, CtrlCloseUI);
|
||||
TrackKit.SendEvent(ADEventTrack.Coinsbuy, ADEventTrack.Property.download);
|
||||
}
|
||||
else
|
||||
{
|
||||
GameHelper.ShowTips("no_enough_gold", true);
|
||||
|
||||
uiCtrlDispatcher.Dispatch(UICtrlMsg.BuygoldUI_Open);
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
Levelunlock levelunlock_ = DataMgr.LevelUnlockListNew.Value.FirstOrDefault(x => x.level_ == index + 1);
|
||||
string file_name = "";
|
||||
if (levelunlock_ != null)
|
||||
{
|
||||
if (levelunlock_.type == 0)
|
||||
{
|
||||
if (levelunlock_.config_index >= ConfigSystem.GetFreeImageConfig().Count) levelunlock_.config_index = ConfigSystem.GetFreeImageConfig().Count - 1;
|
||||
FreeImageLibrary _leveldata = ConfigSystem.GetFreeImageConfig()[levelunlock_.config_index];
|
||||
TextureHelper.SetImgLoader(item.com_loader.GetChild("loader") as GLoader, _leveldata.Name, null, "LevelAlbums/", FolderNames.AlbumName);
|
||||
file_name = _leveldata.Name;
|
||||
}
|
||||
else if (levelunlock_.type == 1)
|
||||
{
|
||||
if (levelunlock_.config_index >= ConfigSystem.GetADImageConfig().Count) levelunlock_.config_index = ConfigSystem.GetADImageConfig().Count - 1;
|
||||
ADImageLibrary _leveldata = ConfigSystem.GetADImageConfig()[levelunlock_.config_index];
|
||||
TextureHelper.SetImgLoader(item.com_loader.GetChild("loader") as GLoader, _leveldata.Name, null, "LevelAlbums/", FolderNames.AlbumName);
|
||||
file_name = _leveldata.Name;
|
||||
}
|
||||
else if (levelunlock_.type == 2)
|
||||
{
|
||||
if (levelunlock_.config_index >= ConfigSystem.GetSpecialImageConfig().Count) levelunlock_.config_index = ConfigSystem.GetSpecialImageConfig().Count - 1;
|
||||
SpecialImageLibrary _leveldata = ConfigSystem.GetSpecialImageConfig()[levelunlock_.config_index];
|
||||
TextureHelper.SetImgLoader(item.com_loader.GetChild("loader") as GLoader, _leveldata.Name, null, "LevelAlbums/", FolderNames.AlbumName);
|
||||
file_name = _leveldata.Name;
|
||||
}
|
||||
else if (levelunlock_.type == 3)
|
||||
{
|
||||
if (levelunlock_.config_index >= ConfigSystem.GetVIPImageConfig().Count) levelunlock_.config_index = ConfigSystem.GetVIPImageConfig().Count - 1;
|
||||
VIPImageLibrary _leveldata = ConfigSystem.GetVIPImageConfig()[levelunlock_.config_index];
|
||||
TextureHelper.SetImgLoader(item.com_loader.GetChild("loader") as GLoader, _leveldata.Name, null, "LevelAlbums/", FolderNames.AlbumName);
|
||||
file_name = _leveldata.Name;
|
||||
}
|
||||
item.btn_download.SetClick(() =>
|
||||
{
|
||||
|
||||
if (GameHelper.GetVipLevel() > 0)
|
||||
{
|
||||
TextureHelper.SaveImageToAlbum(file_name, FolderNames.AlbumName, CtrlCloseUI);
|
||||
}
|
||||
else
|
||||
{
|
||||
GameHelper.ShowVideoAd("DownloadImage", isSuccess =>
|
||||
{
|
||||
if (isSuccess)
|
||||
{
|
||||
TextureHelper.SaveImageToAlbum(file_name, FolderNames.AlbumName, CtrlCloseUI);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
btn_down_coin.SetClick(() =>
|
||||
{
|
||||
if (GameHelper.Get101() >= downloadCoinNum)
|
||||
{
|
||||
DataMgr.Coin.Value -= downloadCoinNum;
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.Update101);
|
||||
TextureHelper.SaveImageToAlbum(file_name, FolderNames.AlbumName, CtrlCloseUI);
|
||||
TrackKit.SendEvent(ADEventTrack.Coinsbuy, ADEventTrack.Property.download);
|
||||
}
|
||||
else
|
||||
{
|
||||
GameHelper.ShowTips("no_enough_gold", true);
|
||||
|
||||
uiCtrlDispatcher.Dispatch(UICtrlMsg.BuygoldUI_Open);
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
TextureHelper.SetImgLoader(item.com_loader.GetChild("loader") as GLoader, LevelData[index].Name, null, "LevelAlbums/", FolderNames.AlbumName);
|
||||
item.btn_download.SetClick(() =>
|
||||
{
|
||||
|
||||
if (GameHelper.GetVipLevel() > 0)
|
||||
{
|
||||
TextureHelper.SaveImageToAlbum(LevelData[index].Name, FolderNames.AlbumName, CtrlCloseUI);
|
||||
}
|
||||
else
|
||||
{
|
||||
GameHelper.ShowVideoAd("DownloadImage", isSuccess =>
|
||||
{
|
||||
if (isSuccess)
|
||||
{
|
||||
TextureHelper.SaveImageToAlbum(LevelData[index].Name, FolderNames.AlbumName, CtrlCloseUI);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
btn_down_coin.SetClick(() =>
|
||||
{
|
||||
if (GameHelper.Get101() >= downloadCoinNum)
|
||||
{
|
||||
DataMgr.Coin.Value -= downloadCoinNum;
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.Update101);
|
||||
TextureHelper.SaveImageToAlbum(LevelData[index].Name, FolderNames.AlbumName, CtrlCloseUI);
|
||||
TrackKit.SendEvent(ADEventTrack.Coinsbuy, ADEventTrack.Property.download);
|
||||
}
|
||||
else
|
||||
{
|
||||
GameHelper.ShowTips("no_enough_gold", true);
|
||||
|
||||
uiCtrlDispatcher.Dispatch(UICtrlMsg.BuygoldUI_Open);
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// if (LevelData[index].LeveType == 0)
|
||||
// {
|
||||
// TextureHelper.SetImgLoader(item.com_loader.GetChild("loader") as GLoader, LevelData[index].Name, null, "LevelAlbums/");
|
||||
// item.type.selectedIndex = 0;
|
||||
// }
|
||||
// else if (LevelData[index].LeveType == 1) //特殊关
|
||||
// {
|
||||
// if (DataMgr.LevelUnlockList.Value.Contains(index))
|
||||
// {
|
||||
// TextureHelper.SetImgLoader(item.com_loader.GetChild("loader") as GLoader, LevelData[index].Name, null, "LevelAlbums/");
|
||||
// item.type.selectedIndex = 0;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// item.type.selectedIndex = 1;
|
||||
// item.btn_pay.title = LevelData[index].PassCoins.ToString();
|
||||
// TextureHelper.SetImgLoader(item.com_loader.GetChild("loader") as GLoader, LevelData[index].Name, (s) =>
|
||||
// {
|
||||
// TextureHelper.SetImageBlur(item.com_loader.GetChild("loader") as GLoader);
|
||||
// }, "LevelAlbums/");
|
||||
// item.btn_pay.SetClick(() =>
|
||||
// {
|
||||
// if (DataMgr.Coin.Value >= LevelData[index].PassCoins)
|
||||
// {
|
||||
// new_index = index;
|
||||
// DataMgr.Coin.Value -= LevelData[index].PassCoins;
|
||||
// GameDispatcher.Instance.Dispatch(GameMsg.Gold_refresh);
|
||||
// DataMgr.LevelUnlockList.Value.Add(index);
|
||||
// GameHelper.ShowTips("Unlocked!");
|
||||
// DataMgr.LevelUnlockList.Save();
|
||||
// GameDispatcher.Instance.Dispatch(GameMsg.UnlockLevelsuccess);
|
||||
// CtrlCloseUI();
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// GameHelper.ShowTips("Not enough golds");
|
||||
// }
|
||||
// });
|
||||
// item.btn_watch.SetClick(() =>
|
||||
// {
|
||||
// if (GameHelper.GetVipPrivilege(Subscription.SLVLevel.As<int>()))
|
||||
// {
|
||||
// new_index = index;
|
||||
// DataMgr.LevelUnlockList.Value.Add(index);
|
||||
// GameHelper.ShowTips("Unlocked!");
|
||||
// DataMgr.LevelUnlockList.Save();
|
||||
// GameDispatcher.Instance.Dispatch(GameMsg.UnlockLevelsuccess);
|
||||
// CtrlCloseUI();
|
||||
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// GameHelper.ShowVideoAd("UnlockSpecialLevel", isSuccess =>
|
||||
// {
|
||||
// if (isSuccess)
|
||||
// {
|
||||
// new_index = index;
|
||||
// DataMgr.LevelUnlockList.Value.Add(index);
|
||||
// GameHelper.ShowTips("Unlocked!");
|
||||
// DataMgr.LevelUnlockList.Save();
|
||||
// GameDispatcher.Instance.Dispatch(GameMsg.UnlockLevelsuccess);
|
||||
// CtrlCloseUI();
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
|
||||
// });
|
||||
// }
|
||||
|
||||
|
||||
// }
|
||||
// else if (LevelData[index].LeveType == 2)//vip关
|
||||
// {
|
||||
// if (DataMgr.LevelUnlockList.Value.Contains(index))
|
||||
// {
|
||||
// TextureHelper.SetImgLoader(item.com_loader.GetChild("loader") as GLoader, LevelData[index].Name, null, "LevelAlbums/");
|
||||
// item.type.selectedIndex = 0;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// item.type.selectedIndex = 2;
|
||||
// item.btn_pay.title = LevelData[index].PassCoins.ToString();
|
||||
// TextureHelper.SetImgLoader(item.com_loader.GetChild("loader") as GLoader, LevelData[index].Name, (s) =>
|
||||
// {
|
||||
// TextureHelper.SetImageBlur(item.com_loader.GetChild("loader") as GLoader);
|
||||
// }, "LevelAlbums/");
|
||||
// item.btn_pay.SetClick(() =>
|
||||
// {
|
||||
// if (DataMgr.Coin.Value >= LevelData[index].PassCoins)
|
||||
// {
|
||||
// new_index = index;
|
||||
// DataMgr.Coin.Value -= LevelData[index].PassCoins;
|
||||
// GameDispatcher.Instance.Dispatch(GameMsg.Gold_refresh);
|
||||
// DataMgr.LevelUnlockList.Value.Add(index);
|
||||
// GameHelper.ShowTips("Unlocked!");
|
||||
// DataMgr.LevelUnlockList.Save();
|
||||
// GameDispatcher.Instance.Dispatch(GameMsg.UnlockLevelsuccess);
|
||||
// CtrlCloseUI();
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// GameHelper.ShowTips("Not enough golds");
|
||||
// }
|
||||
// });
|
||||
// item.btn_vip.SetClick(() =>
|
||||
// {
|
||||
// if (GameHelper.GetVipPrivilege(Subscription.VipLevel.As<int>()))
|
||||
// {
|
||||
// new_index = index;
|
||||
// DataMgr.LevelUnlockList.Value.Add(index);
|
||||
// GameHelper.ShowTips("Unlocked!");
|
||||
// DataMgr.LevelUnlockList.Save();
|
||||
// GameDispatcher.Instance.Dispatch(GameMsg.UnlockLevelsuccess);
|
||||
// CtrlCloseUI();
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// uiCtrlDispatcher.Dispatch(UICtrlMsg.VipClubViewUI_Open, 2);
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
|
||||
|
||||
|
||||
// }
|
||||
|
||||
// if (item.type.selectedIndex == 0)
|
||||
// {
|
||||
// if (GameHelper.GetVipPrivilege(Subscription.FreeDownImage.As<int>()))
|
||||
// {
|
||||
// (item.btn_download as FGUI.LG_Common.btn_claim).have_vip.selectedIndex = 1;
|
||||
// item.is_vip.selectedIndex = 1;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// item.is_vip.selectedIndex = 0;
|
||||
// }
|
||||
// }
|
||||
// else if (item.type.selectedIndex == 1)
|
||||
// {
|
||||
// if (GameHelper.GetVipPrivilege(Subscription.SLVLevel.As<int>()))
|
||||
// {
|
||||
// item.is_vip.selectedIndex = 1;
|
||||
// }
|
||||
// else item.is_vip.selectedIndex = 0;
|
||||
|
||||
// }
|
||||
// else if (item.type.selectedIndex == 2)
|
||||
// {
|
||||
// if (GameHelper.GetVipPrivilege(Subscription.VipLevel.As<int>()))
|
||||
// {
|
||||
// item.is_vip.selectedIndex = 1;
|
||||
// }
|
||||
// else item.is_vip.selectedIndex = 0;
|
||||
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,431 +1,431 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using DG.Tweening;
|
||||
using FairyGUI;
|
||||
using FGUI.LG_albums;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BallKingdomCrush
|
||||
{
|
||||
public class AlubumUI : BaseUI
|
||||
{
|
||||
private AlubumUICtrl ctrl;
|
||||
private AlubumModel model;
|
||||
private com_albums ui;
|
||||
private long[] UpDatatime;
|
||||
|
||||
public AlubumUI(AlubumUICtrl ctrl) : base(ctrl)
|
||||
{
|
||||
uiName = UIConst.AlubumUI;
|
||||
this.ctrl = ctrl;
|
||||
}
|
||||
|
||||
protected override void SetUIInfo(UIInfo uiInfo)
|
||||
{
|
||||
uiInfo.packageName = "LG_albums";
|
||||
uiInfo.assetName = "com_albums";
|
||||
uiInfo.layerType = UILayerType.Popup;
|
||||
uiInfo.isNeedOpenAnim = false;
|
||||
uiInfo.isNeedCloseAnim = false;
|
||||
uiInfo.isNeedUIMask = true;
|
||||
}
|
||||
|
||||
//初始化页面逻辑
|
||||
private void InitView(object a = null)
|
||||
{
|
||||
UpDatatime = new long[LevelData.Count];
|
||||
ImageName = new string[LevelData.Count];
|
||||
ui.list_albums.itemRenderer = RendererList;
|
||||
ui.list_albums.numItems = LevelData.Count;
|
||||
|
||||
InitScroll();
|
||||
}
|
||||
|
||||
private void SetItemData(object obj = null)
|
||||
{
|
||||
UpDatatime[(int)obj] = 0;
|
||||
ui.list_albums.RefreshVirtualList();
|
||||
}
|
||||
|
||||
#region 生命周期
|
||||
|
||||
protected override void OnInit()
|
||||
{
|
||||
GLoaderPool.Instance.Init(null, 24, 312, 310);
|
||||
}
|
||||
|
||||
protected override void OnClose()
|
||||
{
|
||||
foreach (var t in loader_list)
|
||||
if (t != null && !t.isDisposed && t.texture != null)
|
||||
{
|
||||
t.texture.Dispose();
|
||||
t.texture = null;
|
||||
}
|
||||
|
||||
// 1. 解除 UI 对 Loader 的引用
|
||||
for (var i = 0; i < ui.list_albums.numChildren; i++)
|
||||
{
|
||||
var item = ui.list_albums.GetChildAt(i) as item_albums;
|
||||
if (item != null && item.com_loader.loader != null) item.com_loader.loader = null; // 清掉 GLoader 引用
|
||||
}
|
||||
|
||||
activeLoaders.Clear();
|
||||
_fileIsExist.Clear();
|
||||
|
||||
GLoaderPool.Instance.DisposeAll();
|
||||
|
||||
TextureHelper.ClearMaterialPool();
|
||||
|
||||
// 强制卸载未使用的资源
|
||||
// Resources.UnloadUnusedAssets();
|
||||
// MemoryManager.CleanMemoryMonitor();
|
||||
}
|
||||
|
||||
protected override void OnBind()
|
||||
{
|
||||
ui = baseUI as com_albums;
|
||||
}
|
||||
|
||||
private List<LevelUnlock> LevelData;
|
||||
|
||||
private readonly List<GLoader> loader_list = new();
|
||||
|
||||
protected override void OnOpenBefore(object args)
|
||||
{
|
||||
_throttle = new Throttle(1f);
|
||||
|
||||
LevelData = ConfigSystem.GetConfig<LevelUnlock>();
|
||||
ui.list_albums.SetVirtual();
|
||||
ui.btn_close1.SetClick(() => { CtrlCloseUI(); });
|
||||
InitView();
|
||||
}
|
||||
|
||||
|
||||
private const int MaxVisibleCount = 18; // 一屏显示18个
|
||||
private const int PreloadCount = 3; // 上下各预加载一屏
|
||||
private readonly Dictionary<int, GLoader> activeLoaders = new();
|
||||
private readonly Dictionary<int, bool> _fileIsExist = new();
|
||||
|
||||
private Throttle _throttle;
|
||||
|
||||
private void InitScroll()
|
||||
{
|
||||
// ui.list_albums.scrollPane.onScroll.Add(OnScrollUpdate);
|
||||
ui.list_albums.scrollPane.onScrollEnd.Add(OnScrollEndCB); // 保留结束时的整理
|
||||
|
||||
OnScrollEnd();
|
||||
}
|
||||
|
||||
private void OnScrollUpdate()
|
||||
{
|
||||
_throttle.Execute(UpdateVisibleAndPreload);
|
||||
}
|
||||
|
||||
private void OnScrollEndCB()
|
||||
{
|
||||
// UpdateVisibleAndPreload();
|
||||
|
||||
OnScrollEnd();
|
||||
|
||||
// Debug.Log("更新一次");
|
||||
}
|
||||
|
||||
private void UpdateVisibleAndPreload()
|
||||
{
|
||||
// Debug.Log("[UpdateVisibleAndPreload]--------111111--------- ");
|
||||
// if (LevelData == null || LevelData.Count == 0) return;
|
||||
|
||||
// var firstVisibleIndex = ui.list_albums.GetFirstChildInView();
|
||||
// var lastVisibleIndex = Mathf.Min(firstVisibleIndex + MaxVisibleCount - 1, ui.list_albums.numItems - 1);
|
||||
|
||||
// var startIndex = Mathf.Max(0, firstVisibleIndex - PreloadCount);
|
||||
// var endIndex = Mathf.Min(ui.list_albums.numItems - 1, lastVisibleIndex + PreloadCount);
|
||||
|
||||
// // 回收超出范围 loader
|
||||
// var keysToRemove = new List<int>();
|
||||
// foreach (var kv in activeLoaders)
|
||||
// {
|
||||
// var idx = kv.Key;
|
||||
// if (idx < startIndex || idx > endIndex)
|
||||
// {
|
||||
// GLoaderPool.Instance.ReturnLoader(kv.Value);
|
||||
// var oldItem = ui.list_albums.GetChildAt(idx) as item_albums;
|
||||
// if (oldItem != null) oldItem.com_loader.loader = null;
|
||||
// keysToRemove.Add(idx);
|
||||
// }
|
||||
// }
|
||||
|
||||
// foreach (var k in keysToRemove) activeLoaders.Remove(k);
|
||||
|
||||
|
||||
// // 分配 loader 并加载图片
|
||||
// for (var i = startIndex; i <= endIndex; i++)
|
||||
// {
|
||||
// if (activeLoaders.ContainsKey(i)) continue;
|
||||
|
||||
// var item = ui.list_albums.GetChildAt(i) as item_albums;
|
||||
// if (item == null) continue;
|
||||
|
||||
// if (item.com_loader.loader != null && !item.com_loader.loader.isDisposed)
|
||||
// GLoaderPool.Instance.ReturnLoader(item.com_loader.loader);
|
||||
|
||||
// var loader = GLoaderPool.Instance.GetLoader();
|
||||
// item.com_loader.loader = loader;
|
||||
// item.com_loader.AddChild(loader);
|
||||
// loader.SetSize(item.com_loader.loader.width, item.com_loader.loader.height);
|
||||
|
||||
// _fileIsExist.TryGetValue(i, out var value);
|
||||
// if (!value)
|
||||
// {
|
||||
// var localPath = Path.Combine(TextureHelper.getResPath(), LevelData[i].Name + ".jpg");
|
||||
|
||||
// if (File.Exists(localPath))
|
||||
// {
|
||||
// _fileIsExist[i] = true;
|
||||
// Debug.Log($"[SetImgLoader] 本地存在,直接加载 {LevelData[i].Name}");
|
||||
// CrazyAsyKit.StartCoroutine(TextureHelper.LoadTexture(LevelData[i].Name, loader, null,
|
||||
// "LevelAlbums/"));
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// _fileIsExist[i] = false;
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// CrazyAsyKit.StartCoroutine(TextureHelper.LoadTexture(LevelData[i].Name, loader, null,
|
||||
// "LevelAlbums/"));
|
||||
// }
|
||||
|
||||
// activeLoaders[i] = loader;
|
||||
// }
|
||||
// Debug.Log($"[ScrollUpdate] active loaders={activeLoaders.Count}, pool={GLoaderPool.Instance.GetPoolCount()}, inUse={GLoaderPool.Instance.GetInUseCount()}");
|
||||
}
|
||||
|
||||
private void OnScrollEnd()
|
||||
{
|
||||
for (int i = 0; i < UpDatatime.Length; i++)
|
||||
{
|
||||
UpDatatime[i] = 0;
|
||||
// ImageName[i] = "";
|
||||
}
|
||||
|
||||
// DOVirtual.DelayedCall(0.1f, () =>
|
||||
// {
|
||||
ui.list_albums.RefreshVirtualList();
|
||||
// });
|
||||
|
||||
// if (LevelData == null || LevelData.Count == 0) return;
|
||||
|
||||
// var firstVisibleIndex = ui.list_albums.GetFirstChildInView();
|
||||
// var lastVisibleIndex = Mathf.Min(firstVisibleIndex + MaxVisibleCount - 1, ui.list_albums.numItems - 1);
|
||||
|
||||
// var startIndex = Mathf.Max(0, firstVisibleIndex - PreloadCount);
|
||||
// var endIndex = Mathf.Min(ui.list_albums.numItems - 1, lastVisibleIndex + PreloadCount);
|
||||
|
||||
// // Debug.Log($"[ScrollEnd] start index={startIndex} end index={endIndex}");
|
||||
|
||||
|
||||
// var tasks = new List<(GLoader loader, string fileName, Action<NTexture> callback, string folder)>();
|
||||
// // 分配 loader 并加载图片
|
||||
// for (var i = startIndex; i <= endIndex; i++)
|
||||
// {
|
||||
// _fileIsExist.TryGetValue(i, out var value);
|
||||
|
||||
// if (value) continue;
|
||||
|
||||
// if (GameHelper.GetLevel() < i + 1) continue;
|
||||
|
||||
// var item = ui.list_albums.GetChildAt(i) as item_albums;
|
||||
// if (item == null) continue;
|
||||
// if (item.com_loader.loader != null && !item.com_loader.loader.isDisposed)
|
||||
// GLoaderPool.Instance.ReturnLoader(item.com_loader.loader);
|
||||
// var loader = GLoaderPool.Instance.GetLoader();
|
||||
// item.com_loader.loader = loader;
|
||||
// item.com_loader.AddChild(loader);
|
||||
// loader.SetSize(item.com_loader.loader.width, item.com_loader.loader.height);
|
||||
|
||||
// var idx = i;
|
||||
// tasks.Add((loader, LevelData[i].Name, NTexture =>
|
||||
// {
|
||||
// if (NTexture != null) _fileIsExist[idx] = true;
|
||||
// }, "LevelAlbums/"));
|
||||
|
||||
// activeLoaders[i] = loader;
|
||||
// }
|
||||
|
||||
// if (tasks.Count > 0) TextureHelper.SetImgLoaders(tasks);
|
||||
}
|
||||
|
||||
private string[] ImageName;
|
||||
|
||||
private void RendererList(int index, GObject obj)
|
||||
{
|
||||
// Debug.Log("Render list" );
|
||||
|
||||
// Debug.Log(JsonConvert.SerializeObject(LevelData[index]));
|
||||
|
||||
item_albums item = (item_albums)obj;
|
||||
item.text_num.text = (index + 1).ToString();
|
||||
if (index < GameHelper.GetCommonModel().MultiModal - 1)
|
||||
{
|
||||
item.type_.selectedIndex = 0;
|
||||
if (GameHelper.GetLevel() > index + 1)
|
||||
{
|
||||
item.SetClick(() => { uiCtrlDispatcher.Dispatch(UICtrlMsg.AlbumDetailUI_Open, index); });
|
||||
}
|
||||
else
|
||||
{
|
||||
item.SetClick(() => { GameHelper.ShowTips("lv_unlock", true); });
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Levelunlock levelunlock_ = DataMgr.LevelUnlockListNew.Value.FirstOrDefault(x => x.level_ == index + 1);
|
||||
if (levelunlock_ != null)
|
||||
{
|
||||
item.type_.selectedIndex = levelunlock_.type;
|
||||
}
|
||||
else item.type_.selectedIndex = 0;
|
||||
if (GameHelper.GetLevel() > index + 1)
|
||||
{
|
||||
item.SetClick(() => { uiCtrlDispatcher.Dispatch(UICtrlMsg.AlbumDetailUI_Open, index); });
|
||||
}
|
||||
else
|
||||
{
|
||||
item.SetClick(() => { GameHelper.ShowTips("lv_unlock", true); });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (GameHelper.GetNowTime() < UpDatatime[index] + 1) return;
|
||||
UpDatatime[index] = GameHelper.GetNowTime();
|
||||
// if (!activeLoaders.ContainsValue(item.com_loader.loader)) activeLoaders[index] = item.com_loader.loader;
|
||||
if (!loader_list.Contains(item.com_loader.GetChild("loader") as GLoader))
|
||||
loader_list.Add(item.com_loader.GetChild("loader") as GLoader);
|
||||
|
||||
|
||||
if (index < GameHelper.GetCommonModel().MultiModal - 1)
|
||||
{
|
||||
if (GameHelper.GetLevel() > index + 1)
|
||||
{
|
||||
item.isUnlock.selectedIndex = 1;
|
||||
if (item.com_loader.loader.texture == null ||
|
||||
item.com_loader.loader.texture.nativeTexture.name != LevelData[index].Name)
|
||||
{
|
||||
// item.isUnlock.selectedIndex = 0;
|
||||
// if (item.com_loader.loader.texture != null)
|
||||
// {
|
||||
// item.com_loader.loader.texture.Dispose(); // 释放 GPU 资源
|
||||
// item.com_loader.loader.texture = null; // 断开引用
|
||||
// }
|
||||
|
||||
TextureHelper.SetImgLoader(item.com_loader.GetChild("loader") as GLoader, LevelData[index].Name,
|
||||
(a) => { Debug.Log(item.com_loader.loader.texture.nativeTexture.name); }, "LevelAlbums/", FolderNames.AlbumName);
|
||||
|
||||
ImageName[index] = LevelData[index].Name;
|
||||
}
|
||||
|
||||
item.touchable = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
item.isUnlock.selectedIndex = 0;
|
||||
// item.touchable = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Levelunlock levelunlock_ = DataMgr.LevelUnlockListNew.Value.FirstOrDefault(x => x.level_ == index + 1);
|
||||
|
||||
if (GameHelper.GetLevel() > index + 1)
|
||||
{
|
||||
if (levelunlock_ != null)
|
||||
{
|
||||
item.isUnlock.selectedIndex = 1;
|
||||
|
||||
if (item.com_loader.loader.texture == null || item.com_loader.loader.texture.nativeTexture.name != ImageName[index])
|
||||
{
|
||||
|
||||
if (levelunlock_.type == 0)
|
||||
{
|
||||
if (levelunlock_.config_index >= ConfigSystem.GetConfig<FreeImageLibrary>().Count) levelunlock_.config_index = ConfigSystem.GetConfig<FreeImageLibrary>().Count - 1;
|
||||
FreeImageLibrary _leveldata = ConfigSystem.GetConfig<FreeImageLibrary>()[levelunlock_.config_index];
|
||||
TextureHelper.SetImgLoader(item.com_loader.GetChild("loader") as GLoader, _leveldata.Name, null, "LevelAlbums/", FolderNames.AlbumName);
|
||||
ImageName[index] = LevelData[index].Name;
|
||||
}
|
||||
else if (levelunlock_.type == 1)
|
||||
{
|
||||
if (levelunlock_.config_index >= ConfigSystem.GetConfig<ADImageLibrary>().Count) levelunlock_.config_index = ConfigSystem.GetConfig<ADImageLibrary>().Count - 1;
|
||||
ADImageLibrary _leveldata = ConfigSystem.GetConfig<ADImageLibrary>()[levelunlock_.config_index];
|
||||
TextureHelper.SetImgLoader(item.com_loader.GetChild("loader") as GLoader, _leveldata.Name, null, "LevelAlbums/", FolderNames.AlbumName);
|
||||
ImageName[index] = LevelData[index].Name;
|
||||
}
|
||||
else if (levelunlock_.type == 2)
|
||||
{
|
||||
if (levelunlock_.config_index >= ConfigSystem.GetConfig<SpecialImageLibrary>().Count) levelunlock_.config_index = ConfigSystem.GetConfig<SpecialImageLibrary>().Count - 1;
|
||||
SpecialImageLibrary _leveldata = ConfigSystem.GetConfig<SpecialImageLibrary>()[levelunlock_.config_index];
|
||||
TextureHelper.SetImgLoader(item.com_loader.GetChild("loader") as GLoader, _leveldata.Name, null, "LevelAlbums/", FolderNames.AlbumName);
|
||||
ImageName[index] = LevelData[index].Name;
|
||||
}
|
||||
else if (levelunlock_.type == 3)
|
||||
{
|
||||
if (levelunlock_.config_index >= ConfigSystem.GetConfig<VIPImageLibrary>().Count) levelunlock_.config_index = ConfigSystem.GetConfig<VIPImageLibrary>().Count - 1;
|
||||
VIPImageLibrary _leveldata = ConfigSystem.GetConfig<VIPImageLibrary>()[levelunlock_.config_index];
|
||||
TextureHelper.SetImgLoader(item.com_loader.GetChild("loader") as GLoader, _leveldata.Name, null, "LevelAlbums/", FolderNames.AlbumName);
|
||||
ImageName[index] = LevelData[index].Name;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
item.isUnlock.selectedIndex = 1;
|
||||
if (item.com_loader.loader.texture == null || item.com_loader.loader.texture.nativeTexture.name != LevelData[index].Name)
|
||||
{
|
||||
TextureHelper.SetImgLoader(item.com_loader.GetChild("loader") as GLoader, LevelData[index].Name, null, "LevelAlbums/", FolderNames.AlbumName);
|
||||
ImageName[index] = LevelData[index].Name;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// item.touchable = false;
|
||||
item.isUnlock.selectedIndex = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnOpen(object args)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnHide()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnDisplay(object args)
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 消息
|
||||
|
||||
protected override void AddListener()
|
||||
{
|
||||
GameDispatcher.Instance.AddListener(GameMsg.UnlockAlbums, SetItemData);
|
||||
}
|
||||
|
||||
protected override void RemoveListener()
|
||||
{
|
||||
GameDispatcher.Instance.RemoveListener(GameMsg.UnlockAlbums, SetItemData);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using DG.Tweening;
|
||||
using FairyGUI;
|
||||
using FGUI.LG_albums;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BallKingdomCrush
|
||||
{
|
||||
public class AlubumUI : BaseUI
|
||||
{
|
||||
private AlubumUICtrl ctrl;
|
||||
private AlubumModel model;
|
||||
private com_albums ui;
|
||||
private long[] UpDatatime;
|
||||
|
||||
public AlubumUI(AlubumUICtrl ctrl) : base(ctrl)
|
||||
{
|
||||
uiName = UIConst.AlubumUI;
|
||||
this.ctrl = ctrl;
|
||||
}
|
||||
|
||||
protected override void SetUIInfo(UIInfo uiInfo)
|
||||
{
|
||||
uiInfo.packageName = "LG_albums";
|
||||
uiInfo.assetName = "com_albums";
|
||||
uiInfo.layerType = UILayerType.Popup;
|
||||
uiInfo.isNeedOpenAnim = false;
|
||||
uiInfo.isNeedCloseAnim = false;
|
||||
uiInfo.isNeedUIMask = true;
|
||||
}
|
||||
|
||||
//初始化页面逻辑
|
||||
private void InitView(object a = null)
|
||||
{
|
||||
UpDatatime = new long[LevelData.Count];
|
||||
ImageName = new string[LevelData.Count];
|
||||
ui.list_albums.itemRenderer = RendererList;
|
||||
ui.list_albums.numItems = LevelData.Count;
|
||||
|
||||
InitScroll();
|
||||
}
|
||||
|
||||
private void SetItemData(object obj = null)
|
||||
{
|
||||
UpDatatime[(int)obj] = 0;
|
||||
ui.list_albums.RefreshVirtualList();
|
||||
}
|
||||
|
||||
#region 生命周期
|
||||
|
||||
protected override void OnInit()
|
||||
{
|
||||
GLoaderPool.Instance.Init(null, 24, 312, 310);
|
||||
}
|
||||
|
||||
protected override void OnClose()
|
||||
{
|
||||
foreach (var t in loader_list)
|
||||
if (t != null && !t.isDisposed && t.texture != null)
|
||||
{
|
||||
t.texture.Dispose();
|
||||
t.texture = null;
|
||||
}
|
||||
|
||||
// 1. 解除 UI 对 Loader 的引用
|
||||
for (var i = 0; i < ui.list_albums.numChildren; i++)
|
||||
{
|
||||
var item = ui.list_albums.GetChildAt(i) as item_albums;
|
||||
if (item != null && item.com_loader.loader != null) item.com_loader.loader = null; // 清掉 GLoader 引用
|
||||
}
|
||||
|
||||
activeLoaders.Clear();
|
||||
_fileIsExist.Clear();
|
||||
|
||||
GLoaderPool.Instance.DisposeAll();
|
||||
|
||||
TextureHelper.ClearMaterialPool();
|
||||
|
||||
// 强制卸载未使用的资源
|
||||
// Resources.UnloadUnusedAssets();
|
||||
// MemoryManager.CleanMemoryMonitor();
|
||||
}
|
||||
|
||||
protected override void OnBind()
|
||||
{
|
||||
ui = baseUI as com_albums;
|
||||
}
|
||||
|
||||
private List<LevelUnlock> LevelData;
|
||||
|
||||
private readonly List<GLoader> loader_list = new();
|
||||
|
||||
protected override void OnOpenBefore(object args)
|
||||
{
|
||||
_throttle = new Throttle(1f);
|
||||
|
||||
LevelData = ConfigSystem.GetLevelUnlockConfig();
|
||||
ui.list_albums.SetVirtual();
|
||||
ui.btn_close1.SetClick(() => { CtrlCloseUI(); });
|
||||
InitView();
|
||||
}
|
||||
|
||||
|
||||
private const int MaxVisibleCount = 18; // 一屏显示18个
|
||||
private const int PreloadCount = 3; // 上下各预加载一屏
|
||||
private readonly Dictionary<int, GLoader> activeLoaders = new();
|
||||
private readonly Dictionary<int, bool> _fileIsExist = new();
|
||||
|
||||
private Throttle _throttle;
|
||||
|
||||
private void InitScroll()
|
||||
{
|
||||
// ui.list_albums.scrollPane.onScroll.Add(OnScrollUpdate);
|
||||
ui.list_albums.scrollPane.onScrollEnd.Add(OnScrollEndCB); // 保留结束时的整理
|
||||
|
||||
OnScrollEnd();
|
||||
}
|
||||
|
||||
private void OnScrollUpdate()
|
||||
{
|
||||
_throttle.Execute(UpdateVisibleAndPreload);
|
||||
}
|
||||
|
||||
private void OnScrollEndCB()
|
||||
{
|
||||
// UpdateVisibleAndPreload();
|
||||
|
||||
OnScrollEnd();
|
||||
|
||||
// Debug.Log("更新一次");
|
||||
}
|
||||
|
||||
private void UpdateVisibleAndPreload()
|
||||
{
|
||||
// Debug.Log("[UpdateVisibleAndPreload]--------111111--------- ");
|
||||
// if (LevelData == null || LevelData.Count == 0) return;
|
||||
|
||||
// var firstVisibleIndex = ui.list_albums.GetFirstChildInView();
|
||||
// var lastVisibleIndex = Mathf.Min(firstVisibleIndex + MaxVisibleCount - 1, ui.list_albums.numItems - 1);
|
||||
|
||||
// var startIndex = Mathf.Max(0, firstVisibleIndex - PreloadCount);
|
||||
// var endIndex = Mathf.Min(ui.list_albums.numItems - 1, lastVisibleIndex + PreloadCount);
|
||||
|
||||
// // 回收超出范围 loader
|
||||
// var keysToRemove = new List<int>();
|
||||
// foreach (var kv in activeLoaders)
|
||||
// {
|
||||
// var idx = kv.Key;
|
||||
// if (idx < startIndex || idx > endIndex)
|
||||
// {
|
||||
// GLoaderPool.Instance.ReturnLoader(kv.Value);
|
||||
// var oldItem = ui.list_albums.GetChildAt(idx) as item_albums;
|
||||
// if (oldItem != null) oldItem.com_loader.loader = null;
|
||||
// keysToRemove.Add(idx);
|
||||
// }
|
||||
// }
|
||||
|
||||
// foreach (var k in keysToRemove) activeLoaders.Remove(k);
|
||||
|
||||
|
||||
// // 分配 loader 并加载图片
|
||||
// for (var i = startIndex; i <= endIndex; i++)
|
||||
// {
|
||||
// if (activeLoaders.ContainsKey(i)) continue;
|
||||
|
||||
// var item = ui.list_albums.GetChildAt(i) as item_albums;
|
||||
// if (item == null) continue;
|
||||
|
||||
// if (item.com_loader.loader != null && !item.com_loader.loader.isDisposed)
|
||||
// GLoaderPool.Instance.ReturnLoader(item.com_loader.loader);
|
||||
|
||||
// var loader = GLoaderPool.Instance.GetLoader();
|
||||
// item.com_loader.loader = loader;
|
||||
// item.com_loader.AddChild(loader);
|
||||
// loader.SetSize(item.com_loader.loader.width, item.com_loader.loader.height);
|
||||
|
||||
// _fileIsExist.TryGetValue(i, out var value);
|
||||
// if (!value)
|
||||
// {
|
||||
// var localPath = Path.Combine(TextureHelper.getResPath(), LevelData[i].Name + ".jpg");
|
||||
|
||||
// if (File.Exists(localPath))
|
||||
// {
|
||||
// _fileIsExist[i] = true;
|
||||
// Debug.Log($"[SetImgLoader] 本地存在,直接加载 {LevelData[i].Name}");
|
||||
// CrazyAsyKit.StartCoroutine(TextureHelper.LoadTexture(LevelData[i].Name, loader, null,
|
||||
// "LevelAlbums/"));
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// _fileIsExist[i] = false;
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// CrazyAsyKit.StartCoroutine(TextureHelper.LoadTexture(LevelData[i].Name, loader, null,
|
||||
// "LevelAlbums/"));
|
||||
// }
|
||||
|
||||
// activeLoaders[i] = loader;
|
||||
// }
|
||||
// Debug.Log($"[ScrollUpdate] active loaders={activeLoaders.Count}, pool={GLoaderPool.Instance.GetPoolCount()}, inUse={GLoaderPool.Instance.GetInUseCount()}");
|
||||
}
|
||||
|
||||
private void OnScrollEnd()
|
||||
{
|
||||
for (int i = 0; i < UpDatatime.Length; i++)
|
||||
{
|
||||
UpDatatime[i] = 0;
|
||||
// ImageName[i] = "";
|
||||
}
|
||||
|
||||
// DOVirtual.DelayedCall(0.1f, () =>
|
||||
// {
|
||||
ui.list_albums.RefreshVirtualList();
|
||||
// });
|
||||
|
||||
// if (LevelData == null || LevelData.Count == 0) return;
|
||||
|
||||
// var firstVisibleIndex = ui.list_albums.GetFirstChildInView();
|
||||
// var lastVisibleIndex = Mathf.Min(firstVisibleIndex + MaxVisibleCount - 1, ui.list_albums.numItems - 1);
|
||||
|
||||
// var startIndex = Mathf.Max(0, firstVisibleIndex - PreloadCount);
|
||||
// var endIndex = Mathf.Min(ui.list_albums.numItems - 1, lastVisibleIndex + PreloadCount);
|
||||
|
||||
// // Debug.Log($"[ScrollEnd] start index={startIndex} end index={endIndex}");
|
||||
|
||||
|
||||
// var tasks = new List<(GLoader loader, string fileName, Action<NTexture> callback, string folder)>();
|
||||
// // 分配 loader 并加载图片
|
||||
// for (var i = startIndex; i <= endIndex; i++)
|
||||
// {
|
||||
// _fileIsExist.TryGetValue(i, out var value);
|
||||
|
||||
// if (value) continue;
|
||||
|
||||
// if (GameHelper.GetLevel() < i + 1) continue;
|
||||
|
||||
// var item = ui.list_albums.GetChildAt(i) as item_albums;
|
||||
// if (item == null) continue;
|
||||
// if (item.com_loader.loader != null && !item.com_loader.loader.isDisposed)
|
||||
// GLoaderPool.Instance.ReturnLoader(item.com_loader.loader);
|
||||
// var loader = GLoaderPool.Instance.GetLoader();
|
||||
// item.com_loader.loader = loader;
|
||||
// item.com_loader.AddChild(loader);
|
||||
// loader.SetSize(item.com_loader.loader.width, item.com_loader.loader.height);
|
||||
|
||||
// var idx = i;
|
||||
// tasks.Add((loader, LevelData[i].Name, NTexture =>
|
||||
// {
|
||||
// if (NTexture != null) _fileIsExist[idx] = true;
|
||||
// }, "LevelAlbums/"));
|
||||
|
||||
// activeLoaders[i] = loader;
|
||||
// }
|
||||
|
||||
// if (tasks.Count > 0) TextureHelper.SetImgLoaders(tasks);
|
||||
}
|
||||
|
||||
private string[] ImageName;
|
||||
|
||||
private void RendererList(int index, GObject obj)
|
||||
{
|
||||
// Debug.Log("Render list" );
|
||||
|
||||
// Debug.Log(JsonConvert.SerializeObject(LevelData[index]));
|
||||
|
||||
item_albums item = (item_albums)obj;
|
||||
item.text_num.text = (index + 1).ToString();
|
||||
if (index < GameHelper.GetCommonModel().MultiModal - 1)
|
||||
{
|
||||
item.type_.selectedIndex = 0;
|
||||
if (GameHelper.GetLevel() > index + 1)
|
||||
{
|
||||
item.SetClick(() => { uiCtrlDispatcher.Dispatch(UICtrlMsg.AlbumDetailUI_Open, index); });
|
||||
}
|
||||
else
|
||||
{
|
||||
item.SetClick(() => { GameHelper.ShowTips("lv_unlock", true); });
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Levelunlock levelunlock_ = DataMgr.LevelUnlockListNew.Value.FirstOrDefault(x => x.level_ == index + 1);
|
||||
if (levelunlock_ != null)
|
||||
{
|
||||
item.type_.selectedIndex = levelunlock_.type;
|
||||
}
|
||||
else item.type_.selectedIndex = 0;
|
||||
if (GameHelper.GetLevel() > index + 1)
|
||||
{
|
||||
item.SetClick(() => { uiCtrlDispatcher.Dispatch(UICtrlMsg.AlbumDetailUI_Open, index); });
|
||||
}
|
||||
else
|
||||
{
|
||||
item.SetClick(() => { GameHelper.ShowTips("lv_unlock", true); });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (GameHelper.GetNowTime() < UpDatatime[index] + 1) return;
|
||||
UpDatatime[index] = GameHelper.GetNowTime();
|
||||
// if (!activeLoaders.ContainsValue(item.com_loader.loader)) activeLoaders[index] = item.com_loader.loader;
|
||||
if (!loader_list.Contains(item.com_loader.GetChild("loader") as GLoader))
|
||||
loader_list.Add(item.com_loader.GetChild("loader") as GLoader);
|
||||
|
||||
|
||||
if (index < GameHelper.GetCommonModel().MultiModal - 1)
|
||||
{
|
||||
if (GameHelper.GetLevel() > index + 1)
|
||||
{
|
||||
item.isUnlock.selectedIndex = 1;
|
||||
if (item.com_loader.loader.texture == null ||
|
||||
item.com_loader.loader.texture.nativeTexture.name != LevelData[index].Name)
|
||||
{
|
||||
// item.isUnlock.selectedIndex = 0;
|
||||
// if (item.com_loader.loader.texture != null)
|
||||
// {
|
||||
// item.com_loader.loader.texture.Dispose(); // 释放 GPU 资源
|
||||
// item.com_loader.loader.texture = null; // 断开引用
|
||||
// }
|
||||
|
||||
TextureHelper.SetImgLoader(item.com_loader.GetChild("loader") as GLoader, LevelData[index].Name,
|
||||
(a) => { Debug.Log(item.com_loader.loader.texture.nativeTexture.name); }, "LevelAlbums/", FolderNames.AlbumName);
|
||||
|
||||
ImageName[index] = LevelData[index].Name;
|
||||
}
|
||||
|
||||
item.touchable = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
item.isUnlock.selectedIndex = 0;
|
||||
// item.touchable = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Levelunlock levelunlock_ = DataMgr.LevelUnlockListNew.Value.FirstOrDefault(x => x.level_ == index + 1);
|
||||
|
||||
if (GameHelper.GetLevel() > index + 1)
|
||||
{
|
||||
if (levelunlock_ != null)
|
||||
{
|
||||
item.isUnlock.selectedIndex = 1;
|
||||
|
||||
if (item.com_loader.loader.texture == null || item.com_loader.loader.texture.nativeTexture.name != ImageName[index])
|
||||
{
|
||||
|
||||
if (levelunlock_.type == 0)
|
||||
{
|
||||
if (levelunlock_.config_index >= ConfigSystem.GetFreeImageConfig().Count) levelunlock_.config_index = ConfigSystem.GetFreeImageConfig().Count - 1;
|
||||
FreeImageLibrary _leveldata = ConfigSystem.GetFreeImageConfig()[levelunlock_.config_index];
|
||||
TextureHelper.SetImgLoader(item.com_loader.GetChild("loader") as GLoader, _leveldata.Name, null, "LevelAlbums/", FolderNames.AlbumName);
|
||||
ImageName[index] = LevelData[index].Name;
|
||||
}
|
||||
else if (levelunlock_.type == 1)
|
||||
{
|
||||
if (levelunlock_.config_index >= ConfigSystem.GetADImageConfig().Count) levelunlock_.config_index = ConfigSystem.GetADImageConfig().Count - 1;
|
||||
ADImageLibrary _leveldata = ConfigSystem.GetADImageConfig()[levelunlock_.config_index];
|
||||
TextureHelper.SetImgLoader(item.com_loader.GetChild("loader") as GLoader, _leveldata.Name, null, "LevelAlbums/", FolderNames.AlbumName);
|
||||
ImageName[index] = LevelData[index].Name;
|
||||
}
|
||||
else if (levelunlock_.type == 2)
|
||||
{
|
||||
if (levelunlock_.config_index >= ConfigSystem.GetSpecialImageConfig().Count) levelunlock_.config_index = ConfigSystem.GetSpecialImageConfig().Count - 1;
|
||||
SpecialImageLibrary _leveldata = ConfigSystem.GetSpecialImageConfig()[levelunlock_.config_index];
|
||||
TextureHelper.SetImgLoader(item.com_loader.GetChild("loader") as GLoader, _leveldata.Name, null, "LevelAlbums/", FolderNames.AlbumName);
|
||||
ImageName[index] = LevelData[index].Name;
|
||||
}
|
||||
else if (levelunlock_.type == 3)
|
||||
{
|
||||
if (levelunlock_.config_index >= ConfigSystem.GetVIPImageConfig().Count) levelunlock_.config_index = ConfigSystem.GetVIPImageConfig().Count - 1;
|
||||
VIPImageLibrary _leveldata = ConfigSystem.GetVIPImageConfig()[levelunlock_.config_index];
|
||||
TextureHelper.SetImgLoader(item.com_loader.GetChild("loader") as GLoader, _leveldata.Name, null, "LevelAlbums/", FolderNames.AlbumName);
|
||||
ImageName[index] = LevelData[index].Name;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
item.isUnlock.selectedIndex = 1;
|
||||
if (item.com_loader.loader.texture == null || item.com_loader.loader.texture.nativeTexture.name != LevelData[index].Name)
|
||||
{
|
||||
TextureHelper.SetImgLoader(item.com_loader.GetChild("loader") as GLoader, LevelData[index].Name, null, "LevelAlbums/", FolderNames.AlbumName);
|
||||
ImageName[index] = LevelData[index].Name;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// item.touchable = false;
|
||||
item.isUnlock.selectedIndex = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnOpen(object args)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnHide()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnDisplay(object args)
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 消息
|
||||
|
||||
protected override void AddListener()
|
||||
{
|
||||
GameDispatcher.Instance.AddListener(GameMsg.UnlockAlbums, SetItemData);
|
||||
}
|
||||
|
||||
protected override void RemoveListener()
|
||||
{
|
||||
GameDispatcher.Instance.RemoveListener(GameMsg.UnlockAlbums, SetItemData);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,296 +1,296 @@
|
||||
using System.Collections.Generic;
|
||||
using FairyGUI;
|
||||
using FGUI.LG_live;
|
||||
using SGModule.Common.Extensions;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Video;
|
||||
|
||||
namespace BallKingdomCrush
|
||||
{
|
||||
public class LiveUI : BaseUI
|
||||
{
|
||||
private const int MaxVisibleCount = 6; // 一屏最多6个播放器
|
||||
private static readonly Dictionary<item_live, VideoPlayer> dictionary_ = new();
|
||||
private LiveUICtrl ctrl;
|
||||
|
||||
private float late_time = 0.1f;
|
||||
private List<Live> LiveConfig;
|
||||
private LiveModel model;
|
||||
private com_live ui;
|
||||
|
||||
|
||||
private GameObject videoParent;
|
||||
|
||||
public LiveUI(LiveUICtrl ctrl) : base(ctrl)
|
||||
{
|
||||
uiName = UIConst.LiveUI;
|
||||
this.ctrl = ctrl;
|
||||
}
|
||||
|
||||
protected override void SetUIInfo(UIInfo uiInfo)
|
||||
{
|
||||
uiInfo.packageName = "LG_live";
|
||||
uiInfo.assetName = "com_live";
|
||||
uiInfo.layerType = UILayerType.Popup;
|
||||
uiInfo.isNeedOpenAnim = false;
|
||||
uiInfo.isNeedCloseAnim = false;
|
||||
uiInfo.isNeedUIMask = true;
|
||||
}
|
||||
|
||||
private void UpdateEvent()
|
||||
{
|
||||
late_time = 0.1f;
|
||||
}
|
||||
|
||||
// 初始化页面逻辑
|
||||
private void InitView()
|
||||
{
|
||||
}
|
||||
|
||||
#region 生命周期
|
||||
|
||||
protected override void OnInit()
|
||||
{
|
||||
videoParent = new GameObject("VideoPlayerParent");
|
||||
VideoPlayerPool.Instance.Init(videoParent, MaxVisibleCount);
|
||||
}
|
||||
|
||||
protected override void OnClose()
|
||||
{
|
||||
// 归还所有播放器
|
||||
foreach (var kvp in dictionary_)
|
||||
VideoPlayerPool.Instance.ReturnPlayer(kvp.Value);
|
||||
|
||||
dictionary_.Clear();
|
||||
VideoPlayerPool.Instance.DisposeAll();
|
||||
Object.Destroy(videoParent);
|
||||
|
||||
foreach (var t in loader_list)
|
||||
if (t != null && !t.isDisposed && t.texture != null)
|
||||
{
|
||||
t.texture.Dispose();
|
||||
t.texture = null;
|
||||
}
|
||||
|
||||
GLoaderPool.Instance.DisposeAll();
|
||||
TextureHelper.ClearMaterialPool();
|
||||
|
||||
// 强制卸载未使用的资源
|
||||
Resources.UnloadUnusedAssets();
|
||||
MemoryManager.CleanMemoryMonitor();
|
||||
}
|
||||
|
||||
protected override void OnBind()
|
||||
{
|
||||
ui = baseUI as com_live;
|
||||
}
|
||||
|
||||
private readonly List<GLoader> loader_list = new();
|
||||
|
||||
|
||||
protected override void OnOpenBefore(object args)
|
||||
{
|
||||
LiveConfig = ConfigSystem.GetConfig<Live>();
|
||||
|
||||
ui.list_.itemRenderer = RendererList;
|
||||
Debug.Log($"LiveConfig.Count==1=== {LiveConfig.Count}");
|
||||
ui.list_.numItems = LiveConfig.Count;
|
||||
|
||||
ui.btn_close.SetClick(() => { CtrlCloseUI(); });
|
||||
|
||||
InitView();
|
||||
|
||||
// 滚动过程中实时刷新可见播放器
|
||||
ui.list_.scrollPane.onScrollEnd.Add(OnScrollEnd);
|
||||
|
||||
// 打开页面时初始化一次
|
||||
OnScrollEnd();
|
||||
}
|
||||
|
||||
|
||||
private HashSet<item_live> lastVisibleItems = new();
|
||||
|
||||
private void OnScrollEnd()
|
||||
{
|
||||
Debug.Log($"[OnScrollEnd]==lastVisibleItems=== {lastVisibleItems.Count}");
|
||||
// 1️⃣ 回收上一次的可见播放器
|
||||
foreach (var oldItem in lastVisibleItems)
|
||||
if (dictionary_.TryGetValue(oldItem, out var player))
|
||||
{
|
||||
player.Pause();
|
||||
player.targetTexture?.Release();
|
||||
VideoPlayerPool.Instance.ReturnPlayer(player);
|
||||
dictionary_.Remove(oldItem);
|
||||
oldItem.com_loader.visible = false;
|
||||
oldItem.img_cover.visible = true;
|
||||
}
|
||||
|
||||
lastVisibleItems.Clear();
|
||||
|
||||
|
||||
// 2️⃣ 获取当前可见项
|
||||
var firstIndex = ui.list_.GetFirstChildInView();
|
||||
var lastIndex = Mathf.Min(firstIndex + MaxVisibleCount, ui.list_.numItems);
|
||||
|
||||
HashSet<item_live> newVisibleItems = new();
|
||||
for (var i = firstIndex; i < lastIndex; i++)
|
||||
if (ui.list_.GetChildAt(i) is item_live item)
|
||||
{
|
||||
newVisibleItems.Add(item);
|
||||
|
||||
// 分配播放器
|
||||
if (!dictionary_.ContainsKey(item))
|
||||
{
|
||||
var player = VideoPlayerPool.Instance.GetPlayer();
|
||||
if (player != null)
|
||||
{
|
||||
dictionary_[item] = player;
|
||||
BindPlayerToItem(item, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 3️⃣ 保存为“上一次可见项”
|
||||
lastVisibleItems = newVisibleItems;
|
||||
}
|
||||
|
||||
private void BindPlayerToItem(item_live item, int index)
|
||||
{
|
||||
var data = PreDownloadManager.GetLiveDataByIndex(LiveConfig[index], index);
|
||||
|
||||
Debug.Log($"[绑定播放器 进度] progress==1=== {data.progress}");
|
||||
if (data.progress <= 0) return;
|
||||
|
||||
var player = dictionary_[item];
|
||||
var loader = item.com_loader.GetChild("loader") as GLoader;
|
||||
item.com_loader.visible = true;
|
||||
|
||||
if (!loader_list.Contains(loader)) loader_list.Add(loader);
|
||||
|
||||
TextureHelper.SetVideoLoader(player, loader, LiveConfig[index].Name, vp =>
|
||||
{
|
||||
if (vp != null && !item.isDisposed)
|
||||
{
|
||||
if (data.progress >= 100)
|
||||
{
|
||||
item.img_cover.visible = false;
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.liveVideoLoaded);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private void RendererList(int index, GObject obj)
|
||||
{
|
||||
var livedata_ = PreDownloadManager.GetLiveDataByIndex(LiveConfig[index], index);
|
||||
|
||||
var item = (item_live)obj;
|
||||
|
||||
// UI状态显示
|
||||
item.state.selectedIndex = livedata_.progress <= 0 ? 1 : 0;
|
||||
|
||||
if (LiveConfig[index].SubscribeUnlock == 1)
|
||||
{
|
||||
if (livedata_.progress < 100) item.vip.selectedIndex = 1;
|
||||
else item.vip.selectedIndex = 2;
|
||||
}
|
||||
else item.vip.selectedIndex = 0;
|
||||
|
||||
item.mask.img_mask.fillAmount = (float)(100 - livedata_.progress) / 100;
|
||||
var coverLoader = item.img_cover.GetChild("loader") as GLoader;
|
||||
LiveVideoManager.Instance.GetVideoCover(coverLoader, LiveConfig[index].Name + "_cover", (tex) => {
|
||||
if (tex != null) {
|
||||
|
||||
if (coverLoader != null) {
|
||||
coverLoader.texture = new NTexture(tex);
|
||||
coverLoader.visible = true;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// 点击事件
|
||||
item.SetClick(() =>
|
||||
{
|
||||
if (GameHelper.GetLevel() < GameHelper.GetCommonModel().UnlockLive[1])
|
||||
{
|
||||
if (DataMgr.IsUnlockLive.Value < 0 && DataMgr.VipLevel.Value < 0) UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.SecretUnlockUI_Open, 2);
|
||||
else if (DataMgr.IsUnlockLive.Value == 0) UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.UnlockTipsUI_Open, 2);
|
||||
else HandleDetailOpen(item, index);
|
||||
}
|
||||
else
|
||||
{
|
||||
HandleDetailOpen(item, index);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void HandleDetailOpen(item_live item, int index)
|
||||
{
|
||||
if (dictionary_.TryGetValue(item, out var player))
|
||||
uiCtrlDispatcher.Dispatch(UICtrlMsg.LiveDetailUI_Open, (index, player));
|
||||
}
|
||||
|
||||
protected override void OnOpen(object args)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnHide()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnDisplay(object args)
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 消息
|
||||
|
||||
protected override void AddListener()
|
||||
{
|
||||
GameDispatcher.Instance.AddListener(GameMsg.LiveChange, Refresh);
|
||||
HallManager.Instance.UpdateEvent += UpdateEvent;
|
||||
}
|
||||
|
||||
protected override void RemoveListener()
|
||||
{
|
||||
GameDispatcher.Instance.RemoveListener(GameMsg.LiveChange, Refresh);
|
||||
HallManager.Instance.UpdateEvent -= UpdateEvent;
|
||||
}
|
||||
|
||||
|
||||
private void Refresh(object param = null)
|
||||
{
|
||||
var index = param.As<int>();
|
||||
// ui.list_.itemRenderer = RendererList;
|
||||
// Debug.Log($"LiveConfig.Count==2=== {LiveConfig.Count}");
|
||||
// ui.list_.numItems = LiveConfig.Count;
|
||||
|
||||
|
||||
if (ui.list_.GetChildAt(index) is item_live item)
|
||||
{
|
||||
item.state.selectedIndex = 0;
|
||||
var livedata_ = PreDownloadManager.GetLiveDataByIndex(LiveConfig[index], index);
|
||||
item.mask.img_mask.fillAmount = (float)(100 - livedata_.progress) / 100;
|
||||
BindPlayerToItem(item, index);
|
||||
if (LiveConfig[index].SubscribeUnlock == 1)
|
||||
{
|
||||
if (livedata_.progress < 100) item.vip.selectedIndex = 1;
|
||||
else item.vip.selectedIndex = 2;
|
||||
}
|
||||
else item.vip.selectedIndex = 0;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
public class LiveData
|
||||
{
|
||||
public int AD_num;
|
||||
public int progress;
|
||||
public int Singleprogress;
|
||||
public long LiveADTime;
|
||||
}
|
||||
using System.Collections.Generic;
|
||||
using FairyGUI;
|
||||
using FGUI.LG_live;
|
||||
using SGModule.Common.Extensions;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Video;
|
||||
|
||||
namespace BallKingdomCrush
|
||||
{
|
||||
public class LiveUI : BaseUI
|
||||
{
|
||||
private const int MaxVisibleCount = 6; // 一屏最多6个播放器
|
||||
private static readonly Dictionary<item_live, VideoPlayer> dictionary_ = new();
|
||||
private LiveUICtrl ctrl;
|
||||
|
||||
private float late_time = 0.1f;
|
||||
private List<Live> LiveConfig;
|
||||
private LiveModel model;
|
||||
private com_live ui;
|
||||
|
||||
|
||||
private GameObject videoParent;
|
||||
|
||||
public LiveUI(LiveUICtrl ctrl) : base(ctrl)
|
||||
{
|
||||
uiName = UIConst.LiveUI;
|
||||
this.ctrl = ctrl;
|
||||
}
|
||||
|
||||
protected override void SetUIInfo(UIInfo uiInfo)
|
||||
{
|
||||
uiInfo.packageName = "LG_live";
|
||||
uiInfo.assetName = "com_live";
|
||||
uiInfo.layerType = UILayerType.Popup;
|
||||
uiInfo.isNeedOpenAnim = false;
|
||||
uiInfo.isNeedCloseAnim = false;
|
||||
uiInfo.isNeedUIMask = true;
|
||||
}
|
||||
|
||||
private void UpdateEvent()
|
||||
{
|
||||
late_time = 0.1f;
|
||||
}
|
||||
|
||||
// 初始化页面逻辑
|
||||
private void InitView()
|
||||
{
|
||||
}
|
||||
|
||||
#region 生命周期
|
||||
|
||||
protected override void OnInit()
|
||||
{
|
||||
videoParent = new GameObject("VideoPlayerParent");
|
||||
VideoPlayerPool.Instance.Init(videoParent, MaxVisibleCount);
|
||||
}
|
||||
|
||||
protected override void OnClose()
|
||||
{
|
||||
// 归还所有播放器
|
||||
foreach (var kvp in dictionary_)
|
||||
VideoPlayerPool.Instance.ReturnPlayer(kvp.Value);
|
||||
|
||||
dictionary_.Clear();
|
||||
VideoPlayerPool.Instance.DisposeAll();
|
||||
Object.Destroy(videoParent);
|
||||
|
||||
foreach (var t in loader_list)
|
||||
if (t != null && !t.isDisposed && t.texture != null)
|
||||
{
|
||||
t.texture.Dispose();
|
||||
t.texture = null;
|
||||
}
|
||||
|
||||
GLoaderPool.Instance.DisposeAll();
|
||||
TextureHelper.ClearMaterialPool();
|
||||
|
||||
// 强制卸载未使用的资源
|
||||
// Resources.UnloadUnusedAssets();
|
||||
// MemoryManager.CleanMemoryMonitor();
|
||||
}
|
||||
|
||||
protected override void OnBind()
|
||||
{
|
||||
ui = baseUI as com_live;
|
||||
}
|
||||
|
||||
private readonly List<GLoader> loader_list = new();
|
||||
|
||||
|
||||
protected override void OnOpenBefore(object args)
|
||||
{
|
||||
LiveConfig = ConfigSystem.GetLiveConfig();
|
||||
|
||||
ui.list_.itemRenderer = RendererList;
|
||||
Debug.Log($"LiveConfig.Count==1=== {LiveConfig.Count}");
|
||||
ui.list_.numItems = LiveConfig.Count;
|
||||
|
||||
ui.btn_close.SetClick(() => { CtrlCloseUI(); });
|
||||
|
||||
InitView();
|
||||
|
||||
// 滚动过程中实时刷新可见播放器
|
||||
ui.list_.scrollPane.onScrollEnd.Add(OnScrollEnd);
|
||||
|
||||
// 打开页面时初始化一次
|
||||
OnScrollEnd();
|
||||
}
|
||||
|
||||
|
||||
private HashSet<item_live> lastVisibleItems = new();
|
||||
|
||||
private void OnScrollEnd()
|
||||
{
|
||||
Debug.Log($"[OnScrollEnd]==lastVisibleItems=== {lastVisibleItems.Count}");
|
||||
// 1️⃣ 回收上一次的可见播放器
|
||||
foreach (var oldItem in lastVisibleItems)
|
||||
if (dictionary_.TryGetValue(oldItem, out var player))
|
||||
{
|
||||
player.Pause();
|
||||
player.targetTexture?.Release();
|
||||
VideoPlayerPool.Instance.ReturnPlayer(player);
|
||||
dictionary_.Remove(oldItem);
|
||||
oldItem.com_loader.visible = false;
|
||||
oldItem.img_cover.visible = true;
|
||||
}
|
||||
|
||||
lastVisibleItems.Clear();
|
||||
|
||||
|
||||
// 2️⃣ 获取当前可见项
|
||||
var firstIndex = ui.list_.GetFirstChildInView();
|
||||
var lastIndex = Mathf.Min(firstIndex + MaxVisibleCount, ui.list_.numItems);
|
||||
|
||||
HashSet<item_live> newVisibleItems = new();
|
||||
for (var i = firstIndex; i < lastIndex; i++)
|
||||
if (ui.list_.GetChildAt(i) is item_live item)
|
||||
{
|
||||
newVisibleItems.Add(item);
|
||||
|
||||
// 分配播放器
|
||||
if (!dictionary_.ContainsKey(item))
|
||||
{
|
||||
var player = VideoPlayerPool.Instance.GetPlayer();
|
||||
if (player != null)
|
||||
{
|
||||
dictionary_[item] = player;
|
||||
BindPlayerToItem(item, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 3️⃣ 保存为“上一次可见项”
|
||||
lastVisibleItems = newVisibleItems;
|
||||
}
|
||||
|
||||
private void BindPlayerToItem(item_live item, int index)
|
||||
{
|
||||
var data = PreDownloadManager.GetLiveDataByIndex(LiveConfig[index], index);
|
||||
|
||||
Debug.Log($"[绑定播放器 进度] progress==1=== {data.progress}");
|
||||
if (data.progress <= 0) return;
|
||||
|
||||
var player = dictionary_[item];
|
||||
var loader = item.com_loader.GetChild("loader") as GLoader;
|
||||
item.com_loader.visible = true;
|
||||
|
||||
if (!loader_list.Contains(loader)) loader_list.Add(loader);
|
||||
|
||||
TextureHelper.SetVideoLoader(player, loader, LiveConfig[index].Name, vp =>
|
||||
{
|
||||
if (vp != null && !item.isDisposed)
|
||||
{
|
||||
if (data.progress >= 100)
|
||||
{
|
||||
item.img_cover.visible = false;
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.liveVideoLoaded);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private void RendererList(int index, GObject obj)
|
||||
{
|
||||
var livedata_ = PreDownloadManager.GetLiveDataByIndex(LiveConfig[index], index);
|
||||
|
||||
var item = (item_live)obj;
|
||||
|
||||
// UI状态显示
|
||||
item.state.selectedIndex = livedata_.progress <= 0 ? 1 : 0;
|
||||
|
||||
if (LiveConfig[index].SubscribeUnlock == 1)
|
||||
{
|
||||
if (livedata_.progress < 100) item.vip.selectedIndex = 1;
|
||||
else item.vip.selectedIndex = 2;
|
||||
}
|
||||
else item.vip.selectedIndex = 0;
|
||||
|
||||
item.mask.img_mask.fillAmount = (float)(100 - livedata_.progress) / 100;
|
||||
var coverLoader = item.img_cover.GetChild("loader") as GLoader;
|
||||
LiveVideoManager.Instance.GetVideoCover(coverLoader, LiveConfig[index].Name + "_cover", (tex) => {
|
||||
if (tex != null) {
|
||||
|
||||
if (coverLoader != null) {
|
||||
coverLoader.texture = new NTexture(tex);
|
||||
coverLoader.visible = true;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// 点击事件
|
||||
item.SetClick(() =>
|
||||
{
|
||||
if (GameHelper.GetLevel() < GameHelper.GetCommonModel().UnlockLive[1])
|
||||
{
|
||||
if (DataMgr.IsUnlockLive.Value < 0 && DataMgr.VipLevel.Value < 0) UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.SecretUnlockUI_Open, 2);
|
||||
else if (DataMgr.IsUnlockLive.Value == 0) UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.UnlockTipsUI_Open, 2);
|
||||
else HandleDetailOpen(item, index);
|
||||
}
|
||||
else
|
||||
{
|
||||
HandleDetailOpen(item, index);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void HandleDetailOpen(item_live item, int index)
|
||||
{
|
||||
if (dictionary_.TryGetValue(item, out var player))
|
||||
uiCtrlDispatcher.Dispatch(UICtrlMsg.LiveDetailUI_Open, (index, player));
|
||||
}
|
||||
|
||||
protected override void OnOpen(object args)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnHide()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnDisplay(object args)
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 消息
|
||||
|
||||
protected override void AddListener()
|
||||
{
|
||||
GameDispatcher.Instance.AddListener(GameMsg.LiveChange, Refresh);
|
||||
HallManager.Instance.UpdateEvent += UpdateEvent;
|
||||
}
|
||||
|
||||
protected override void RemoveListener()
|
||||
{
|
||||
GameDispatcher.Instance.RemoveListener(GameMsg.LiveChange, Refresh);
|
||||
HallManager.Instance.UpdateEvent -= UpdateEvent;
|
||||
}
|
||||
|
||||
|
||||
private void Refresh(object param = null)
|
||||
{
|
||||
var index = param.As<int>();
|
||||
// ui.list_.itemRenderer = RendererList;
|
||||
// Debug.Log($"LiveConfig.Count==2=== {LiveConfig.Count}");
|
||||
// ui.list_.numItems = LiveConfig.Count;
|
||||
|
||||
|
||||
if (ui.list_.GetChildAt(index) is item_live item)
|
||||
{
|
||||
item.state.selectedIndex = 0;
|
||||
var livedata_ = PreDownloadManager.GetLiveDataByIndex(LiveConfig[index], index);
|
||||
item.mask.img_mask.fillAmount = (float)(100 - livedata_.progress) / 100;
|
||||
BindPlayerToItem(item, index);
|
||||
if (LiveConfig[index].SubscribeUnlock == 1)
|
||||
{
|
||||
if (livedata_.progress < 100) item.vip.selectedIndex = 1;
|
||||
else item.vip.selectedIndex = 2;
|
||||
}
|
||||
else item.vip.selectedIndex = 0;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
public class LiveData
|
||||
{
|
||||
public int AD_num;
|
||||
public int progress;
|
||||
public int Singleprogress;
|
||||
public long LiveADTime;
|
||||
}
|
||||
}
|
||||
@@ -1,346 +1,346 @@
|
||||
using System;
|
||||
using DG.Tweening;
|
||||
using FairyGUI;
|
||||
using FGUI.LG_Common;
|
||||
using FGUI.LG_live;
|
||||
using Newtonsoft.Json;
|
||||
using SGModule.Common.Extensions;
|
||||
using SGModule.NetKit;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Video;
|
||||
using Object = UnityEngine.Object;
|
||||
|
||||
namespace BallKingdomCrush
|
||||
{
|
||||
public class LiveDetailUI : BaseUI
|
||||
{
|
||||
private LiveDetailUICtrl ctrl;
|
||||
private LiveDetailModel model;
|
||||
private com_liveDetail ui;
|
||||
private VideoPlayer video;
|
||||
|
||||
public LiveDetailUI(LiveDetailUICtrl ctrl) : base(ctrl)
|
||||
{
|
||||
uiName = UIConst.LiveDetailUI;
|
||||
this.ctrl = ctrl;
|
||||
}
|
||||
|
||||
protected override void SetUIInfo(UIInfo uiInfo)
|
||||
{
|
||||
uiInfo.packageName = "LG_live";
|
||||
uiInfo.assetName = "com_liveDetail";
|
||||
uiInfo.layerType = UILayerType.Popup;
|
||||
uiInfo.isNeedOpenAnim = false;
|
||||
uiInfo.isNeedCloseAnim = false;
|
||||
uiInfo.isNeedUIMask = true;
|
||||
}
|
||||
|
||||
//初始化页面逻辑
|
||||
private void Updata()
|
||||
{
|
||||
if (GameHelper.GetNowTime() < livedata_.LiveADTime)
|
||||
{
|
||||
Debug.Log("??????????????????");
|
||||
(ui.btn_watchad as btn_ad).state.selectedIndex = 1;
|
||||
(ui.btn_watchad as btn_ad).text_time.text = CommonHelper.TimeFormat(
|
||||
(int)livedata_.LiveADTime - Convert.ToInt32(GameHelper.GetNowTime()),
|
||||
CountDownType.Hour);
|
||||
}
|
||||
else
|
||||
{
|
||||
(ui.btn_watchad as btn_ad).state.selectedIndex = 0;
|
||||
if (LiveConfig.AD == livedata_.AD_num + 1)
|
||||
ui.btn_watchad.title = "+" + (100 - livedata_.progress) + "%";
|
||||
else
|
||||
ui.btn_watchad.title = "+" + livedata_.Singleprogress + "%";
|
||||
}
|
||||
}
|
||||
|
||||
private void InitView(object a = null)
|
||||
{
|
||||
// TextureHelper.SetImgLoader(ui.com_loader.GetChild("loader") as GLoader, LiveConfig.Name, () =>
|
||||
// {
|
||||
|
||||
// });
|
||||
Debug.Log(JsonConvert.SerializeObject(livedata_));
|
||||
Debug.Log(JsonConvert.SerializeObject(LiveConfig));
|
||||
|
||||
Updata();
|
||||
var btn_down_coin = ((btn_unlock)ui.btn_download_coin);
|
||||
if (GameHelper.GetVipLevel() >= 1)
|
||||
{
|
||||
(ui.btn_download as btn_claim_1).have_vip.selectedIndex = 1;
|
||||
ui.is_vip.selectedIndex = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
ui.is_vip.selectedIndex = 0;
|
||||
btn_down_coin.down_load.selectedIndex = 1;
|
||||
}
|
||||
if (livedata_.progress < 100)
|
||||
{
|
||||
ui.state.selectedIndex = 0;
|
||||
if (LiveConfig.AD == 0) ui.can_speed.selectedIndex = 1;
|
||||
if (LiveConfig.SubscribeUnlock == 1)
|
||||
{
|
||||
ui.SubscribeUnlock.selectedIndex = 1;
|
||||
if (GameHelper.GetVipLevel() > 0)
|
||||
{
|
||||
ui.btn_pay.visible = false;
|
||||
ui.btn_watchad.visible = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ui.SubscribeUnlock.selectedIndex = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ui.state.selectedIndex = 1;
|
||||
if (video != null) video.Play();
|
||||
}
|
||||
|
||||
(ui.img_cover.GetChild("img_mask") as GImage).fillAmount = (float)(100 - livedata_.progress) / 100;
|
||||
ui.progress_live.value = (float)livedata_.progress;
|
||||
|
||||
//ui.btn_pay.title = LiveConfig.GoldCoins.ToString();
|
||||
Debug.Log(LiveConfig.GoldCoins);
|
||||
var need_gold = (int)MathF.Ceiling((100f - livedata_.progress) * LiveConfig.GoldCoins / 100);
|
||||
ui.btn_pay.title = need_gold.ToString();
|
||||
|
||||
if (LiveConfig.AD == livedata_.AD_num + 1)
|
||||
ui.btn_watchad.title = "+" + (100 - livedata_.progress) + "%";
|
||||
else
|
||||
ui.btn_watchad.title = "+" + livedata_.Singleprogress + "%";
|
||||
|
||||
|
||||
ui.btn_pay.SetClick(() =>
|
||||
{
|
||||
if (DataMgr.Coin.Value >= need_gold)
|
||||
{
|
||||
DataMgr.Coin.Value -= need_gold;
|
||||
|
||||
livedata_.progress = 100;
|
||||
DataMgr.LiveDataDic.Value[index] = livedata_;
|
||||
Debug.Log($"[解锁成功 0] LiveData总数为: {DataMgr.LiveDataDic.Value.Count}");
|
||||
DataMgr.LiveDataDic.Save();
|
||||
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.Gold_refresh);
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.Update101);
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.LiveChange, index);
|
||||
|
||||
InitView();
|
||||
GameHelper.ShowTips("unlock_success", true);
|
||||
TrackKit.SendEvent(ADEventTrack.Coinsbuy, ADEventTrack.Property.unlock_live_resources);
|
||||
}
|
||||
else
|
||||
{
|
||||
GameHelper.ShowTips("no_enough_gold", true);
|
||||
|
||||
uiCtrlDispatcher.Dispatch(UICtrlMsg.BuygoldUI_Open);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
ui.btn_watchad.SetClick(() =>
|
||||
{
|
||||
if (livedata_.LiveADTime < GameHelper.GetNowTime())
|
||||
GameHelper.ShowVideoAd("UnlockLive", isSuccess =>
|
||||
{
|
||||
if (isSuccess)
|
||||
{
|
||||
livedata_.AD_num++;
|
||||
if (LiveConfig.AD == livedata_.AD_num)
|
||||
{
|
||||
livedata_.progress = 100;
|
||||
GameHelper.ShowTips("unlock_success", true);
|
||||
}
|
||||
else
|
||||
{
|
||||
livedata_.progress += livedata_.Singleprogress;
|
||||
}
|
||||
|
||||
DataMgr.LiveDataDic.Value[index] = livedata_;
|
||||
Debug.Log($"[解锁成功 1] LiveData总数为: {DataMgr.LiveDataDic.Value.Count}");
|
||||
DataMgr.LiveDataDic.Save();
|
||||
|
||||
livedata_.LiveADTime = GameHelper.GetNowTime() + LiveConfig.CD;
|
||||
SaveData.SaveDataFunc();
|
||||
// if (livedata_.progress == 100) HandlePvPlay();
|
||||
InitView();
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.LiveChange, index);
|
||||
}
|
||||
});
|
||||
});
|
||||
ui.btn_vip_unlock.SetClick(() =>
|
||||
{
|
||||
if (GameHelper.GetVipLevel() > 0)
|
||||
{
|
||||
livedata_.progress = 100;
|
||||
DataMgr.LiveDataDic.Value[index] = livedata_;
|
||||
Debug.Log($"[解锁成功 0] LiveData总数为: {DataMgr.LiveDataDic.Value.Count}");
|
||||
DataMgr.LiveDataDic.Save();
|
||||
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.LiveChange, index);
|
||||
|
||||
// HandlePvPlay();
|
||||
InitView();
|
||||
GameHelper.ShowTips("unlock_success", true);
|
||||
|
||||
string eventName = ADEventTrack.Property.vip_live_unclock_ + (index + 1);
|
||||
TrackKit.SendEvent(ADEventTrack.VipLive, eventName);
|
||||
}
|
||||
else
|
||||
{
|
||||
uiCtrlDispatcher.Dispatch(UICtrlMsg.VipClubViewUI_Open, 2);
|
||||
TrackKit.SendEvent(ADEventTrack.VipLive, ADEventTrack.Property.vip_live_unclock);
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
#region 生命周期
|
||||
|
||||
protected override void OnInit()
|
||||
{
|
||||
//model = ModuleManager.Instance.GetModel(ModelConst.LiveDetailModel) as LiveDetailModel;
|
||||
}
|
||||
|
||||
protected override void OnClose()
|
||||
{
|
||||
if (video != null) Object.Destroy(video.gameObject);
|
||||
HallManager.Instance.UpdateSecondEvent -= Updata;
|
||||
|
||||
VideoPlayerHandover.Return();
|
||||
}
|
||||
|
||||
protected override void OnBind()
|
||||
{
|
||||
ui = baseUI as com_liveDetail;
|
||||
}
|
||||
|
||||
private void HandlePvPlay()
|
||||
{
|
||||
Debug.Log("HandlePvPlay: " + index);
|
||||
var secondUIRoot = ui.displayObject.gameObject.transform;
|
||||
var loader = ui.com_loader.GetChild("loader") as GLoader;
|
||||
|
||||
|
||||
// 接管播放器
|
||||
VideoPlayerHandover.TakeOver(player, secondUIRoot, loader);
|
||||
ui.img_cover.visible = false;
|
||||
}
|
||||
|
||||
private int index;
|
||||
private VideoPlayer player;
|
||||
private LiveData livedata_;
|
||||
private Live LiveConfig;
|
||||
|
||||
protected override void OnOpenBefore(object args)
|
||||
{
|
||||
var tuple = ((int index, VideoPlayer player))args;
|
||||
|
||||
index = tuple.index;
|
||||
player = tuple.player;
|
||||
player.audioOutputMode = VideoAudioOutputMode.None;
|
||||
|
||||
// 从配置表取配置(这里还是 List,如果有 Id 字段可改成字典)
|
||||
LiveConfig = ConfigSystem.GetConfig<Live>()[index];
|
||||
|
||||
livedata_ = PreDownloadManager.GetLiveDataByIndex(LiveConfig, index);
|
||||
|
||||
ui.btn_close.SetClick(() => { CtrlCloseUI(); });
|
||||
|
||||
|
||||
if (livedata_.progress >= 100 && LiveVideoManager.Instance.ExistVideo(LiveConfig.Name))
|
||||
HandlePvPlay();
|
||||
else
|
||||
{
|
||||
var coverLoader = ui.img_cover.GetChild("loader") as GLoader;
|
||||
LiveVideoManager.Instance.GetVideoCover(coverLoader, LiveConfig.Name + "_cover", (tex) =>
|
||||
{
|
||||
if (tex != null)
|
||||
{
|
||||
if (coverLoader != null)
|
||||
{
|
||||
coverLoader.texture = new NTexture(tex);
|
||||
coverLoader.visible = true;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
var btn_down_coin = ((btn_unlock)ui.btn_download_coin);
|
||||
var downloadCoinNum = ConfigSystem.GetCommonConf().CoinsDownload;
|
||||
btn_down_coin.title = downloadCoinNum.ToString();
|
||||
HallManager.Instance.UpdateSecondEvent += Updata;
|
||||
|
||||
btn_down_coin.SetClick(() =>
|
||||
{
|
||||
|
||||
if (GameHelper.Get101() >= downloadCoinNum)
|
||||
{
|
||||
DataMgr.Coin.Value -= downloadCoinNum;
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.Update101);
|
||||
TextureHelper.SaveVideoToAlbum(LiveConfig.Name, CtrlCloseUI);
|
||||
TrackKit.SendEvent(ADEventTrack.Coinsbuy, ADEventTrack.Property.download);
|
||||
}
|
||||
else
|
||||
{
|
||||
GameHelper.ShowTips("no_enough_gold", true);
|
||||
uiCtrlDispatcher.Dispatch(UICtrlMsg.BuygoldUI_Open);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
ui.btn_download.SetClick(() =>
|
||||
{
|
||||
if (GameHelper.GetVipLevel() >= 1)
|
||||
{
|
||||
TextureHelper.SaveVideoToAlbum(LiveConfig.Name, CtrlCloseUI);
|
||||
}
|
||||
else
|
||||
GameHelper.ShowVideoAd("DownloadLive", isSuccess =>
|
||||
{
|
||||
if (isSuccess) TextureHelper.SaveVideoToAlbum(LiveConfig.Name, CtrlCloseUI);
|
||||
});
|
||||
});
|
||||
InitView();
|
||||
}
|
||||
|
||||
protected override void OnOpen(object args)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnHide()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnDisplay(object args)
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 消息
|
||||
|
||||
protected override void AddListener()
|
||||
{
|
||||
GameDispatcher.Instance.AddListener(GameMsg.BuyVip, InitView);
|
||||
GameDispatcher.Instance.AddListener(GameMsg.liveVideoLoaded, liveVideoLoaded);
|
||||
}
|
||||
|
||||
protected override void RemoveListener()
|
||||
{
|
||||
HallManager.Instance.UpdateSecondEvent -= Updata;
|
||||
GameDispatcher.Instance.RemoveListener(GameMsg.BuyVip, InitView);
|
||||
GameDispatcher.Instance.RemoveListener(GameMsg.liveVideoLoaded, liveVideoLoaded);
|
||||
}
|
||||
private void liveVideoLoaded(object o)
|
||||
{
|
||||
HandlePvPlay();
|
||||
// InitView();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
using System;
|
||||
using DG.Tweening;
|
||||
using FairyGUI;
|
||||
using FGUI.LG_Common;
|
||||
using FGUI.LG_live;
|
||||
using Newtonsoft.Json;
|
||||
using SGModule.Common.Extensions;
|
||||
using SGModule.NetKit;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Video;
|
||||
using Object = UnityEngine.Object;
|
||||
|
||||
namespace BallKingdomCrush
|
||||
{
|
||||
public class LiveDetailUI : BaseUI
|
||||
{
|
||||
private LiveDetailUICtrl ctrl;
|
||||
private LiveDetailModel model;
|
||||
private com_liveDetail ui;
|
||||
private VideoPlayer video;
|
||||
|
||||
public LiveDetailUI(LiveDetailUICtrl ctrl) : base(ctrl)
|
||||
{
|
||||
uiName = UIConst.LiveDetailUI;
|
||||
this.ctrl = ctrl;
|
||||
}
|
||||
|
||||
protected override void SetUIInfo(UIInfo uiInfo)
|
||||
{
|
||||
uiInfo.packageName = "LG_live";
|
||||
uiInfo.assetName = "com_liveDetail";
|
||||
uiInfo.layerType = UILayerType.Popup;
|
||||
uiInfo.isNeedOpenAnim = false;
|
||||
uiInfo.isNeedCloseAnim = false;
|
||||
uiInfo.isNeedUIMask = true;
|
||||
}
|
||||
|
||||
//初始化页面逻辑
|
||||
private void Updata()
|
||||
{
|
||||
if (GameHelper.GetNowTime() < livedata_.LiveADTime)
|
||||
{
|
||||
Debug.Log("??????????????????");
|
||||
(ui.btn_watchad as btn_ad).state.selectedIndex = 1;
|
||||
(ui.btn_watchad as btn_ad).text_time.text = CommonHelper.TimeFormat(
|
||||
(int)livedata_.LiveADTime - Convert.ToInt32(GameHelper.GetNowTime()),
|
||||
CountDownType.Hour);
|
||||
}
|
||||
else
|
||||
{
|
||||
(ui.btn_watchad as btn_ad).state.selectedIndex = 0;
|
||||
if (LiveConfig.AD == livedata_.AD_num + 1)
|
||||
ui.btn_watchad.title = "+" + (100 - livedata_.progress) + "%";
|
||||
else
|
||||
ui.btn_watchad.title = "+" + livedata_.Singleprogress + "%";
|
||||
}
|
||||
}
|
||||
|
||||
private void InitView(object a = null)
|
||||
{
|
||||
// TextureHelper.SetImgLoader(ui.com_loader.GetChild("loader") as GLoader, LiveConfig.Name, () =>
|
||||
// {
|
||||
|
||||
// });
|
||||
Debug.Log(JsonConvert.SerializeObject(livedata_));
|
||||
Debug.Log(JsonConvert.SerializeObject(LiveConfig));
|
||||
|
||||
Updata();
|
||||
var btn_down_coin = ((btn_unlock)ui.btn_download_coin);
|
||||
if (GameHelper.GetVipLevel() >= 1)
|
||||
{
|
||||
(ui.btn_download as btn_claim_1).have_vip.selectedIndex = 1;
|
||||
ui.is_vip.selectedIndex = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
ui.is_vip.selectedIndex = 0;
|
||||
btn_down_coin.down_load.selectedIndex = 1;
|
||||
}
|
||||
if (livedata_.progress < 100)
|
||||
{
|
||||
ui.state.selectedIndex = 0;
|
||||
if (LiveConfig.AD == 0) ui.can_speed.selectedIndex = 1;
|
||||
if (LiveConfig.SubscribeUnlock == 1)
|
||||
{
|
||||
ui.SubscribeUnlock.selectedIndex = 1;
|
||||
if (GameHelper.GetVipLevel() > 0)
|
||||
{
|
||||
ui.btn_pay.visible = false;
|
||||
ui.btn_watchad.visible = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ui.SubscribeUnlock.selectedIndex = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ui.state.selectedIndex = 1;
|
||||
if (video != null) video.Play();
|
||||
}
|
||||
|
||||
(ui.img_cover.GetChild("img_mask") as GImage).fillAmount = (float)(100 - livedata_.progress) / 100;
|
||||
ui.progress_live.value = (float)livedata_.progress;
|
||||
|
||||
//ui.btn_pay.title = LiveConfig.GoldCoins.ToString();
|
||||
Debug.Log(LiveConfig.GoldCoins);
|
||||
var need_gold = (int)MathF.Ceiling((100f - livedata_.progress) * LiveConfig.GoldCoins / 100);
|
||||
ui.btn_pay.title = need_gold.ToString();
|
||||
|
||||
if (LiveConfig.AD == livedata_.AD_num + 1)
|
||||
ui.btn_watchad.title = "+" + (100 - livedata_.progress) + "%";
|
||||
else
|
||||
ui.btn_watchad.title = "+" + livedata_.Singleprogress + "%";
|
||||
|
||||
|
||||
ui.btn_pay.SetClick(() =>
|
||||
{
|
||||
if (DataMgr.Coin.Value >= need_gold)
|
||||
{
|
||||
DataMgr.Coin.Value -= need_gold;
|
||||
|
||||
livedata_.progress = 100;
|
||||
DataMgr.LiveDataDic.Value[index] = livedata_;
|
||||
Debug.Log($"[解锁成功 0] LiveData总数为: {DataMgr.LiveDataDic.Value.Count}");
|
||||
DataMgr.LiveDataDic.Save();
|
||||
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.Gold_refresh);
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.Update101);
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.LiveChange, index);
|
||||
|
||||
InitView();
|
||||
GameHelper.ShowTips("unlock_success", true);
|
||||
TrackKit.SendEvent(ADEventTrack.Coinsbuy, ADEventTrack.Property.unlock_live_resources);
|
||||
}
|
||||
else
|
||||
{
|
||||
GameHelper.ShowTips("no_enough_gold", true);
|
||||
|
||||
uiCtrlDispatcher.Dispatch(UICtrlMsg.BuygoldUI_Open);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
ui.btn_watchad.SetClick(() =>
|
||||
{
|
||||
if (livedata_.LiveADTime < GameHelper.GetNowTime())
|
||||
GameHelper.ShowVideoAd("UnlockLive", isSuccess =>
|
||||
{
|
||||
if (isSuccess)
|
||||
{
|
||||
livedata_.AD_num++;
|
||||
if (LiveConfig.AD == livedata_.AD_num)
|
||||
{
|
||||
livedata_.progress = 100;
|
||||
GameHelper.ShowTips("unlock_success", true);
|
||||
}
|
||||
else
|
||||
{
|
||||
livedata_.progress += livedata_.Singleprogress;
|
||||
}
|
||||
|
||||
DataMgr.LiveDataDic.Value[index] = livedata_;
|
||||
Debug.Log($"[解锁成功 1] LiveData总数为: {DataMgr.LiveDataDic.Value.Count}");
|
||||
DataMgr.LiveDataDic.Save();
|
||||
|
||||
livedata_.LiveADTime = GameHelper.GetNowTime() + LiveConfig.CD;
|
||||
SaveData.SaveDataFunc();
|
||||
// if (livedata_.progress == 100) HandlePvPlay();
|
||||
InitView();
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.LiveChange, index);
|
||||
}
|
||||
});
|
||||
});
|
||||
ui.btn_vip_unlock.SetClick(() =>
|
||||
{
|
||||
if (GameHelper.GetVipLevel() > 0)
|
||||
{
|
||||
livedata_.progress = 100;
|
||||
DataMgr.LiveDataDic.Value[index] = livedata_;
|
||||
Debug.Log($"[解锁成功 0] LiveData总数为: {DataMgr.LiveDataDic.Value.Count}");
|
||||
DataMgr.LiveDataDic.Save();
|
||||
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.LiveChange, index);
|
||||
|
||||
// HandlePvPlay();
|
||||
InitView();
|
||||
GameHelper.ShowTips("unlock_success", true);
|
||||
|
||||
string eventName = ADEventTrack.Property.vip_live_unclock_ + (index + 1);
|
||||
TrackKit.SendEvent(ADEventTrack.VipLive, eventName);
|
||||
}
|
||||
else
|
||||
{
|
||||
uiCtrlDispatcher.Dispatch(UICtrlMsg.VipClubViewUI_Open, 2);
|
||||
TrackKit.SendEvent(ADEventTrack.VipLive, ADEventTrack.Property.vip_live_unclock);
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
#region 生命周期
|
||||
|
||||
protected override void OnInit()
|
||||
{
|
||||
//model = ModuleManager.Instance.GetModel(ModelConst.LiveDetailModel) as LiveDetailModel;
|
||||
}
|
||||
|
||||
protected override void OnClose()
|
||||
{
|
||||
if (video != null) Object.Destroy(video.gameObject);
|
||||
HallManager.Instance.UpdateSecondEvent -= Updata;
|
||||
|
||||
VideoPlayerHandover.Return();
|
||||
}
|
||||
|
||||
protected override void OnBind()
|
||||
{
|
||||
ui = baseUI as com_liveDetail;
|
||||
}
|
||||
|
||||
private void HandlePvPlay()
|
||||
{
|
||||
Debug.Log("HandlePvPlay: " + index);
|
||||
var secondUIRoot = ui.displayObject.gameObject.transform;
|
||||
var loader = ui.com_loader.GetChild("loader") as GLoader;
|
||||
|
||||
|
||||
// 接管播放器
|
||||
VideoPlayerHandover.TakeOver(player, secondUIRoot, loader);
|
||||
ui.img_cover.visible = false;
|
||||
}
|
||||
|
||||
private int index;
|
||||
private VideoPlayer player;
|
||||
private LiveData livedata_;
|
||||
private Live LiveConfig;
|
||||
|
||||
protected override void OnOpenBefore(object args)
|
||||
{
|
||||
var tuple = ((int index, VideoPlayer player))args;
|
||||
|
||||
index = tuple.index;
|
||||
player = tuple.player;
|
||||
player.audioOutputMode = VideoAudioOutputMode.None;
|
||||
|
||||
// 从配置表取配置(这里还是 List,如果有 Id 字段可改成字典)
|
||||
LiveConfig = ConfigSystem.GetLiveConfig()[index];
|
||||
|
||||
livedata_ = PreDownloadManager.GetLiveDataByIndex(LiveConfig, index);
|
||||
|
||||
ui.btn_close.SetClick(() => { CtrlCloseUI(); });
|
||||
|
||||
|
||||
if (livedata_.progress >= 100 && LiveVideoManager.Instance.ExistVideo(LiveConfig.Name))
|
||||
HandlePvPlay();
|
||||
else
|
||||
{
|
||||
var coverLoader = ui.img_cover.GetChild("loader") as GLoader;
|
||||
LiveVideoManager.Instance.GetVideoCover(coverLoader, LiveConfig.Name + "_cover", (tex) =>
|
||||
{
|
||||
if (tex != null)
|
||||
{
|
||||
if (coverLoader != null)
|
||||
{
|
||||
coverLoader.texture = new NTexture(tex);
|
||||
coverLoader.visible = true;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
var btn_down_coin = ((btn_unlock)ui.btn_download_coin);
|
||||
var downloadCoinNum = ConfigSystem.GetCommonConf().CoinsDownload;
|
||||
btn_down_coin.title = downloadCoinNum.ToString();
|
||||
HallManager.Instance.UpdateSecondEvent += Updata;
|
||||
|
||||
btn_down_coin.SetClick(() =>
|
||||
{
|
||||
|
||||
if (GameHelper.Get101() >= downloadCoinNum)
|
||||
{
|
||||
DataMgr.Coin.Value -= downloadCoinNum;
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.Update101);
|
||||
TextureHelper.SaveVideoToAlbum(LiveConfig.Name, CtrlCloseUI);
|
||||
TrackKit.SendEvent(ADEventTrack.Coinsbuy, ADEventTrack.Property.download);
|
||||
}
|
||||
else
|
||||
{
|
||||
GameHelper.ShowTips("no_enough_gold", true);
|
||||
uiCtrlDispatcher.Dispatch(UICtrlMsg.BuygoldUI_Open);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
ui.btn_download.SetClick(() =>
|
||||
{
|
||||
if (GameHelper.GetVipLevel() >= 1)
|
||||
{
|
||||
TextureHelper.SaveVideoToAlbum(LiveConfig.Name, CtrlCloseUI);
|
||||
}
|
||||
else
|
||||
GameHelper.ShowVideoAd("DownloadLive", isSuccess =>
|
||||
{
|
||||
if (isSuccess) TextureHelper.SaveVideoToAlbum(LiveConfig.Name, CtrlCloseUI);
|
||||
});
|
||||
});
|
||||
InitView();
|
||||
}
|
||||
|
||||
protected override void OnOpen(object args)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnHide()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnDisplay(object args)
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 消息
|
||||
|
||||
protected override void AddListener()
|
||||
{
|
||||
GameDispatcher.Instance.AddListener(GameMsg.BuyVip, InitView);
|
||||
GameDispatcher.Instance.AddListener(GameMsg.liveVideoLoaded, liveVideoLoaded);
|
||||
}
|
||||
|
||||
protected override void RemoveListener()
|
||||
{
|
||||
HallManager.Instance.UpdateSecondEvent -= Updata;
|
||||
GameDispatcher.Instance.RemoveListener(GameMsg.BuyVip, InitView);
|
||||
GameDispatcher.Instance.RemoveListener(GameMsg.liveVideoLoaded, liveVideoLoaded);
|
||||
}
|
||||
private void liveVideoLoaded(object o)
|
||||
{
|
||||
HandlePvPlay();
|
||||
// InitView();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,235 +1,239 @@
|
||||
using System;
|
||||
using FairyGUI;
|
||||
using FGUI.ZM_Setting_07;
|
||||
|
||||
|
||||
// using FGUI.G006_menu;
|
||||
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace BallKingdomCrush
|
||||
{
|
||||
public class MenuUI : BaseUI
|
||||
{
|
||||
private MenuUICtrl ctrl;
|
||||
private MenuModel model;
|
||||
private FGUI.ZM_Setting_07.com_setting ui;
|
||||
private int selectIndex = -1;
|
||||
|
||||
private int total_item;
|
||||
|
||||
public MenuUI(MenuUICtrl ctrl) : base(ctrl)
|
||||
{
|
||||
uiName = UIConst.MenuUI;
|
||||
this.ctrl = ctrl;
|
||||
}
|
||||
|
||||
protected override void SetUIInfo(UIInfo uiInfo)
|
||||
{
|
||||
uiInfo.packageName = "ZM_Setting_07";
|
||||
uiInfo.assetName = "com_setting";
|
||||
uiInfo.layerType = UILayerType.Popup;
|
||||
uiInfo.isNeedOpenAnim = false;
|
||||
uiInfo.isNeedCloseAnim = false;
|
||||
uiInfo.isNeedUIMask = true;
|
||||
}
|
||||
|
||||
#region 生命周期
|
||||
|
||||
protected override void OnInit()
|
||||
{
|
||||
model = moduleManager.GetModel(ModelConst.MenuModel) as MenuModel;
|
||||
}
|
||||
|
||||
protected override void OnClose()
|
||||
{
|
||||
CommonHelper.FadeOut(ui);
|
||||
}
|
||||
|
||||
protected override void OnBind()
|
||||
{
|
||||
ui = baseUI as FGUI.ZM_Setting_07.com_setting;
|
||||
}
|
||||
|
||||
protected override void OnOpenBefore(object args)
|
||||
{
|
||||
total_item = 8;
|
||||
selectIndex = DataMgr.PlayerAvatarId.Value;
|
||||
|
||||
InitView();
|
||||
}
|
||||
|
||||
protected override void OnOpen(object args)
|
||||
{
|
||||
CommonHelper.FadeIn(ui);
|
||||
|
||||
}
|
||||
|
||||
protected override void OnHide()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnDisplay(object args)
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 消息
|
||||
|
||||
protected override void AddListener()
|
||||
{
|
||||
HallManager.Instance.AddChangeGiftSwitch(InitView);
|
||||
}
|
||||
|
||||
protected override void RemoveListener()
|
||||
{
|
||||
HallManager.Instance.RemoveChangeGiftSwitch(InitView);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private void InitView()
|
||||
{
|
||||
var namStr = GameHelper.GetUserName();
|
||||
// com_Person.edit_name.input.text = namStr;
|
||||
// com_Person.btn_update.SetClick(UpdateUserInfo);
|
||||
// com_Person.edit_name.btn_amend.SetClick(SaveName);
|
||||
|
||||
ui.btn_back.SetClick(OnCloseView);
|
||||
ui.btn_music.SetClick(OnClickSetMusic);
|
||||
ui.btn_sound.SetClick(OnClickSoundBtn);
|
||||
|
||||
ui.btn_privacy.menus.selectedIndex = btn_menu.Menus_privacy;
|
||||
ui.btn_terms.menus.selectedIndex = btn_menu.Menus_terms;
|
||||
ui.btn_language.menus.selectedIndex = btn_menu.Menus_delete;
|
||||
ui.btn_official.menus.selectedIndex = btn_menu.Menus_official;
|
||||
ui.btn_restore.menus.selectedIndex = 4;
|
||||
|
||||
ui.btn_privacy.SetClick(() => { UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.PrivacyUI_Open, 0); });
|
||||
ui.btn_terms.SetClick(() => { UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.PrivacyUI_Open, 1); });
|
||||
ui.btn_language.SetClick(() =>
|
||||
{
|
||||
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.LanguageViewUI_Open);
|
||||
});
|
||||
ui.btn_official.SetClick(() => { Application.OpenURL("https://official.piggyhydration.com/"); });
|
||||
ui.btn_restore.SetClick(Restore);
|
||||
|
||||
SetUID();
|
||||
SetVersion();
|
||||
RefreshMusicUI();
|
||||
|
||||
// com_Person.list.itemRenderer = UpdateItem;
|
||||
// com_Person.list.numItems = total_item;
|
||||
}
|
||||
|
||||
private void Restore()
|
||||
{
|
||||
if (GameHelper.IsAdModelOfPay()) return;
|
||||
// GooglePayManager.Instance.RestoreNonConsumable();
|
||||
}
|
||||
// private void UpdateItem(int index, GObject items)
|
||||
// {
|
||||
// var currentIndex = index + 1;
|
||||
// var head = items as btn_item_head;
|
||||
// var imgHead = head.head as btn_head;
|
||||
|
||||
// TextureHelper.SetAvatarToLoader(currentIndex, imgHead.load_avatar);
|
||||
// head.head_select.selectedIndex = selectIndex == currentIndex
|
||||
// ? btn_item_head.Head_select_select
|
||||
// : btn_item_head.Head_select_none;
|
||||
|
||||
// head.SetClick(() =>
|
||||
// {
|
||||
// selectIndex = currentIndex;
|
||||
// com_Person.list.numItems = total_item;
|
||||
// });
|
||||
|
||||
|
||||
// }
|
||||
|
||||
|
||||
private void UpdateUserInfo()
|
||||
{
|
||||
if (selectIndex != -1)
|
||||
{
|
||||
DataMgr.PlayerAvatarId.Value = selectIndex;
|
||||
}
|
||||
|
||||
SaveName();
|
||||
|
||||
OnCloseView();
|
||||
|
||||
}
|
||||
|
||||
private void SaveName()
|
||||
{
|
||||
// var name = com_Person.edit_name.input.text;
|
||||
|
||||
// if (string.IsNullOrEmpty(name) || name.IsNullOrWhiteSpace())
|
||||
// {
|
||||
// GameHelper.ShowTips("empty_input", true);
|
||||
// return;
|
||||
// }
|
||||
|
||||
// // if (name.Equals(GameHelper.GetPlayerInviteCode()))
|
||||
// // {
|
||||
// // return;
|
||||
// // }
|
||||
|
||||
// if (name.Equals(PreferencesMgr.Instance.PlayerName)) return;
|
||||
|
||||
// GameHelper.ShowTips($"Name changed successfully");
|
||||
// PreferencesMgr.Instance.PlayerName = name;
|
||||
}
|
||||
|
||||
private void SetVersion()
|
||||
{
|
||||
ui.text_version.SetVar("count", Application.version).FlushVars();
|
||||
}
|
||||
|
||||
private void SetUID()
|
||||
{
|
||||
ui.text_uid.SetVar("UID", GameHelper.GetLoginModel().Uid.ToString()).FlushVars();
|
||||
}
|
||||
|
||||
public override void OnSwitchLanguage()
|
||||
{
|
||||
base.OnSwitchLanguage();
|
||||
|
||||
SetVersion();
|
||||
|
||||
SetUID();
|
||||
}
|
||||
private void CloseMenu(Action action = null)
|
||||
{
|
||||
CtrlCloseUI();
|
||||
action?.Invoke();
|
||||
}
|
||||
private void OnCloseView()
|
||||
{
|
||||
CloseMenu();
|
||||
}
|
||||
|
||||
private void OnClickSetMusic()
|
||||
{
|
||||
model.IsOpenMusic = !model.IsOpenMusic;
|
||||
RefreshMusicUI();
|
||||
}
|
||||
|
||||
private void OnClickSoundBtn()
|
||||
{
|
||||
model.IsOpenEffect = !model.IsOpenEffect;
|
||||
RefreshMusicUI();
|
||||
}
|
||||
|
||||
private void RefreshMusicUI()
|
||||
{
|
||||
ui.btn_music.music_on_off.selectedIndex =
|
||||
model.IsOpenMusic ? 0 : 1;
|
||||
ui.btn_sound.sound_on_off.selectedIndex =
|
||||
model.IsOpenEffect ? 0 : 1;
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using FairyGUI;
|
||||
using FGUI.ZM_Setting_07;
|
||||
|
||||
|
||||
// using FGUI.G006_menu;
|
||||
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace BallKingdomCrush
|
||||
{
|
||||
public class MenuUI : BaseUI
|
||||
{
|
||||
private MenuUICtrl ctrl;
|
||||
private MenuModel model;
|
||||
private FGUI.ZM_Setting_07.com_setting ui;
|
||||
private int selectIndex = -1;
|
||||
|
||||
private int total_item;
|
||||
|
||||
public MenuUI(MenuUICtrl ctrl) : base(ctrl)
|
||||
{
|
||||
uiName = UIConst.MenuUI;
|
||||
this.ctrl = ctrl;
|
||||
}
|
||||
|
||||
protected override void SetUIInfo(UIInfo uiInfo)
|
||||
{
|
||||
uiInfo.packageName = "ZM_Setting_07";
|
||||
uiInfo.assetName = "com_setting";
|
||||
uiInfo.layerType = UILayerType.Popup;
|
||||
uiInfo.isNeedOpenAnim = false;
|
||||
uiInfo.isNeedCloseAnim = false;
|
||||
uiInfo.isNeedUIMask = true;
|
||||
}
|
||||
|
||||
#region 生命周期
|
||||
|
||||
protected override void OnInit()
|
||||
{
|
||||
model = moduleManager.GetModel(ModelConst.MenuModel) as MenuModel;
|
||||
}
|
||||
|
||||
protected override void OnClose()
|
||||
{
|
||||
CommonHelper.FadeOut(ui);
|
||||
}
|
||||
|
||||
protected override void OnBind()
|
||||
{
|
||||
ui = baseUI as FGUI.ZM_Setting_07.com_setting;
|
||||
}
|
||||
|
||||
protected override void OnOpenBefore(object args)
|
||||
{
|
||||
total_item = 8;
|
||||
selectIndex = DataMgr.PlayerAvatarId.Value;
|
||||
|
||||
InitView();
|
||||
}
|
||||
|
||||
protected override void OnOpen(object args)
|
||||
{
|
||||
CommonHelper.FadeIn(ui);
|
||||
|
||||
}
|
||||
|
||||
protected override void OnHide()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnDisplay(object args)
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 消息
|
||||
|
||||
protected override void AddListener()
|
||||
{
|
||||
HallManager.Instance.AddChangeGiftSwitch(InitView);
|
||||
}
|
||||
|
||||
protected override void RemoveListener()
|
||||
{
|
||||
HallManager.Instance.RemoveChangeGiftSwitch(InitView);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private void InitView()
|
||||
{
|
||||
var namStr = GameHelper.GetUserName();
|
||||
// com_Person.edit_name.input.text = namStr;
|
||||
// com_Person.btn_update.SetClick(UpdateUserInfo);
|
||||
// com_Person.edit_name.btn_amend.SetClick(SaveName);
|
||||
|
||||
ui.btn_back.SetClick(OnCloseView);
|
||||
ui.btn_music.SetClick(OnClickSetMusic);
|
||||
ui.btn_sound.SetClick(OnClickSoundBtn);
|
||||
|
||||
ui.btn_privacy.menus.selectedIndex = btn_menu.Menus_privacy;
|
||||
ui.btn_terms.menus.selectedIndex = btn_menu.Menus_terms;
|
||||
ui.btn_language.menus.selectedIndex = btn_menu.Menus_delete;
|
||||
ui.btn_official.menus.selectedIndex = btn_menu.Menus_official;
|
||||
ui.btn_email.menus.selectedIndex = 5;
|
||||
ui.btn_restore.menus.selectedIndex = 4;
|
||||
|
||||
ui.btn_privacy.SetClick(() => { UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.PrivacyUI_Open, 0); });
|
||||
ui.btn_terms.SetClick(() => { UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.PrivacyUI_Open, 1); });
|
||||
ui.btn_language.SetClick(() =>
|
||||
{
|
||||
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.LanguageViewUI_Open);
|
||||
});
|
||||
ui.btn_official.SetClick(() => { Application.OpenURL("https://www.ballcrushbest.com"); });
|
||||
ui.btn_restore.SetClick(Restore);
|
||||
ui.btn_email.SetClick(() => {
|
||||
GameHelper.OpenEmail();
|
||||
});
|
||||
|
||||
SetUID();
|
||||
SetVersion();
|
||||
RefreshMusicUI();
|
||||
|
||||
// com_Person.list.itemRenderer = UpdateItem;
|
||||
// com_Person.list.numItems = total_item;
|
||||
}
|
||||
|
||||
private void Restore()
|
||||
{
|
||||
if (GameHelper.IsAdModelOfPay()) return;
|
||||
// GooglePayManager.Instance.RestoreNonConsumable();
|
||||
}
|
||||
// private void UpdateItem(int index, GObject items)
|
||||
// {
|
||||
// var currentIndex = index + 1;
|
||||
// var head = items as btn_item_head;
|
||||
// var imgHead = head.head as btn_head;
|
||||
|
||||
// TextureHelper.SetAvatarToLoader(currentIndex, imgHead.load_avatar);
|
||||
// head.head_select.selectedIndex = selectIndex == currentIndex
|
||||
// ? btn_item_head.Head_select_select
|
||||
// : btn_item_head.Head_select_none;
|
||||
|
||||
// head.SetClick(() =>
|
||||
// {
|
||||
// selectIndex = currentIndex;
|
||||
// com_Person.list.numItems = total_item;
|
||||
// });
|
||||
|
||||
|
||||
// }
|
||||
|
||||
|
||||
private void UpdateUserInfo()
|
||||
{
|
||||
if (selectIndex != -1)
|
||||
{
|
||||
DataMgr.PlayerAvatarId.Value = selectIndex;
|
||||
}
|
||||
|
||||
SaveName();
|
||||
|
||||
OnCloseView();
|
||||
|
||||
}
|
||||
|
||||
private void SaveName()
|
||||
{
|
||||
// var name = com_Person.edit_name.input.text;
|
||||
|
||||
// if (string.IsNullOrEmpty(name) || name.IsNullOrWhiteSpace())
|
||||
// {
|
||||
// GameHelper.ShowTips("empty_input", true);
|
||||
// return;
|
||||
// }
|
||||
|
||||
// // if (name.Equals(GameHelper.GetPlayerInviteCode()))
|
||||
// // {
|
||||
// // return;
|
||||
// // }
|
||||
|
||||
// if (name.Equals(PreferencesMgr.Instance.PlayerName)) return;
|
||||
|
||||
// GameHelper.ShowTips($"Name changed successfully");
|
||||
// PreferencesMgr.Instance.PlayerName = name;
|
||||
}
|
||||
|
||||
private void SetVersion()
|
||||
{
|
||||
ui.text_version.SetVar("count", Application.version).FlushVars();
|
||||
}
|
||||
|
||||
private void SetUID()
|
||||
{
|
||||
ui.text_uid.SetVar("UID", GameHelper.GetLoginModel().Uid.ToString()).FlushVars();
|
||||
}
|
||||
|
||||
public override void OnSwitchLanguage()
|
||||
{
|
||||
base.OnSwitchLanguage();
|
||||
|
||||
SetVersion();
|
||||
|
||||
SetUID();
|
||||
}
|
||||
private void CloseMenu(Action action = null)
|
||||
{
|
||||
CtrlCloseUI();
|
||||
action?.Invoke();
|
||||
}
|
||||
private void OnCloseView()
|
||||
{
|
||||
CloseMenu();
|
||||
}
|
||||
|
||||
private void OnClickSetMusic()
|
||||
{
|
||||
model.IsOpenMusic = !model.IsOpenMusic;
|
||||
RefreshMusicUI();
|
||||
}
|
||||
|
||||
private void OnClickSoundBtn()
|
||||
{
|
||||
model.IsOpenEffect = !model.IsOpenEffect;
|
||||
RefreshMusicUI();
|
||||
}
|
||||
|
||||
private void RefreshMusicUI()
|
||||
{
|
||||
ui.btn_music.music_on_off.selectedIndex =
|
||||
model.IsOpenMusic ? 0 : 1;
|
||||
ui.btn_sound.sound_on_off.selectedIndex =
|
||||
model.IsOpenEffect ? 0 : 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,123 +1,123 @@
|
||||
using System;
|
||||
|
||||
using DG.Tweening;
|
||||
using Newtonsoft.Json;
|
||||
using Spine.Unity;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BallKingdomCrush
|
||||
{
|
||||
public class OpenGameUI : BaseUI
|
||||
{
|
||||
private OpenGameUICtrl ctrl;
|
||||
private OpenGameModel model;
|
||||
private FGUI.ZM_Game_04.com_open ui;
|
||||
|
||||
public OpenGameUI(OpenGameUICtrl ctrl) : base(ctrl)
|
||||
{
|
||||
uiName = UIConst.OpenGameUI;
|
||||
this.ctrl = ctrl;
|
||||
}
|
||||
|
||||
protected override void SetUIInfo(UIInfo uiInfo)
|
||||
{
|
||||
uiInfo.packageName = "ZM_Game_04";
|
||||
uiInfo.assetName = "com_open";
|
||||
uiInfo.layerType = UILayerType.Highest;
|
||||
uiInfo.isNeedOpenAnim = false;
|
||||
uiInfo.isNeedCloseAnim = false;
|
||||
uiInfo.isNeedUIMask = false;
|
||||
}
|
||||
|
||||
#region 生命周期
|
||||
protected override void OnInit()
|
||||
{
|
||||
// model = ModuleManager.Instance.GetModel(ModelConst.OpenGameModel) as OpenGameModel;
|
||||
}
|
||||
|
||||
protected override void OnClose()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected override void OnBind()
|
||||
{
|
||||
ui = baseUI as FGUI.ZM_Game_04.com_open;
|
||||
}
|
||||
|
||||
protected override void OnOpenBefore(object args)
|
||||
{
|
||||
Debug.Log(JsonConvert.SerializeObject(DataMgr.LevelUnlockList.Value));
|
||||
DOVirtual.DelayedCall(0.7f, () =>
|
||||
{
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.reset_game, args);
|
||||
});
|
||||
InitView();
|
||||
|
||||
if (GameHelper.IsGiftSwitch())
|
||||
{
|
||||
DOVirtual.DelayedCall(0.2f, () =>
|
||||
{
|
||||
Debug.Log($"open 1 game------------------{GameHelper.GetLevel() - 1}");
|
||||
|
||||
if (GameHelper.GetLevel() - 1 < ConfigSystem.GetConfig<LevelUnlock>().Count)
|
||||
{
|
||||
LevelUnlock levelUnlock_ = ConfigSystem.GetConfig<LevelUnlock>()[GameHelper.GetLevel() - 1];
|
||||
|
||||
Debug.Log($"open 2 game------------------{levelUnlock_.LeveType}");
|
||||
if (levelUnlock_.LeveType != 0)
|
||||
{
|
||||
Debug.Log($"open 3 game------------------{DataMgr.LevelUnlockList.Value.Count}");
|
||||
if (!DataMgr.LevelUnlockList.Value.Contains(GameHelper.GetLevel() - 1))
|
||||
{
|
||||
uiCtrlDispatcher.Dispatch(UICtrlMsg.UnlockLevelUI_Open, GameHelper.GetLevel() - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
ui.t0.Play();
|
||||
|
||||
if (AudioManager.Instance.IsOpenEffect)
|
||||
{
|
||||
AudioManager.Instance.PlayDynamicEffect(AudioConst.game_open);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnOpen(object args)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnHide()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnDisplay(object args)
|
||||
{
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 消息
|
||||
protected override void AddListener()
|
||||
{
|
||||
|
||||
}
|
||||
protected override void RemoveListener()
|
||||
{
|
||||
|
||||
}
|
||||
#endregion
|
||||
private Action closeCallback;
|
||||
//初始化页面逻辑
|
||||
private void InitView()
|
||||
{
|
||||
|
||||
string stage = Language.GetContentParams("need_lv_text", GameHelper.GetLevel());
|
||||
|
||||
ui.text_level.text = stage;
|
||||
|
||||
DOVirtual.DelayedCall(1.2f, () => { CtrlCloseUI(); });
|
||||
}
|
||||
}
|
||||
using System;
|
||||
|
||||
using DG.Tweening;
|
||||
using Newtonsoft.Json;
|
||||
using Spine.Unity;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BallKingdomCrush
|
||||
{
|
||||
public class OpenGameUI : BaseUI
|
||||
{
|
||||
private OpenGameUICtrl ctrl;
|
||||
private OpenGameModel model;
|
||||
private FGUI.ZM_Game_04.com_open ui;
|
||||
|
||||
public OpenGameUI(OpenGameUICtrl ctrl) : base(ctrl)
|
||||
{
|
||||
uiName = UIConst.OpenGameUI;
|
||||
this.ctrl = ctrl;
|
||||
}
|
||||
|
||||
protected override void SetUIInfo(UIInfo uiInfo)
|
||||
{
|
||||
uiInfo.packageName = "ZM_Game_04";
|
||||
uiInfo.assetName = "com_open";
|
||||
uiInfo.layerType = UILayerType.Highest;
|
||||
uiInfo.isNeedOpenAnim = false;
|
||||
uiInfo.isNeedCloseAnim = false;
|
||||
uiInfo.isNeedUIMask = false;
|
||||
}
|
||||
|
||||
#region 生命周期
|
||||
protected override void OnInit()
|
||||
{
|
||||
// model = ModuleManager.Instance.GetModel(ModelConst.OpenGameModel) as OpenGameModel;
|
||||
}
|
||||
|
||||
protected override void OnClose()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected override void OnBind()
|
||||
{
|
||||
ui = baseUI as FGUI.ZM_Game_04.com_open;
|
||||
}
|
||||
|
||||
protected override void OnOpenBefore(object args)
|
||||
{
|
||||
Debug.Log(JsonConvert.SerializeObject(DataMgr.LevelUnlockList.Value));
|
||||
DOVirtual.DelayedCall(0.7f, () =>
|
||||
{
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.reset_game, args);
|
||||
});
|
||||
InitView();
|
||||
|
||||
if (GameHelper.IsGiftSwitch())
|
||||
{
|
||||
DOVirtual.DelayedCall(0.2f, () =>
|
||||
{
|
||||
Debug.Log($"open 1 game------------------{GameHelper.GetLevel() - 1}");
|
||||
|
||||
if (GameHelper.GetLevel() - 1 < ConfigSystem.GetLevelUnlockConfig().Count)
|
||||
{
|
||||
LevelUnlock levelUnlock_ = ConfigSystem.GetLevelUnlockConfig()[GameHelper.GetLevel() - 1];
|
||||
|
||||
Debug.Log($"open 2 game------------------{levelUnlock_.LeveType}");
|
||||
if (levelUnlock_.LeveType != 0)
|
||||
{
|
||||
Debug.Log($"open 3 game------------------{DataMgr.LevelUnlockList.Value.Count}");
|
||||
if (!DataMgr.LevelUnlockList.Value.Contains(GameHelper.GetLevel() - 1))
|
||||
{
|
||||
uiCtrlDispatcher.Dispatch(UICtrlMsg.UnlockLevelUI_Open, GameHelper.GetLevel() - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
ui.t0.Play();
|
||||
|
||||
if (AudioManager.Instance.IsOpenEffect)
|
||||
{
|
||||
AudioManager.Instance.PlayDynamicEffect(AudioConst.game_open);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnOpen(object args)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnHide()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnDisplay(object args)
|
||||
{
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 消息
|
||||
protected override void AddListener()
|
||||
{
|
||||
|
||||
}
|
||||
protected override void RemoveListener()
|
||||
{
|
||||
|
||||
}
|
||||
#endregion
|
||||
private Action closeCallback;
|
||||
//初始化页面逻辑
|
||||
private void InitView()
|
||||
{
|
||||
|
||||
string stage = Language.GetContentParams("need_lv_text", GameHelper.GetLevel());
|
||||
|
||||
ui.text_level.text = stage;
|
||||
|
||||
DOVirtual.DelayedCall(1.2f, () => { CtrlCloseUI(); });
|
||||
}
|
||||
}
|
||||
}
|
||||
+2062
-2053
File diff suppressed because it is too large
Load Diff
@@ -4,9 +4,11 @@ using AppsFlyerSDK;
|
||||
using FairyGUI;
|
||||
using IgnoreOPS;
|
||||
using SGModule.Common.Extensions;
|
||||
using SGModule.GooglePay;
|
||||
using SGModule.Net;
|
||||
using SGModule.NetKit;
|
||||
using UnityEngine;
|
||||
using ZrZYFo6bYXYM71YyLSDK;
|
||||
|
||||
namespace BallKingdomCrush
|
||||
{
|
||||
@@ -291,10 +293,10 @@ namespace BallKingdomCrush
|
||||
int startIndex = "secret_albnums".Length;
|
||||
string suffix = type[startIndex..]; // 截取 "gold" 后的所有字符
|
||||
int suffix_num = int.Parse(suffix);
|
||||
var model = ConfigSystem.GetConfig<SecretAlbums>()[suffix_num];
|
||||
var model = ConfigSystem.GetSecretAlbumsConfig()[suffix_num];
|
||||
if (model.PayType == (int)UnlockPayType.Pay)
|
||||
{
|
||||
purch_number = ConfigSystem.GetConfig<SecretAlbums>()[suffix_num].DiscountPrice.ToString();
|
||||
purch_number = ConfigSystem.GetSecretAlbumsConfig()[suffix_num].DiscountPrice.ToString();
|
||||
}
|
||||
}
|
||||
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.PayloadingUI_Close);
|
||||
@@ -303,20 +305,42 @@ namespace BallKingdomCrush
|
||||
{
|
||||
var payType = MaxPayManager.isOfficialPay ? 0 : 1;
|
||||
// 付费上报BI
|
||||
BIManager.Instance.TrackPurchase(purch_number.As<double>(), "USD", payType.ToString(), type, "paid");
|
||||
// BIManager.Instance.TrackPurchase(purch_number.As<double>(), "USD", payType.ToString(), type, "paid");
|
||||
|
||||
Debug.Log("付费收益上报AF----------- " + revenue);
|
||||
adCallbackInfo.Clear();
|
||||
adCallbackInfo.Add("appsflyer_id", AppsFlyer.getAppsFlyerId());
|
||||
adCallbackInfo.Add("customer_user_id", GameHelper.GetLoginModel().Uid.ToString());
|
||||
adCallbackInfo.Add("af_currency", "USD");
|
||||
adCallbackInfo.Add("af_revenue", revenue.ToString(CultureInfo.InvariantCulture));
|
||||
AppsFlyer.sendEvent("af_purchase", adCallbackInfo);
|
||||
// Debug.Log("付费收益上报AF----------- " + revenue);
|
||||
// adCallbackInfo.Clear();
|
||||
// adCallbackInfo.Add("appsflyer_id", AppsFlyer.getAppsFlyerId());
|
||||
// adCallbackInfo.Add("customer_user_id", GameHelper.GetLoginModel().Uid.ToString());
|
||||
// adCallbackInfo.Add("af_currency", "USD");
|
||||
// adCallbackInfo.Add("af_revenue", revenue.ToString(CultureInfo.InvariantCulture));
|
||||
// AppsFlyer.sendEvent("af_purchase", adCallbackInfo);
|
||||
|
||||
FireBaseManger.OnPayRevenueEvent(purch_number.As<double>());
|
||||
// FireBaseManger.OnPayRevenueEvent(purch_number.As<double>());
|
||||
|
||||
// ZrZYFo6bYXYM71YyLSDKCONTROLLER.Instance.Track("af_purchase", new Dictionary<string, string>()
|
||||
// {
|
||||
// {"evt1", "1"},
|
||||
// });
|
||||
|
||||
TrackKit.SendEvent(AfPurchaseTrack.Event, AfPurchaseTrack.Property.af_revenue,(int)(purch_number.As<decimal>() * 10000));
|
||||
var payData = new GooglePayData
|
||||
{
|
||||
sku = type,
|
||||
currency = "USD",
|
||||
amount = (int)(purch_number.As<decimal>() * 100),
|
||||
isCompleted = true
|
||||
};
|
||||
|
||||
//上报给服务器,用来做数据分析,之前创建订单接口改的
|
||||
GooglePayNet.GooglePayCreate<GooglePayData>(payData, (response) =>
|
||||
{
|
||||
Debug.Log($"[付费收益] Purchase-----type--{type}----{response.IsSuccess}");
|
||||
|
||||
if (response.IsSuccess)
|
||||
{
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ namespace BallKingdomCrush
|
||||
|
||||
// 强制卸载未使用的资源
|
||||
// Resources.UnloadUnusedAssets();
|
||||
MemoryManager.CleanMemoryMonitor();
|
||||
// MemoryManager.CleanMemoryMonitor();
|
||||
}
|
||||
|
||||
protected override void OnBind()
|
||||
@@ -86,7 +86,7 @@ namespace BallKingdomCrush
|
||||
var eventName = GameHelper.IsAdModelOfPay() ? ADEventTrack.AD_Event : ADEventTrack.MaxPayEvent;
|
||||
TrackKit.SendEvent(eventName, ADEventTrack.Property.secret_albums_show);
|
||||
|
||||
_secretData = ConfigSystem.GetConfig<SecretAlbums>();
|
||||
_secretData = ConfigSystem.GetSecretAlbumsConfig();
|
||||
InitView();
|
||||
}
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ namespace BallKingdomCrush
|
||||
loader_list.Clear();
|
||||
|
||||
// 强制卸载未使用的资源
|
||||
Resources.UnloadUnusedAssets();
|
||||
// Resources.UnloadUnusedAssets();
|
||||
}
|
||||
|
||||
protected override void OnBind()
|
||||
|
||||
@@ -144,12 +144,10 @@ namespace BallKingdomCrush
|
||||
{
|
||||
string type = (string)str;
|
||||
|
||||
if (type.StartsWith("buy_gold"))
|
||||
if (PurchasingManager._shopProductMap.TryGetValue(type, out var shopId))
|
||||
{
|
||||
int startIndex = "buy_gold".Length;
|
||||
string suffix = type[startIndex..]; // 截取 "gold" 后的所有字符
|
||||
int suffix_num = int.Parse(suffix);
|
||||
|
||||
int suffix_num = int.Parse(shopId);
|
||||
Debug.Log($"购买金币成功 id===={suffix_num}");
|
||||
SaveData.GetSaveObject()._goldtime[suffix_num] = (int)GameHelper.GetNowTime();
|
||||
SaveData.SaveDataFunc();
|
||||
GetAward(list[suffix_num].Actual_coins, suffix_num);
|
||||
@@ -321,7 +319,7 @@ namespace BallKingdomCrush
|
||||
{
|
||||
ad_count = AdExchangeManager.Instance.GetCeilingNeedAds(_type),
|
||||
type = _type,
|
||||
shopName = $"buy_gold{index}"
|
||||
shopName = _type
|
||||
};
|
||||
AdExchangeManager.Instance.Exchange(test);
|
||||
}
|
||||
|
||||
@@ -1,291 +1,291 @@
|
||||
// using FGUI.A000_common;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using FairyGUI;
|
||||
using FGUI.ZM_Sign_06;
|
||||
using Spine.Unity;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BallKingdomCrush
|
||||
{
|
||||
public class SignInViewUI : BaseUI
|
||||
{
|
||||
private SignInViewUICtrl ctrl;
|
||||
private SignInViewModel model;
|
||||
private List<SignDailyReward> signModel;
|
||||
|
||||
private FGUI.ZM_Sign_06.com_sign_in ui;
|
||||
|
||||
private List<GComponent> signBtnList = new List<GComponent>();
|
||||
|
||||
public SignInViewUI(SignInViewUICtrl ctrl) : base(ctrl)
|
||||
{
|
||||
uiName = UIConst.SignInViewUI;
|
||||
this.ctrl = ctrl;
|
||||
}
|
||||
|
||||
protected override void SetUIInfo(UIInfo uiInfo)
|
||||
{
|
||||
uiInfo.packageName = "ZM_Sign_06";
|
||||
uiInfo.assetName = "com_sign_in";
|
||||
uiInfo.layerType = UILayerType.Popup;
|
||||
uiInfo.isNeedOpenAnim = true;
|
||||
uiInfo.isNeedCloseAnim = true;
|
||||
uiInfo.isNeedUIMask = true;
|
||||
}
|
||||
|
||||
#region 生命周期
|
||||
protected override void OnInit()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnClose()
|
||||
{
|
||||
closeCallback?.Invoke();
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.RefreshRedDot);
|
||||
GameHelper.showGameUI = true;
|
||||
}
|
||||
|
||||
protected override void OnBind()
|
||||
{
|
||||
ui = baseUI as FGUI.ZM_Sign_06.com_sign_in;
|
||||
}
|
||||
|
||||
protected override void OnOpenBefore(object args)
|
||||
{
|
||||
signBtnList.Add(ui.day1);
|
||||
signBtnList.Add(ui.day2);
|
||||
signBtnList.Add(ui.day3);
|
||||
signBtnList.Add(ui.day4);
|
||||
signBtnList.Add(ui.day5);
|
||||
signBtnList.Add(ui.day6);
|
||||
signBtnList.Add(ui.day7);
|
||||
|
||||
signModel = ConfigSystem.GetConfig<SignDailyReward>();
|
||||
|
||||
InitView();
|
||||
}
|
||||
|
||||
protected override void OnOpen(object args)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnHide()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnDisplay(object args)
|
||||
{
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 消息
|
||||
protected override void AddListener()
|
||||
{
|
||||
|
||||
}
|
||||
protected override void RemoveListener()
|
||||
{
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
//初始化页面逻辑
|
||||
private void InitView()
|
||||
{
|
||||
var signList = signModel;
|
||||
|
||||
Debug.Log($"signList.Count:{signList.Count}");
|
||||
ui.btn_get.grayed = true;
|
||||
ui.btn_get.SetClick(() => { });
|
||||
for (int i = 0; i < signList.Count; i++)
|
||||
{
|
||||
if (i < 7)
|
||||
{
|
||||
RefreshView(signBtnList[i], signList[i], i);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ui.close.SetClick(CtrlCloseUI);
|
||||
}
|
||||
|
||||
private void RefreshView(GComponent btnSign, SignDailyReward reward, int index)
|
||||
{
|
||||
if (index != 6)
|
||||
{
|
||||
|
||||
btn_sign btnSign_new = btnSign as btn_sign;
|
||||
|
||||
btnSign_new.reward_num.text = reward.quantity[0] + "";
|
||||
SkeletonAnimation sk = FXManager.Instance.SetFx<SkeletonAnimation>(btnSign_new.fx_parent, Fx_Type.fx_signin, ref closeCallback);
|
||||
sk.state.SetAnimation(0, "small", true);
|
||||
// sk.SetActive(false);
|
||||
|
||||
var signDays = DataMgr.SignState.Value.Count;
|
||||
var isToday = true;
|
||||
if (signDays > 0)
|
||||
isToday = GameHelper.InToday(DataMgr.SignState.Value[signDays - 1], 0, true);
|
||||
if (index < signDays)
|
||||
{
|
||||
btnSign_new.status.selectedIndex = btn_sign.Status_reward;
|
||||
}
|
||||
else if (index == signDays)
|
||||
{
|
||||
if (signDays > 0 && isToday)
|
||||
{
|
||||
btnSign_new.status.selectedIndex = btn_sign.Status_unreward;
|
||||
}
|
||||
else
|
||||
{
|
||||
// sk.SetActive(true);
|
||||
// sk.state.SetAnimation(0, "signin1_6", true);
|
||||
btnSign_new.isCloseClickAnim = true;
|
||||
// btnSign.status.selectedIndex = btn_sign.State_today;
|
||||
btnSign_new.line.visible = true;
|
||||
btnSign.SetClick(() =>
|
||||
{
|
||||
var startPos = GameHelper.GetUICenterPosition(btnSign);
|
||||
btnSign_new.status.selectedIndex = btn_sign.Status_reward;
|
||||
btnSign.onClick.Clear();
|
||||
btnSign.touchable = false;
|
||||
// sk.SetActive(false);
|
||||
btnSign_new.line.visible = false;
|
||||
|
||||
GetSignInReward(reward, startPos, btnSign_new);
|
||||
});
|
||||
ui.btn_get.grayed = false;
|
||||
ui.btn_get.SetClick(() =>
|
||||
{
|
||||
var startPos = GameHelper.GetUICenterPosition(btnSign);
|
||||
btnSign_new.status.selectedIndex = btn_sign.Status_reward;
|
||||
btnSign.onClick.Clear();
|
||||
btnSign.touchable = false;
|
||||
// sk.SetActive(false);
|
||||
btnSign_new.line.visible = false;
|
||||
|
||||
GetSignInReward(reward, startPos, btnSign_new);
|
||||
ui.btn_get.grayed = true;
|
||||
ui.btn_get.SetClick(() => { });
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
btnSign_new.status.selectedIndex = btn_sign.Status_unreward;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var btnSign_new = btnSign as btn_sign7;
|
||||
|
||||
btnSign_new.reward_num.text = reward.quantity[0] + "";
|
||||
SkeletonAnimation sk = FXManager.Instance.SetFx<SkeletonAnimation>(btnSign_new.fx_parent, Fx_Type.fx_signin, ref closeCallback);
|
||||
sk.state.SetAnimation(0, "big", true);
|
||||
var signDays = DataMgr.SignState.Value.Count;
|
||||
var isToday = true;
|
||||
if (signDays > 0)
|
||||
isToday = GameHelper.InToday(DataMgr.SignState.Value[signDays - 1], 0, true);
|
||||
if (index < signDays)
|
||||
{
|
||||
btnSign_new.status.selectedIndex = btn_sign.Status_reward;
|
||||
}
|
||||
else if (index == signDays)
|
||||
{
|
||||
if (signDays > 0 && isToday)
|
||||
{
|
||||
btnSign_new.status.selectedIndex = btn_sign.Status_unreward;
|
||||
}
|
||||
else
|
||||
{
|
||||
// sk.SetActive(true);
|
||||
// sk.state.SetAnimation(0, "signin1_6", true);
|
||||
btnSign_new.isCloseClickAnim = true;
|
||||
// btnSign.status.selectedIndex = btn_sign.State_today;
|
||||
btnSign_new.line.visible = true;
|
||||
btnSign.SetClick(() =>
|
||||
{
|
||||
var startPos = GameHelper.GetUICenterPosition(btnSign);
|
||||
btnSign_new.status.selectedIndex = btn_sign.Status_reward;
|
||||
btnSign.onClick.Clear();
|
||||
btnSign.touchable = false;
|
||||
// sk.SetActive(false);
|
||||
btnSign_new.line.visible = false;
|
||||
|
||||
GetSignInReward(reward, startPos, btnSign_new);
|
||||
});
|
||||
ui.btn_get.grayed = false;
|
||||
ui.btn_get.SetClick(() =>
|
||||
{
|
||||
var startPos = GameHelper.GetUICenterPosition(btnSign);
|
||||
btnSign_new.status.selectedIndex = btn_sign.Status_reward;
|
||||
btnSign.onClick.Clear();
|
||||
btnSign.touchable = false;
|
||||
// sk.SetActive(false);
|
||||
btnSign_new.line.visible = false;
|
||||
GetSignInReward(reward, startPos, btnSign_new);
|
||||
ui.btn_get.grayed = true;
|
||||
ui.btn_get.SetClick(() => { });
|
||||
});
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
btnSign_new.status.selectedIndex = btn_sign.Status_unreward;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private Action closeCallback;
|
||||
|
||||
private void GetSignInReward(SignDailyReward vo, Vector2 startPos, GButton btnDay)
|
||||
{
|
||||
|
||||
var rewardModel = new RewardData();
|
||||
for (var i = 0; i < vo.item1.Length; i++)
|
||||
{
|
||||
var rewardData = new RewardSingleData(101, vo.quantity[i], RewardOrigin.SignIn)
|
||||
{
|
||||
startPosition = startPos,
|
||||
endPosition = new Vector2(ui.point.x, ui.point.y)
|
||||
|
||||
};
|
||||
rewardModel.AddReward(rewardData);
|
||||
}
|
||||
|
||||
if (vo.is_com_reward)
|
||||
rewardModel.displayType = RewardDisplayType.RewardFly | RewardDisplayType.Dialog |
|
||||
RewardDisplayType.ValueChange;
|
||||
else
|
||||
rewardModel.displayType = RewardDisplayType.RewardFly | RewardDisplayType.ValueChange;
|
||||
|
||||
if (vo.is_double) rewardModel.condition = RewardCondition.None;
|
||||
|
||||
rewardModel.AddCompleted(isSuccess =>
|
||||
{
|
||||
if (isSuccess)
|
||||
{
|
||||
DataMgr.SignState.Value.Add(GameHelper.GetNowTime());
|
||||
DataMgr.SignState.Save();
|
||||
|
||||
InitView();
|
||||
|
||||
btnDay.onClick.Clear();
|
||||
AudioManager.Instance.PlayDynamicEffect(AudioConst.DailyBonusCollect);
|
||||
|
||||
// 用来刷新todo界面的一些信息,如红点等
|
||||
// GameDispatcher.Instance.Dispatch(GameMsg.UpdateTodoView);
|
||||
|
||||
|
||||
// CtrlCloseUI();
|
||||
}
|
||||
});
|
||||
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.GetReward, rewardModel);
|
||||
// ui.visible = false;
|
||||
}
|
||||
}
|
||||
// using FGUI.A000_common;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using FairyGUI;
|
||||
using FGUI.ZM_Sign_06;
|
||||
using Spine.Unity;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BallKingdomCrush
|
||||
{
|
||||
public class SignInViewUI : BaseUI
|
||||
{
|
||||
private SignInViewUICtrl ctrl;
|
||||
private SignInViewModel model;
|
||||
private List<SignDailyReward> signModel;
|
||||
|
||||
private FGUI.ZM_Sign_06.com_sign_in ui;
|
||||
|
||||
private List<GComponent> signBtnList = new List<GComponent>();
|
||||
|
||||
public SignInViewUI(SignInViewUICtrl ctrl) : base(ctrl)
|
||||
{
|
||||
uiName = UIConst.SignInViewUI;
|
||||
this.ctrl = ctrl;
|
||||
}
|
||||
|
||||
protected override void SetUIInfo(UIInfo uiInfo)
|
||||
{
|
||||
uiInfo.packageName = "ZM_Sign_06";
|
||||
uiInfo.assetName = "com_sign_in";
|
||||
uiInfo.layerType = UILayerType.Popup;
|
||||
uiInfo.isNeedOpenAnim = true;
|
||||
uiInfo.isNeedCloseAnim = true;
|
||||
uiInfo.isNeedUIMask = true;
|
||||
}
|
||||
|
||||
#region 生命周期
|
||||
protected override void OnInit()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnClose()
|
||||
{
|
||||
closeCallback?.Invoke();
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.RefreshRedDot);
|
||||
GameHelper.showGameUI = true;
|
||||
}
|
||||
|
||||
protected override void OnBind()
|
||||
{
|
||||
ui = baseUI as FGUI.ZM_Sign_06.com_sign_in;
|
||||
}
|
||||
|
||||
protected override void OnOpenBefore(object args)
|
||||
{
|
||||
signBtnList.Add(ui.day1);
|
||||
signBtnList.Add(ui.day2);
|
||||
signBtnList.Add(ui.day3);
|
||||
signBtnList.Add(ui.day4);
|
||||
signBtnList.Add(ui.day5);
|
||||
signBtnList.Add(ui.day6);
|
||||
signBtnList.Add(ui.day7);
|
||||
|
||||
signModel = ConfigSystem.GetConfig<SignDailyReward>();
|
||||
|
||||
InitView();
|
||||
}
|
||||
|
||||
protected override void OnOpen(object args)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnHide()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnDisplay(object args)
|
||||
{
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 消息
|
||||
protected override void AddListener()
|
||||
{
|
||||
|
||||
}
|
||||
protected override void RemoveListener()
|
||||
{
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
//初始化页面逻辑
|
||||
private void InitView()
|
||||
{
|
||||
var signList = signModel;
|
||||
|
||||
Debug.Log($"signList.Count:{signList.Count}");
|
||||
ui.btn_get.grayed = true;
|
||||
ui.btn_get.SetClick(() => { });
|
||||
for (int i = 0; i < signList.Count; i++)
|
||||
{
|
||||
if (i < 7)
|
||||
{
|
||||
RefreshView(signBtnList[i], signList[i], i);
|
||||
}
|
||||
}
|
||||
|
||||
ui.close.SetClick(()=>{});
|
||||
ui.close.SetClick(CtrlCloseUI);
|
||||
}
|
||||
|
||||
private void RefreshView(GComponent btnSign, SignDailyReward reward, int index)
|
||||
{
|
||||
if (index != 6)
|
||||
{
|
||||
|
||||
btn_sign btnSign_new = btnSign as btn_sign;
|
||||
|
||||
btnSign_new.reward_num.text = reward.quantity[0] + "";
|
||||
SkeletonAnimation sk = FXManager.Instance.SetFx<SkeletonAnimation>(btnSign_new.fx_parent, Fx_Type.fx_signin, ref closeCallback);
|
||||
sk.state.SetAnimation(0, "small", true);
|
||||
// sk.SetActive(false);
|
||||
|
||||
var signDays = DataMgr.SignState.Value.Count;
|
||||
var isToday = true;
|
||||
if (signDays > 0)
|
||||
isToday = GameHelper.InToday(DataMgr.SignState.Value[signDays - 1], 0, true);
|
||||
if (index < signDays)
|
||||
{
|
||||
btnSign_new.status.selectedIndex = btn_sign.Status_reward;
|
||||
}
|
||||
else if (index == signDays)
|
||||
{
|
||||
if (signDays > 0 && isToday)
|
||||
{
|
||||
btnSign_new.status.selectedIndex = btn_sign.Status_unreward;
|
||||
}
|
||||
else
|
||||
{
|
||||
// sk.SetActive(true);
|
||||
// sk.state.SetAnimation(0, "signin1_6", true);
|
||||
btnSign_new.isCloseClickAnim = true;
|
||||
// btnSign.status.selectedIndex = btn_sign.State_today;
|
||||
btnSign_new.line.visible = true;
|
||||
btnSign.SetClick(() =>
|
||||
{
|
||||
// var startPos = GameHelper.GetUICenterPosition(btnSign);
|
||||
// btnSign_new.status.selectedIndex = btn_sign.Status_reward;
|
||||
// btnSign.onClick.Clear();
|
||||
// btnSign.touchable = false;
|
||||
// // sk.SetActive(false);
|
||||
// btnSign_new.line.visible = false;
|
||||
//
|
||||
// GetSignInReward(reward, startPos, btnSign_new);
|
||||
});
|
||||
ui.btn_get.grayed = false;
|
||||
ui.btn_get.SetClick(() =>
|
||||
{
|
||||
var startPos = GameHelper.GetUICenterPosition(btnSign);
|
||||
btnSign_new.status.selectedIndex = btn_sign.Status_reward;
|
||||
btnSign.onClick.Clear();
|
||||
btnSign.touchable = false;
|
||||
// sk.SetActive(false);
|
||||
btnSign_new.line.visible = false;
|
||||
|
||||
GetSignInReward(reward, startPos, btnSign_new);
|
||||
ui.btn_get.grayed = true;
|
||||
ui.btn_get.SetClick(() => { });
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
btnSign_new.status.selectedIndex = btn_sign.Status_unreward;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var btnSign_new = btnSign as btn_sign7;
|
||||
|
||||
btnSign_new.reward_num.text = reward.quantity[0] + "";
|
||||
SkeletonAnimation sk = FXManager.Instance.SetFx<SkeletonAnimation>(btnSign_new.fx_parent, Fx_Type.fx_signin, ref closeCallback);
|
||||
sk.state.SetAnimation(0, "big", true);
|
||||
var signDays = DataMgr.SignState.Value.Count;
|
||||
var isToday = true;
|
||||
if (signDays > 0)
|
||||
isToday = GameHelper.InToday(DataMgr.SignState.Value[signDays - 1], 0, true);
|
||||
if (index < signDays)
|
||||
{
|
||||
btnSign_new.status.selectedIndex = btn_sign.Status_reward;
|
||||
}
|
||||
else if (index == signDays)
|
||||
{
|
||||
if (signDays > 0 && isToday)
|
||||
{
|
||||
btnSign_new.status.selectedIndex = btn_sign.Status_unreward;
|
||||
}
|
||||
else
|
||||
{
|
||||
// sk.SetActive(true);
|
||||
// sk.state.SetAnimation(0, "signin1_6", true);
|
||||
btnSign_new.isCloseClickAnim = true;
|
||||
// btnSign.status.selectedIndex = btn_sign.State_today;
|
||||
btnSign_new.line.visible = true;
|
||||
btnSign.SetClick(() =>
|
||||
{
|
||||
// var startPos = GameHelper.GetUICenterPosition(btnSign);
|
||||
// btnSign_new.status.selectedIndex = btn_sign.Status_reward;
|
||||
// btnSign.onClick.Clear();
|
||||
// btnSign.touchable = false;
|
||||
// // sk.SetActive(false);
|
||||
// btnSign_new.line.visible = false;
|
||||
//
|
||||
// GetSignInReward(reward, startPos, btnSign_new);
|
||||
});
|
||||
ui.btn_get.grayed = false;
|
||||
ui.btn_get.SetClick(() =>
|
||||
{
|
||||
var startPos = GameHelper.GetUICenterPosition(btnSign);
|
||||
btnSign_new.status.selectedIndex = btn_sign.Status_reward;
|
||||
btnSign.onClick.Clear();
|
||||
btnSign.touchable = false;
|
||||
// sk.SetActive(false);
|
||||
btnSign_new.line.visible = false;
|
||||
GetSignInReward(reward, startPos, btnSign_new);
|
||||
ui.btn_get.grayed = true;
|
||||
ui.btn_get.SetClick(() => { });
|
||||
});
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
btnSign_new.status.selectedIndex = btn_sign.Status_unreward;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private Action closeCallback;
|
||||
|
||||
private void GetSignInReward(SignDailyReward vo, Vector2 startPos, GButton btnDay)
|
||||
{
|
||||
|
||||
var rewardModel = new RewardData();
|
||||
for (var i = 0; i < vo.item1.Length; i++)
|
||||
{
|
||||
var rewardData = new RewardSingleData(101, vo.quantity[i], RewardOrigin.SignIn)
|
||||
{
|
||||
startPosition = startPos,
|
||||
endPosition = new Vector2(ui.point.x, ui.point.y)
|
||||
|
||||
};
|
||||
rewardModel.AddReward(rewardData);
|
||||
}
|
||||
|
||||
if (vo.is_com_reward)
|
||||
rewardModel.displayType = RewardDisplayType.RewardFly | RewardDisplayType.Dialog |
|
||||
RewardDisplayType.ValueChange;
|
||||
else
|
||||
rewardModel.displayType = RewardDisplayType.RewardFly | RewardDisplayType.ValueChange;
|
||||
|
||||
if (vo.is_double) rewardModel.condition = RewardCondition.None;
|
||||
|
||||
rewardModel.AddCompleted(isSuccess =>
|
||||
{
|
||||
if (isSuccess)
|
||||
{
|
||||
DataMgr.SignState.Value.Add(GameHelper.GetNowTime());
|
||||
DataMgr.SignState.Save();
|
||||
|
||||
InitView();
|
||||
|
||||
btnDay.onClick.Clear();
|
||||
AudioManager.Instance.PlayDynamicEffect(AudioConst.DailyBonusCollect);
|
||||
|
||||
// 用来刷新todo界面的一些信息,如红点等
|
||||
// GameDispatcher.Instance.Dispatch(GameMsg.UpdateTodoView);
|
||||
|
||||
|
||||
// CtrlCloseUI();
|
||||
}
|
||||
});
|
||||
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.GetReward, rewardModel);
|
||||
// ui.visible = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,248 +1,248 @@
|
||||
|
||||
using System.Collections.Generic;
|
||||
using FGUI.ZM_Common_01;
|
||||
using UnityEngine;
|
||||
using FairyGUI;
|
||||
using FGUI.LG_Common;
|
||||
using DG.Tweening;
|
||||
using SGModule.NetKit;
|
||||
|
||||
namespace BallKingdomCrush
|
||||
{
|
||||
public class UnlockLevelUI : BaseUI
|
||||
{
|
||||
private UnlockLevelUICtrl ctrl;
|
||||
private UnlockLevelModel model;
|
||||
private FGUI.LG_End.com_unlockLevel ui;
|
||||
|
||||
public UnlockLevelUI(UnlockLevelUICtrl ctrl) : base(ctrl)
|
||||
{
|
||||
uiName = UIConst.UnlockLevelUI;
|
||||
this.ctrl = ctrl;
|
||||
}
|
||||
|
||||
protected override void SetUIInfo(UIInfo uiInfo)
|
||||
{
|
||||
uiInfo.packageName = "LG_End";
|
||||
uiInfo.assetName = "com_unlockLevel";
|
||||
uiInfo.layerType = UILayerType.Popup;
|
||||
uiInfo.isNeedOpenAnim = false;
|
||||
uiInfo.isNeedCloseAnim = false;
|
||||
uiInfo.isNeedUIMask = true;
|
||||
}
|
||||
|
||||
#region 生命周期
|
||||
protected override void OnInit()
|
||||
{
|
||||
//model = ModuleManager.Instance.GetModel(ModelConst.UnlockLevelModel) as UnlockLevelModel;
|
||||
}
|
||||
|
||||
protected override void OnClose()
|
||||
{
|
||||
for (int i = 0; i < loader_list.Count; i++)
|
||||
{
|
||||
if (loader_list[i] != null && !loader_list[i].isDisposed && loader_list[i].texture != null)
|
||||
{
|
||||
loader_list[i].texture = null;
|
||||
}
|
||||
}
|
||||
loader_list.Clear();
|
||||
|
||||
}
|
||||
|
||||
protected override void OnBind()
|
||||
{
|
||||
ui = baseUI as FGUI.LG_End.com_unlockLevel;
|
||||
}
|
||||
private LevelUnlock levelUnlock_;
|
||||
private int level_;
|
||||
private List<GLoader> loader_list = new List<GLoader>();
|
||||
protected override void OnOpenBefore(object args)
|
||||
{
|
||||
level_ = (int)args;
|
||||
Debug.Log(level_);
|
||||
|
||||
if (!loader_list.Contains(ui.com_loader.GetChild("loader") as GLoader))
|
||||
{
|
||||
loader_list.Add(ui.com_loader.GetChild("loader") as GLoader);
|
||||
}
|
||||
|
||||
levelUnlock_ = ConfigSystem.GetConfig<LevelUnlock>()[level_];
|
||||
// TextureHelper.SetImgLoader(ui.com_loader.GetChild("loader") as GLoader, levelUnlock_.Name, (s) =>
|
||||
// {
|
||||
// TextureHelper.SetImageBlur(ui.com_loader.GetChild("loader") as GLoader);
|
||||
// }, "LevelAlbums/");
|
||||
InitView();
|
||||
|
||||
var names = ADEventTrack.Property.vip_show_levelpass + (level_ + 1);
|
||||
TrackKit.SendEvent(ADEventTrack.Subscription, names);
|
||||
|
||||
|
||||
var eventName = levelUnlock_.LeveType == 1 ? ADEventTrack.Property.special_level : ADEventTrack.Property.vip_level;
|
||||
TrackKit.SendEvent(ADEventTrack.Special, eventName);
|
||||
|
||||
}
|
||||
|
||||
protected override void OnOpen(object args)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnHide()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnDisplay(object args)
|
||||
{
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 消息
|
||||
protected override void AddListener()
|
||||
{
|
||||
GameDispatcher.Instance.AddListener(GameMsg.BuyVip, refrsh);
|
||||
}
|
||||
protected override void RemoveListener()
|
||||
{
|
||||
GameDispatcher.Instance.RemoveListener(GameMsg.BuyVip, refrsh);
|
||||
}
|
||||
#endregion
|
||||
private void refrsh(object a = null)
|
||||
{
|
||||
DOVirtual.DelayedCall(0.5f, () =>
|
||||
{
|
||||
InitView();
|
||||
});
|
||||
|
||||
}
|
||||
//初始化页面逻辑
|
||||
private void InitView()
|
||||
{
|
||||
|
||||
|
||||
if (GameHelper.GetVipLevel() >= 3)
|
||||
{
|
||||
(ui.btn_vip as btn_claim_2).have_vip.selectedIndex = 1;
|
||||
}
|
||||
if (GameHelper.GetVipLevel() >= 2)
|
||||
{
|
||||
(ui.btn_watch as btn_claim_1).have_vip.selectedIndex = 1;
|
||||
}
|
||||
if (levelUnlock_.LeveType == 1) //特殊关
|
||||
{
|
||||
ui.type.selectedIndex = 0;
|
||||
ui.btn_pay.title = levelUnlock_.GoldCoins.ToString();
|
||||
|
||||
ui.btn_pay.SetClick(() =>
|
||||
{
|
||||
if (DataMgr.Coin.Value >= levelUnlock_.GoldCoins)
|
||||
{
|
||||
DataMgr.Coin.Value -= levelUnlock_.GoldCoins;
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.Gold_refresh);
|
||||
DataMgr.LevelUnlockList.Value.Add(level_);
|
||||
GameHelper.ShowTips("unlocked", true);
|
||||
DataMgr.LevelUnlockList.Save();
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.UnlockLevelsuccess);
|
||||
|
||||
TrackKit.SendEvent(ADEventTrack.Special, ADEventTrack.Property.special_level_coin);
|
||||
|
||||
CtrlCloseUI();
|
||||
}
|
||||
else
|
||||
{
|
||||
GameHelper.ShowTips("no_enough_gold", true);
|
||||
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.BuygoldUI_Open, true);
|
||||
}
|
||||
});
|
||||
|
||||
ui.btn_watch.SetClick(() => //7天都不包含。30天包含特殊,365全部包含
|
||||
{
|
||||
if (GameHelper.GetVipLevel() >= 2)
|
||||
{
|
||||
DataMgr.LevelUnlockList.Value.Add(level_);
|
||||
GameHelper.ShowTips("unlocked", true);
|
||||
DataMgr.LevelUnlockList.Save();
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.UnlockLevelsuccess);
|
||||
CtrlCloseUI();
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
GameHelper.ShowVideoAd("UnlockSpecialLevel", isSuccess =>
|
||||
{
|
||||
|
||||
if (isSuccess)
|
||||
{
|
||||
TrackKit.SendEvent(ADEventTrack.Special, ADEventTrack.Property.special_level_video);
|
||||
|
||||
DataMgr.LevelUnlockList.Value.Add(level_);
|
||||
GameHelper.ShowTips("unlocked", true);
|
||||
DataMgr.LevelUnlockList.Save();
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.UnlockLevelsuccess);
|
||||
CtrlCloseUI();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
else if (levelUnlock_.LeveType == 2)//vip关
|
||||
{
|
||||
ui.type.selectedIndex = 1;
|
||||
ui.btn_pay.title = levelUnlock_.GoldCoins.ToString();
|
||||
|
||||
ui.btn_pay.SetClick(() =>
|
||||
{
|
||||
if (DataMgr.Coin.Value >= levelUnlock_.GoldCoins)
|
||||
{
|
||||
DataMgr.Coin.Value -= levelUnlock_.GoldCoins;
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.Gold_refresh);
|
||||
DataMgr.LevelUnlockList.Value.Add(level_);
|
||||
DataMgr.LevelUnlockList.Save();
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.UnlockLevelsuccess);
|
||||
CtrlCloseUI();
|
||||
|
||||
TrackKit.SendEvent(ADEventTrack.Special, ADEventTrack.Property.vip_level_coin);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
});
|
||||
ui.btn_vip.SetClick(() =>
|
||||
{
|
||||
if (GameHelper.GetVipLevel() >= 3)
|
||||
{
|
||||
DataMgr.LevelUnlockList.Value.Add(level_);
|
||||
DataMgr.LevelUnlockList.Save();
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.UnlockLevelsuccess);
|
||||
CtrlCloseUI();
|
||||
}
|
||||
else
|
||||
{
|
||||
uiCtrlDispatcher.Dispatch(UICtrlMsg.VipClubViewUI_Open, 2);
|
||||
}
|
||||
TrackKit.SendEvent(ADEventTrack.Special, ADEventTrack.Property.vip_level_sub);
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
ui.btn_close.SetClick(() =>
|
||||
{
|
||||
GameHelper.SetLevel(GameHelper.GetLevel() + 1);
|
||||
if (UIManager.Instance.IsExistUI(UIConst.NewEndUI))
|
||||
{
|
||||
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.NewEndUI_Close);
|
||||
}
|
||||
else
|
||||
{
|
||||
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.OpenGameUI_Open);
|
||||
}
|
||||
|
||||
CtrlCloseUI();
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
using System.Collections.Generic;
|
||||
using FGUI.ZM_Common_01;
|
||||
using UnityEngine;
|
||||
using FairyGUI;
|
||||
using FGUI.LG_Common;
|
||||
using DG.Tweening;
|
||||
using SGModule.NetKit;
|
||||
|
||||
namespace BallKingdomCrush
|
||||
{
|
||||
public class UnlockLevelUI : BaseUI
|
||||
{
|
||||
private UnlockLevelUICtrl ctrl;
|
||||
private UnlockLevelModel model;
|
||||
private FGUI.LG_End.com_unlockLevel ui;
|
||||
|
||||
public UnlockLevelUI(UnlockLevelUICtrl ctrl) : base(ctrl)
|
||||
{
|
||||
uiName = UIConst.UnlockLevelUI;
|
||||
this.ctrl = ctrl;
|
||||
}
|
||||
|
||||
protected override void SetUIInfo(UIInfo uiInfo)
|
||||
{
|
||||
uiInfo.packageName = "LG_End";
|
||||
uiInfo.assetName = "com_unlockLevel";
|
||||
uiInfo.layerType = UILayerType.Popup;
|
||||
uiInfo.isNeedOpenAnim = false;
|
||||
uiInfo.isNeedCloseAnim = false;
|
||||
uiInfo.isNeedUIMask = true;
|
||||
}
|
||||
|
||||
#region 生命周期
|
||||
protected override void OnInit()
|
||||
{
|
||||
//model = ModuleManager.Instance.GetModel(ModelConst.UnlockLevelModel) as UnlockLevelModel;
|
||||
}
|
||||
|
||||
protected override void OnClose()
|
||||
{
|
||||
for (int i = 0; i < loader_list.Count; i++)
|
||||
{
|
||||
if (loader_list[i] != null && !loader_list[i].isDisposed && loader_list[i].texture != null)
|
||||
{
|
||||
loader_list[i].texture = null;
|
||||
}
|
||||
}
|
||||
loader_list.Clear();
|
||||
|
||||
}
|
||||
|
||||
protected override void OnBind()
|
||||
{
|
||||
ui = baseUI as FGUI.LG_End.com_unlockLevel;
|
||||
}
|
||||
private LevelUnlock levelUnlock_;
|
||||
private int level_;
|
||||
private List<GLoader> loader_list = new List<GLoader>();
|
||||
protected override void OnOpenBefore(object args)
|
||||
{
|
||||
level_ = (int)args;
|
||||
Debug.Log(level_);
|
||||
|
||||
if (!loader_list.Contains(ui.com_loader.GetChild("loader") as GLoader))
|
||||
{
|
||||
loader_list.Add(ui.com_loader.GetChild("loader") as GLoader);
|
||||
}
|
||||
|
||||
levelUnlock_ = ConfigSystem.GetLevelUnlockConfig()[level_];
|
||||
// TextureHelper.SetImgLoader(ui.com_loader.GetChild("loader") as GLoader, levelUnlock_.Name, (s) =>
|
||||
// {
|
||||
// TextureHelper.SetImageBlur(ui.com_loader.GetChild("loader") as GLoader);
|
||||
// }, "LevelAlbums/");
|
||||
InitView();
|
||||
|
||||
var names = ADEventTrack.Property.vip_show_levelpass + (level_ + 1);
|
||||
TrackKit.SendEvent(ADEventTrack.Subscription, names);
|
||||
|
||||
|
||||
var eventName = levelUnlock_.LeveType == 1 ? ADEventTrack.Property.special_level : ADEventTrack.Property.vip_level;
|
||||
TrackKit.SendEvent(ADEventTrack.Special, eventName);
|
||||
|
||||
}
|
||||
|
||||
protected override void OnOpen(object args)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnHide()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnDisplay(object args)
|
||||
{
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 消息
|
||||
protected override void AddListener()
|
||||
{
|
||||
GameDispatcher.Instance.AddListener(GameMsg.BuyVip, refrsh);
|
||||
}
|
||||
protected override void RemoveListener()
|
||||
{
|
||||
GameDispatcher.Instance.RemoveListener(GameMsg.BuyVip, refrsh);
|
||||
}
|
||||
#endregion
|
||||
private void refrsh(object a = null)
|
||||
{
|
||||
DOVirtual.DelayedCall(0.5f, () =>
|
||||
{
|
||||
InitView();
|
||||
});
|
||||
|
||||
}
|
||||
//初始化页面逻辑
|
||||
private void InitView()
|
||||
{
|
||||
|
||||
|
||||
if (GameHelper.GetVipLevel() >= 3)
|
||||
{
|
||||
(ui.btn_vip as btn_claim_2).have_vip.selectedIndex = 1;
|
||||
}
|
||||
if (GameHelper.GetVipLevel() >= 2)
|
||||
{
|
||||
(ui.btn_watch as btn_claim_1).have_vip.selectedIndex = 1;
|
||||
}
|
||||
if (levelUnlock_.LeveType == 1) //特殊关
|
||||
{
|
||||
ui.type.selectedIndex = 0;
|
||||
ui.btn_pay.title = levelUnlock_.GoldCoins.ToString();
|
||||
|
||||
ui.btn_pay.SetClick(() =>
|
||||
{
|
||||
if (DataMgr.Coin.Value >= levelUnlock_.GoldCoins)
|
||||
{
|
||||
DataMgr.Coin.Value -= levelUnlock_.GoldCoins;
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.Gold_refresh);
|
||||
DataMgr.LevelUnlockList.Value.Add(level_);
|
||||
GameHelper.ShowTips("unlocked", true);
|
||||
DataMgr.LevelUnlockList.Save();
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.UnlockLevelsuccess);
|
||||
|
||||
TrackKit.SendEvent(ADEventTrack.Special, ADEventTrack.Property.special_level_coin);
|
||||
|
||||
CtrlCloseUI();
|
||||
}
|
||||
else
|
||||
{
|
||||
GameHelper.ShowTips("no_enough_gold", true);
|
||||
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.BuygoldUI_Open, true);
|
||||
}
|
||||
});
|
||||
|
||||
ui.btn_watch.SetClick(() => //7天都不包含。30天包含特殊,365全部包含
|
||||
{
|
||||
if (GameHelper.GetVipLevel() >= 2)
|
||||
{
|
||||
DataMgr.LevelUnlockList.Value.Add(level_);
|
||||
GameHelper.ShowTips("unlocked", true);
|
||||
DataMgr.LevelUnlockList.Save();
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.UnlockLevelsuccess);
|
||||
CtrlCloseUI();
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
GameHelper.ShowVideoAd("UnlockSpecialLevel", isSuccess =>
|
||||
{
|
||||
|
||||
if (isSuccess)
|
||||
{
|
||||
TrackKit.SendEvent(ADEventTrack.Special, ADEventTrack.Property.special_level_video);
|
||||
|
||||
DataMgr.LevelUnlockList.Value.Add(level_);
|
||||
GameHelper.ShowTips("unlocked", true);
|
||||
DataMgr.LevelUnlockList.Save();
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.UnlockLevelsuccess);
|
||||
CtrlCloseUI();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
else if (levelUnlock_.LeveType == 2)//vip关
|
||||
{
|
||||
ui.type.selectedIndex = 1;
|
||||
ui.btn_pay.title = levelUnlock_.GoldCoins.ToString();
|
||||
|
||||
ui.btn_pay.SetClick(() =>
|
||||
{
|
||||
if (DataMgr.Coin.Value >= levelUnlock_.GoldCoins)
|
||||
{
|
||||
DataMgr.Coin.Value -= levelUnlock_.GoldCoins;
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.Gold_refresh);
|
||||
DataMgr.LevelUnlockList.Value.Add(level_);
|
||||
DataMgr.LevelUnlockList.Save();
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.UnlockLevelsuccess);
|
||||
CtrlCloseUI();
|
||||
|
||||
TrackKit.SendEvent(ADEventTrack.Special, ADEventTrack.Property.vip_level_coin);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
});
|
||||
ui.btn_vip.SetClick(() =>
|
||||
{
|
||||
if (GameHelper.GetVipLevel() >= 3)
|
||||
{
|
||||
DataMgr.LevelUnlockList.Value.Add(level_);
|
||||
DataMgr.LevelUnlockList.Save();
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.UnlockLevelsuccess);
|
||||
CtrlCloseUI();
|
||||
}
|
||||
else
|
||||
{
|
||||
uiCtrlDispatcher.Dispatch(UICtrlMsg.VipClubViewUI_Open, 2);
|
||||
}
|
||||
TrackKit.SendEvent(ADEventTrack.Special, ADEventTrack.Property.vip_level_sub);
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
ui.btn_close.SetClick(() =>
|
||||
{
|
||||
GameHelper.SetLevel(GameHelper.GetLevel() + 1);
|
||||
if (UIManager.Instance.IsExistUI(UIConst.NewEndUI))
|
||||
{
|
||||
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.NewEndUI_Close);
|
||||
}
|
||||
else
|
||||
{
|
||||
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.OpenGameUI_Open);
|
||||
}
|
||||
|
||||
CtrlCloseUI();
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -193,6 +193,8 @@ namespace BallKingdomCrush
|
||||
//初始化页面逻辑
|
||||
private void InitView()
|
||||
{
|
||||
ui.viplevel.selectedIndex = GameHelper.GetVipLevel();
|
||||
|
||||
ui.btn_week.text_price.text = GameHelper.getPrice((decimal)vip_list[0].DiscountPrice);
|
||||
ui.btn_month.text_price.text = GameHelper.getPrice((decimal)vip_list[1].DiscountPrice);
|
||||
ui.btn_year.text_price.text = GameHelper.getPrice((decimal)vip_list[2].DiscountPrice);
|
||||
|
||||
@@ -386,6 +386,24 @@ public class PurchasingManager
|
||||
{ IAPPayManager.PRODUCT_VIP_MONTH, "1" },
|
||||
{ IAPPayManager.PRODUCT_VIP_YEAR, "2" },
|
||||
};
|
||||
|
||||
public static void SetShopMapValue()
|
||||
{
|
||||
var list = ConfigSystem.GetConfig<Paidcoins>();
|
||||
if (list is not { Count: > 0 }) return;
|
||||
foreach (var paidcoin in list)
|
||||
{
|
||||
if (string.IsNullOrEmpty(paidcoin.SKU))
|
||||
continue;
|
||||
|
||||
if (_shopProductMap.ContainsKey(paidcoin.SKU))
|
||||
{
|
||||
_shopProductMap[paidcoin.SKU] = (paidcoin.id - 1).ToString();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static void SendEventClickByName(string name, string type)
|
||||
|
||||
@@ -150,7 +150,8 @@ namespace BallKingdomCrush
|
||||
var organicConfig = ConfigLoader.Instance.GetConfig<List<TOrganic>>();
|
||||
if (organicConfig != null)
|
||||
{
|
||||
return organicConfig.Cast<T>().ToList();
|
||||
var json = Newtonsoft.Json.JsonConvert.SerializeObject(organicConfig);
|
||||
return Newtonsoft.Json.JsonConvert.DeserializeObject<List<T>>(json);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -166,7 +167,29 @@ namespace BallKingdomCrush
|
||||
{
|
||||
return GetConfigWithOrganicFallback<SecretAlbums, SecretAlbums_A>();
|
||||
}
|
||||
public static List<FreeImageLibrary> GetFreeImageConfig()
|
||||
{
|
||||
return GetConfigWithOrganicFallback<FreeImageLibrary, FreeImageLibrary_A>();
|
||||
}
|
||||
public static List<ADImageLibrary> GetADImageConfig()
|
||||
{
|
||||
return GetConfigWithOrganicFallback<ADImageLibrary, ADImageLibrary_A>();
|
||||
}
|
||||
|
||||
public static List<SpecialImageLibrary> GetSpecialImageConfig()
|
||||
{
|
||||
return GetConfigWithOrganicFallback<SpecialImageLibrary, SpecialImageLibrary_A>();
|
||||
}
|
||||
|
||||
public static List<VIPImageLibrary> GetVIPImageConfig()
|
||||
{
|
||||
return GetConfigWithOrganicFallback<VIPImageLibrary, VIPImageLibrary_A>();
|
||||
}
|
||||
|
||||
public static List<LevelUnlock> GetLevelUnlockConfig()
|
||||
{
|
||||
return GetConfigWithOrganicFallback<LevelUnlock, LevelUnlock_A>();
|
||||
}
|
||||
|
||||
|
||||
public override void Dispose()
|
||||
|
||||
@@ -61,7 +61,7 @@ namespace BallKingdomCrush {
|
||||
{
|
||||
Debug.Log($"loginData.CdnURL======={loginData.CdnURL}");
|
||||
// AB上传 BI
|
||||
BIManager.Instance.TrackABConfig(loginData.IsMagic ? 30 : 15);
|
||||
// BIManager.Instance.TrackABConfig(loginData.IsMagic ? 30 : 15);
|
||||
|
||||
// loginData.CdnURL = "https://asserts.minskyfun.top";
|
||||
|
||||
|
||||
@@ -142,13 +142,13 @@ namespace BallKingdomCrush
|
||||
private static void LoadInterstitial()
|
||||
{
|
||||
MaxSdk.LoadInterstitial(interstitialADUnitID);
|
||||
BIManager.Instance.TrackAdEvent(BIEvent.AD_REQUEST, "Interstitial");
|
||||
// BIManager.Instance.TrackAdEvent(BIEvent.AD_REQUEST, "Interstitial");
|
||||
}
|
||||
|
||||
private static void OnInterstitialLoadedEvent(string adUnitId, MaxSdkBase.AdInfo adInfo)
|
||||
{
|
||||
retryAttemptInterstitial = 0;
|
||||
BIManager.Instance.TrackAdEvent(BIEvent.AD_INVENTORY, "Interstitial", adInfo.Placement, adInfo.NetworkName);
|
||||
// BIManager.Instance.TrackAdEvent(BIEvent.AD_INVENTORY, "Interstitial", adInfo.Placement, adInfo.NetworkName);
|
||||
}
|
||||
|
||||
private static void OnInterstitialLoadFailedEvent(string adUnitId, MaxSdkBase.ErrorInfo errorInfo)
|
||||
@@ -161,8 +161,8 @@ namespace BallKingdomCrush
|
||||
|
||||
private static void OnInterstitialDisplayedEvent(string adUnitId, MaxSdkBase.AdInfo adInfo)
|
||||
{
|
||||
BIManager.Instance.TrackAdEvent(BIEvent.AD_IMP, "Interstitial", adInfo.Placement, adInfo.NetworkName,
|
||||
adInfo.Revenue, _placement);
|
||||
// BIManager.Instance.TrackAdEvent(BIEvent.AD_IMP, "Interstitial", adInfo.Placement, adInfo.NetworkName,
|
||||
// adInfo.Revenue, _placement);
|
||||
}
|
||||
|
||||
private static void OnInterstitialAdFailedToDisplayEvent(string adUnitId, MaxSdkBase.ErrorInfo errorInfo,
|
||||
@@ -173,7 +173,7 @@ namespace BallKingdomCrush
|
||||
|
||||
private static void OnInterstitialClickedEvent(string adUnitId, MaxSdkBase.AdInfo adInfo)
|
||||
{
|
||||
BIManager.Instance.TrackAdEvent(BIEvent.AD_CLICK, "Interstitial", adInfo.Placement, adInfo.NetworkName);
|
||||
// BIManager.Instance.TrackAdEvent(BIEvent.AD_CLICK, "Interstitial", adInfo.Placement, adInfo.NetworkName);
|
||||
}
|
||||
|
||||
private static void OnInterstitialHiddenEvent(string adUnitId, MaxSdkBase.AdInfo adInfo)
|
||||
@@ -213,6 +213,12 @@ namespace BallKingdomCrush
|
||||
}, ()=>
|
||||
{
|
||||
Debug.Log($"激励广告关闭");
|
||||
if (GameHelper.IsGiftSwitch() && !SaveData.GetSaveObject().is_get_removead && (UnityEngine.Random.Range(0, 100) < GameHelper.GetCommonModel().rewardinsertion))
|
||||
{
|
||||
TrackKit.SendEvent(ADEventTrack.AD_Event, ADEventTrack.Property.afterRewardAdShow);
|
||||
|
||||
GameHelper.ShowInterstitial("AfterReward");
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
@@ -284,7 +290,7 @@ namespace BallKingdomCrush
|
||||
private static void LoadRewardedAd()
|
||||
{
|
||||
MaxSdk.LoadRewardedAd(rewardedADUnitID);
|
||||
BIManager.Instance.TrackAdEvent(BIEvent.AD_REQUEST, "RewardedVideo");
|
||||
// BIManager.Instance.TrackAdEvent(BIEvent.AD_REQUEST, "RewardedVideo");
|
||||
}
|
||||
|
||||
private static void OnInterstitialAdRevenueEvent(string adUnitId, MaxSdkBase.AdInfo adInfo)
|
||||
@@ -391,8 +397,8 @@ namespace BallKingdomCrush
|
||||
retryAttempt = 0;
|
||||
TrackKit.SendEvent(ADEventTrack.AD_Event, $"{ADEventTrack.Property.ad_load_code}Succeed");
|
||||
|
||||
BIManager.Instance.TrackAdEvent(BIEvent.AD_INVENTORY, "RewardedVideo", adInfo.Placement,
|
||||
adInfo.NetworkName);
|
||||
// BIManager.Instance.TrackAdEvent(BIEvent.AD_INVENTORY, "RewardedVideo", adInfo.Placement,
|
||||
// adInfo.NetworkName);
|
||||
}
|
||||
|
||||
private static void OnRewardedAdLoadFailedEvent(string adUnitId, MaxSdkBase.ErrorInfo errorInfo)
|
||||
@@ -407,8 +413,8 @@ namespace BallKingdomCrush
|
||||
private static void OnRewardedAdDisplayedEvent(string adUnitId, MaxSdkBase.AdInfo adInfo)
|
||||
{
|
||||
TrackKit.SendEvent(ADEventTrack.AD_Event, $"{ADEventTrack.Property.ad_show_code}Succeed");
|
||||
BIManager.Instance.TrackAdEvent(BIEvent.AD_IMP, "RewardedVideo", adInfo.Placement, adInfo.NetworkName,
|
||||
adInfo.Revenue, _placement);
|
||||
// BIManager.Instance.TrackAdEvent(BIEvent.AD_IMP, "RewardedVideo", adInfo.Placement, adInfo.NetworkName,
|
||||
// adInfo.Revenue, _placement);
|
||||
}
|
||||
|
||||
private static void OnRewardedAdFailedToDisplayEvent(string adUnitId, MaxSdkBase.ErrorInfo errorInfo,
|
||||
@@ -421,7 +427,7 @@ namespace BallKingdomCrush
|
||||
|
||||
private static void OnRewardedAdClickedEvent(string adUnitId, MaxSdkBase.AdInfo adInfo)
|
||||
{
|
||||
BIManager.Instance.TrackAdEvent(BIEvent.AD_CLICK, "RewardedVideo", adInfo.Placement, adInfo.NetworkName);
|
||||
// BIManager.Instance.TrackAdEvent(BIEvent.AD_CLICK, "RewardedVideo", adInfo.Placement, adInfo.NetworkName);
|
||||
}
|
||||
|
||||
private static void OnRewardedAdHiddenEvent(string adUnitId, MaxSdkBase.AdInfo adInfo)
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 54ee81bee93f0ec4892bf47c7e311b27
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a29a27f240f983848b74be6f96172809
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,18 @@
|
||||
// WARNING: Do not modify! Generated file.
|
||||
|
||||
namespace UnityEngine.Purchasing.Security {
|
||||
public class GooglePlayTangle
|
||||
{
|
||||
private static byte[] data = System.Convert.FromBase64String("oItBKoF1TJsvsNyC2XcQpwjj4DW6+5bq/jyqe7OcVq5T2Qy7fOmOh/OOD4MI5JJtmH+brM7+CkVFRXy/i0gylnSECNznWIx7Hv3L6tDNuHtNzsDP/03Oxc1Nzs7PareFOePy+GtR+tBa2oT2PJenjj47A6vrRZvF0VpSP9jcPZgJd5lyVGrEnNpQKNP/Tc7t/8LJxuVJh0k4ws7OzsrPzHSNkDPHIpqdduhePEYNmSwaunerYOKHpDmi/jmLGsUhFFzKBslfMToITxkLFunkB2TJxSflLatZwqwWJzDPHHyWlIUpRdcwNLM5XgYBiHLOdzrcMVSapCyzuSTSrozKIqM9dMEzVDZTcnKji6XeVkamyXe53q6bV7g5YzShIak27s3Mzs/O");
|
||||
private static int[] order = new int[] { 13,9,12,5,9,5,10,13,11,12,12,12,12,13,14 };
|
||||
private static int key = 207;
|
||||
|
||||
public static readonly bool IsPopulated = true;
|
||||
|
||||
public static byte[] Data() {
|
||||
if (IsPopulated == false)
|
||||
return null;
|
||||
return Obfuscator.DeObfuscate(data, order, key);
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 39c8d648f664d534b85655b5c4317090
|
||||
guid: b01b28c44da522948a3eb8fbb51512ad
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
Reference in New Issue
Block a user