fix:1、修复bug。 2、1.0.8版本提审
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user