fix:1、添加_A表的读取方式
This commit is contained in:
@@ -1,68 +1,70 @@
|
|||||||
using SGModule.ConfigLoader;
|
using SGModule.ConfigLoader;
|
||||||
|
|
||||||
namespace RedHotRoast
|
namespace RedHotRoast
|
||||||
{
|
{
|
||||||
[ConfigKey("Common", false)]
|
[ConfigKey("Common", false)]
|
||||||
public class CommonModel
|
public class CommonModel
|
||||||
{
|
{
|
||||||
public int InitialNum;
|
public int InitialNum;
|
||||||
public int[] inlineLoginDown;
|
public int[] inlineLoginDown;
|
||||||
public int inlineMin;
|
public int inlineMin;
|
||||||
public int Purchaseprops;
|
public int Purchaseprops;
|
||||||
public int rewardrate;
|
public int rewardrate;
|
||||||
public int RevivalCoins;
|
public int RevivalCoins;
|
||||||
public int[] wheelTimes;
|
public int[] wheelTimes;
|
||||||
public float Passportgift;
|
public float Passportgift;
|
||||||
public float Passportgift2;
|
public float Passportgift2;
|
||||||
public float addspace;
|
public float addspace;
|
||||||
public float addspace2;
|
public float addspace2;
|
||||||
public int playtimes;
|
public int playtimes;
|
||||||
public int interstitialtype;
|
public int interstitialtype;
|
||||||
public int lobbyrewrdtime;
|
public int lobbyrewrdtime;
|
||||||
public int roomrewardrate;
|
public int roomrewardrate;
|
||||||
public int Activetimes;
|
public int Activetimes;
|
||||||
public int adrate;
|
public int adrate;
|
||||||
public int roomrate;
|
public int roomrate;
|
||||||
public float afSendLimit;
|
public float afSendLimit;
|
||||||
public float afSendNum;
|
public float afSendNum;
|
||||||
public int rewardinsertion;
|
public int rewardinsertion;
|
||||||
public int exchangeCD = 120;
|
public int exchangeCD = 120;
|
||||||
|
|
||||||
public int AddSpaceLevel;
|
public int AddSpaceLevel;
|
||||||
|
|
||||||
public int RemoveADsPackDuration;
|
public int RemoveADsPackDuration;
|
||||||
public int RemoveADsPackPopup;
|
public int RemoveADsPackPopup;
|
||||||
|
|
||||||
public string contactUs;
|
public string contactUs;
|
||||||
public int[] UnlockSecret;
|
public int[] UnlockSecret;
|
||||||
|
|
||||||
public int[] UnlockLive;
|
public int[] UnlockLive;
|
||||||
public int Live;
|
public int Live;
|
||||||
public int Secret;
|
public int Secret;
|
||||||
public int Assitant;
|
public int Assitant;
|
||||||
public int LivePreview;
|
public int LivePreview;
|
||||||
public int SecretPreview;
|
public int SecretPreview;
|
||||||
public int AssitantPreview;
|
public int AssitantPreview;
|
||||||
public int HomeGuideRate;
|
public int HomeGuideRate;
|
||||||
public int roomGuideRate;
|
public int roomGuideRate;
|
||||||
public int VIPGuide;
|
public int VIPGuide;
|
||||||
public int VIPGuideRate;
|
public int VIPGuideRate;
|
||||||
public int HomeInterstitialAd;
|
public int HomeInterstitialAd;
|
||||||
public int FreeClaims;
|
public int FreeClaims;
|
||||||
public int TurnOffPackRate;
|
public int TurnOffPackRate;
|
||||||
public int TurnOffRewardsRate;
|
public int TurnOffRewardsRate;
|
||||||
public int TurnOffRewardsCD;
|
public int TurnOffRewardsCD;
|
||||||
public int TurnOffRewardslimit;
|
public int TurnOffRewardslimit;
|
||||||
public int PayRate;
|
public int PayRate;
|
||||||
public int FreeMessages;
|
public int FreeMessages;
|
||||||
public int[] CoinsAccess;
|
public int[] CoinsAccess;
|
||||||
public int AdAccess;
|
public int AdAccess;
|
||||||
public int UnlockAIAssistant;
|
public int UnlockAIAssistant;
|
||||||
public int ClearRAM;
|
public int ClearRAM;
|
||||||
public int CoinsDownload;
|
public int CoinsDownload;
|
||||||
public string ResVersion;
|
public string ResVersion;
|
||||||
public int MultiModal;
|
public int MultiModal;
|
||||||
public int[] eggReward;
|
public int[] eggReward;
|
||||||
public int eggCD;
|
public int eggCD;
|
||||||
}
|
public string ResVersion1;
|
||||||
}
|
public int IsOrganic;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
+1011
-1011
File diff suppressed because it is too large
Load Diff
@@ -1,299 +1,299 @@
|
|||||||
|
|
||||||
using FGUI.ZM_Common_01;
|
using FGUI.ZM_Common_01;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using FairyGUI;
|
using FairyGUI;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using FGUI.LG_albums;
|
using FGUI.LG_albums;
|
||||||
using FGUI.LG_Common;
|
using FGUI.LG_Common;
|
||||||
using SGModule.DataStorage;
|
using SGModule.DataStorage;
|
||||||
using DG.Tweening;
|
using DG.Tweening;
|
||||||
using SGModule.Common.Extensions;
|
using SGModule.Common.Extensions;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using SGModule.NetKit;
|
using SGModule.NetKit;
|
||||||
namespace RedHotRoast
|
namespace RedHotRoast
|
||||||
{
|
{
|
||||||
public class AlbumDetailUI : BaseUI
|
public class AlbumDetailUI : BaseUI
|
||||||
{
|
{
|
||||||
private AlbumDetailUICtrl ctrl;
|
private AlbumDetailUICtrl ctrl;
|
||||||
private AlbumDetailModel model;
|
private AlbumDetailModel model;
|
||||||
private FGUI.LG_albums.com_albumsDetail ui;
|
private FGUI.LG_albums.com_albumsDetail ui;
|
||||||
|
|
||||||
public AlbumDetailUI(AlbumDetailUICtrl ctrl) : base(ctrl)
|
public AlbumDetailUI(AlbumDetailUICtrl ctrl) : base(ctrl)
|
||||||
{
|
{
|
||||||
uiName = UIConst.AlbumDetailUI;
|
uiName = UIConst.AlbumDetailUI;
|
||||||
this.ctrl = ctrl;
|
this.ctrl = ctrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void SetUIInfo(UIInfo uiInfo)
|
protected override void SetUIInfo(UIInfo uiInfo)
|
||||||
{
|
{
|
||||||
uiInfo.packageName = "LG_albums";
|
uiInfo.packageName = "LG_albums";
|
||||||
uiInfo.assetName = "com_albumsDetail";
|
uiInfo.assetName = "com_albumsDetail";
|
||||||
uiInfo.layerType = UILayerType.Popup;
|
uiInfo.layerType = UILayerType.Popup;
|
||||||
uiInfo.isNeedOpenAnim = false;
|
uiInfo.isNeedOpenAnim = false;
|
||||||
uiInfo.isNeedCloseAnim = false;
|
uiInfo.isNeedCloseAnim = false;
|
||||||
uiInfo.isNeedUIMask = true;
|
uiInfo.isNeedUIMask = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#region 生命周期
|
#region 生命周期
|
||||||
protected override void OnInit()
|
protected override void OnInit()
|
||||||
{
|
{
|
||||||
//model = ModuleManager.Instance.GetModel(ModelConst.AlbumDetailModel) as AlbumDetailModel;
|
//model = ModuleManager.Instance.GetModel(ModelConst.AlbumDetailModel) as AlbumDetailModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnClose()
|
protected override void OnClose()
|
||||||
{
|
{
|
||||||
if (loader != null && !loader.isDisposed && loader.texture != null)
|
if (loader != null && !loader.isDisposed && loader.texture != null)
|
||||||
{
|
{
|
||||||
loader.texture.Dispose();
|
loader.texture.Dispose();
|
||||||
loader.texture = null;
|
loader.texture = null;
|
||||||
}
|
}
|
||||||
loader = null;
|
loader = null;
|
||||||
|
|
||||||
if (new_index != -1)
|
if (new_index != -1)
|
||||||
{
|
{
|
||||||
GameDispatcher.Instance.Dispatch(GameMsg.UnlockAlbums, index);
|
GameDispatcher.Instance.Dispatch(GameMsg.UnlockAlbums, index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnBind()
|
protected override void OnBind()
|
||||||
{
|
{
|
||||||
ui = baseUI as FGUI.LG_albums.com_albumsDetail;
|
ui = baseUI as FGUI.LG_albums.com_albumsDetail;
|
||||||
}
|
}
|
||||||
private List<LevelUnlock> LevelData;
|
private List<LevelUnlock> LevelData;
|
||||||
private int new_index = -1;
|
private int new_index = -1;
|
||||||
private int index;
|
private int index;
|
||||||
|
|
||||||
private GLoader loader = new GLoader();
|
private GLoader loader = new GLoader();
|
||||||
protected override void OnOpenBefore(object args)
|
protected override void OnOpenBefore(object args)
|
||||||
{
|
{
|
||||||
index = (int)args;
|
index = (int)args;
|
||||||
Debug.Log(index);
|
Debug.Log(index);
|
||||||
ui.btn_close.SetClick(() =>
|
ui.btn_close.SetClick(() =>
|
||||||
{
|
{
|
||||||
CtrlCloseUI();
|
CtrlCloseUI();
|
||||||
});
|
});
|
||||||
LevelData = ConfigSystem.GetConfig<LevelUnlock>();
|
LevelData = ConfigSystem.GetLevelUnlockConfig();
|
||||||
// ui.list_.SetVirtual();
|
// ui.list_.SetVirtual();
|
||||||
// ui.list_.itemRenderer = RendererList;
|
// ui.list_.itemRenderer = RendererList;
|
||||||
// ui.list_.numItems = GameHelper.GetLevel() - 1;
|
// ui.list_.numItems = GameHelper.GetLevel() - 1;
|
||||||
// ui.list_.ScrollToView(new_index);
|
// ui.list_.ScrollToView(new_index);
|
||||||
|
|
||||||
RendererList();
|
RendererList();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnOpen(object args)
|
protected override void OnOpen(object args)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnHide()
|
protected override void OnHide()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnDisplay(object args)
|
protected override void OnDisplay(object args)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region 消息
|
#region 消息
|
||||||
protected override void AddListener()
|
protected override void AddListener()
|
||||||
{
|
{
|
||||||
GameDispatcher.Instance.AddListener(GameMsg.BuyVip, refrsh);
|
GameDispatcher.Instance.AddListener(GameMsg.BuyVip, refrsh);
|
||||||
}
|
}
|
||||||
protected override void RemoveListener()
|
protected override void RemoveListener()
|
||||||
{
|
{
|
||||||
GameDispatcher.Instance.RemoveListener(GameMsg.BuyVip, refrsh);
|
GameDispatcher.Instance.RemoveListener(GameMsg.BuyVip, refrsh);
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
//初始化页面逻辑
|
//初始化页面逻辑
|
||||||
private void refrsh(object a = null)
|
private void refrsh(object a = null)
|
||||||
{
|
{
|
||||||
DOVirtual.DelayedCall(0.5f, () =>
|
DOVirtual.DelayedCall(0.5f, () =>
|
||||||
{
|
{
|
||||||
// ui.list_.numItems = GameHelper.GetLevel() - 1;
|
// ui.list_.numItems = GameHelper.GetLevel() - 1;
|
||||||
RendererList();
|
RendererList();
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
// void RendererList(int index, GObject obj)
|
// void RendererList(int index, GObject obj)
|
||||||
void RendererList()
|
void RendererList()
|
||||||
{
|
{
|
||||||
|
|
||||||
item_albumsDetails item = (item_albumsDetails)ui.com_item;
|
item_albumsDetails item = (item_albumsDetails)ui.com_item;
|
||||||
|
|
||||||
loader = item.com_loader.GetChild("loader") as GLoader;
|
loader = item.com_loader.GetChild("loader") as GLoader;
|
||||||
|
|
||||||
// if (GameHelper.GetVipPrivilege(Subscription.VipLevel.As<int>()))
|
// if (GameHelper.GetVipPrivilege(Subscription.VipLevel.As<int>()))
|
||||||
// {
|
// {
|
||||||
// (item.btn_vip as btn_claim_2).have_vip.selectedIndex = 1;
|
// (item.btn_vip as btn_claim_2).have_vip.selectedIndex = 1;
|
||||||
|
|
||||||
// }
|
// }
|
||||||
// if (GameHelper.GetVipPrivilege(Subscription.SLVLevel.As<int>()))
|
// if (GameHelper.GetVipPrivilege(Subscription.SLVLevel.As<int>()))
|
||||||
// {
|
// {
|
||||||
// (item.btn_watch as btn_claim_1).have_vip.selectedIndex = 1;
|
// (item.btn_watch as btn_claim_1).have_vip.selectedIndex = 1;
|
||||||
|
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
var downloadCoinNum = ConfigSystem.GetCommonConf().CoinsDownload;
|
var downloadCoinNum = ConfigSystem.GetCommonConf().CoinsDownload;
|
||||||
var btn_down_coin = (FGUI.LG_Common.btn_unlock_1)item.btn_download_coin;
|
var btn_down_coin = (FGUI.LG_Common.btn_unlock_1)item.btn_download_coin;
|
||||||
btn_down_coin.title = downloadCoinNum.As<string>();
|
btn_down_coin.title = downloadCoinNum.As<string>();
|
||||||
btn_down_coin.down_load.selectedIndex = GameHelper.GetVipPrivilege(Subscription.FreeDownImage.As<int>()) ? 0 : 1;
|
btn_down_coin.down_load.selectedIndex = GameHelper.GetVipPrivilege(Subscription.FreeDownImage.As<int>()) ? 0 : 1;
|
||||||
|
|
||||||
|
|
||||||
if (GameHelper.GetVipPrivilege(Subscription.FreeDownImage.As<int>()))
|
if (GameHelper.GetVipPrivilege(Subscription.FreeDownImage.As<int>()))
|
||||||
{
|
{
|
||||||
(item.btn_download as FGUI.LG_Common.btn_claim).have_vip.selectedIndex = 1;
|
(item.btn_download as FGUI.LG_Common.btn_claim).have_vip.selectedIndex = 1;
|
||||||
item.is_vip.selectedIndex = 1;
|
item.is_vip.selectedIndex = 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
item.is_vip.selectedIndex = 0;
|
item.is_vip.selectedIndex = 0;
|
||||||
}
|
}
|
||||||
if (index < GameHelper.GetCommonModel().MultiModal - 1)
|
if (index < GameHelper.GetCommonModel().MultiModal - 1)
|
||||||
{
|
{
|
||||||
TextureHelper.SetImgLoader(item.com_loader.GetChild("loader") as GLoader, LevelData[index].Name, null, "LevelAlbums/", FolderNames.AlbumName);
|
TextureHelper.SetImgLoader(item.com_loader.GetChild("loader") as GLoader, LevelData[index].Name, null, "LevelAlbums/", FolderNames.AlbumName);
|
||||||
item.btn_download.SetClick(() =>
|
item.btn_download.SetClick(() =>
|
||||||
{
|
{
|
||||||
if (GameHelper.GetVipPrivilege(Subscription.FreeDownImage.As<int>()))
|
if (GameHelper.GetVipPrivilege(Subscription.FreeDownImage.As<int>()))
|
||||||
{
|
{
|
||||||
TextureHelper.SaveImageToAlbum(LevelData[index].Name, FolderNames.AlbumName);
|
TextureHelper.SaveImageToAlbum(LevelData[index].Name, FolderNames.AlbumName);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
GameHelper.ShowVideoAd("DownloadImage", isSuccess =>
|
GameHelper.ShowVideoAd("DownloadImage", isSuccess =>
|
||||||
{
|
{
|
||||||
if (isSuccess)
|
if (isSuccess)
|
||||||
{
|
{
|
||||||
TextureHelper.SaveImageToAlbum(LevelData[index].Name, FolderNames.AlbumName);
|
TextureHelper.SaveImageToAlbum(LevelData[index].Name, FolderNames.AlbumName);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
btn_down_coin.SetClick(() =>
|
btn_down_coin.SetClick(() =>
|
||||||
{
|
{
|
||||||
if (GameHelper.Get101() >= downloadCoinNum)
|
if (GameHelper.Get101() >= downloadCoinNum)
|
||||||
{
|
{
|
||||||
GameHelper.AddGold(-downloadCoinNum);
|
GameHelper.AddGold(-downloadCoinNum);
|
||||||
TextureHelper.SaveImageToAlbum(LevelData[index].Name, FolderNames.AlbumName);
|
TextureHelper.SaveImageToAlbum(LevelData[index].Name, FolderNames.AlbumName);
|
||||||
TrackKit.SendEvent(ADEventTrack.Coinsbuy, ADEventTrack.Property.download);
|
TrackKit.SendEvent(ADEventTrack.Coinsbuy, ADEventTrack.Property.download);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
GameHelper.ShowTips("no_enough_gold", true);
|
GameHelper.ShowTips("no_enough_gold", true);
|
||||||
|
|
||||||
uiCtrlDispatcher.Dispatch(UICtrlMsg.BuygoldUI_Open);
|
uiCtrlDispatcher.Dispatch(UICtrlMsg.BuygoldUI_Open);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Levelunlock levelunlock_ = DataMgr.LevelUnlockListNew.Value.FirstOrDefault(x => x.level_ == index + 1);
|
Levelunlock levelunlock_ = DataMgr.LevelUnlockListNew.Value.FirstOrDefault(x => x.level_ == index + 1);
|
||||||
string file_name = "";
|
string file_name = "";
|
||||||
if (levelunlock_ != null)
|
if (levelunlock_ != null)
|
||||||
{
|
{
|
||||||
if (levelunlock_.type == 0)
|
if (levelunlock_.type == 0)
|
||||||
{
|
{
|
||||||
if (levelunlock_.config_index >= ConfigSystem.GetConfig<FreeImageLibrary>().Count) levelunlock_.config_index = ConfigSystem.GetConfig<FreeImageLibrary>().Count - 1;
|
if (levelunlock_.config_index >= ConfigSystem.GetFreeImageConfig().Count) levelunlock_.config_index = ConfigSystem.GetFreeImageConfig().Count - 1;
|
||||||
FreeImageLibrary _leveldata = ConfigSystem.GetConfig<FreeImageLibrary>()[levelunlock_.config_index];
|
FreeImageLibrary _leveldata = ConfigSystem.GetFreeImageConfig()[levelunlock_.config_index];
|
||||||
TextureHelper.SetImgLoader(item.com_loader.GetChild("loader") as GLoader, _leveldata.Name, null, "LevelAlbums/", FolderNames.AlbumName);
|
TextureHelper.SetImgLoader(item.com_loader.GetChild("loader") as GLoader, _leveldata.Name, null, "LevelAlbums/", FolderNames.AlbumName);
|
||||||
file_name = _leveldata.Name;
|
file_name = _leveldata.Name;
|
||||||
}
|
}
|
||||||
else if (levelunlock_.type == 1)
|
else if (levelunlock_.type == 1)
|
||||||
{
|
{
|
||||||
if (levelunlock_.config_index >= ConfigSystem.GetConfig<ADImageLibrary>().Count) levelunlock_.config_index = ConfigSystem.GetConfig<ADImageLibrary>().Count - 1;
|
if (levelunlock_.config_index >= ConfigSystem.GetADImageConfig().Count) levelunlock_.config_index = ConfigSystem.GetADImageConfig().Count - 1;
|
||||||
ADImageLibrary _leveldata = ConfigSystem.GetConfig<ADImageLibrary>()[levelunlock_.config_index];
|
ADImageLibrary _leveldata = ConfigSystem.GetADImageConfig()[levelunlock_.config_index];
|
||||||
TextureHelper.SetImgLoader(item.com_loader.GetChild("loader") as GLoader, _leveldata.Name, null, "LevelAlbums/", FolderNames.AlbumName);
|
TextureHelper.SetImgLoader(item.com_loader.GetChild("loader") as GLoader, _leveldata.Name, null, "LevelAlbums/", FolderNames.AlbumName);
|
||||||
file_name = _leveldata.Name;
|
file_name = _leveldata.Name;
|
||||||
}
|
}
|
||||||
else if (levelunlock_.type == 2)
|
else if (levelunlock_.type == 2)
|
||||||
{
|
{
|
||||||
if (levelunlock_.config_index >= ConfigSystem.GetConfig<SpecialImageLibrary>().Count) levelunlock_.config_index = ConfigSystem.GetConfig<SpecialImageLibrary>().Count - 1;
|
if (levelunlock_.config_index >= ConfigSystem.GetSpecialImageConfig().Count) levelunlock_.config_index = ConfigSystem.GetSpecialImageConfig().Count - 1;
|
||||||
SpecialImageLibrary _leveldata = ConfigSystem.GetConfig<SpecialImageLibrary>()[levelunlock_.config_index];
|
SpecialImageLibrary _leveldata = ConfigSystem.GetSpecialImageConfig()[levelunlock_.config_index];
|
||||||
TextureHelper.SetImgLoader(item.com_loader.GetChild("loader") as GLoader, _leveldata.Name, null, "LevelAlbums/", FolderNames.AlbumName);
|
TextureHelper.SetImgLoader(item.com_loader.GetChild("loader") as GLoader, _leveldata.Name, null, "LevelAlbums/", FolderNames.AlbumName);
|
||||||
file_name = _leveldata.Name;
|
file_name = _leveldata.Name;
|
||||||
}
|
}
|
||||||
else if (levelunlock_.type == 3)
|
else if (levelunlock_.type == 3)
|
||||||
{
|
{
|
||||||
if (levelunlock_.config_index >= ConfigSystem.GetConfig<VIPImageLibrary>().Count) levelunlock_.config_index = ConfigSystem.GetConfig<VIPImageLibrary>().Count - 1;
|
if (levelunlock_.config_index >= ConfigSystem.GetVIPImageConfig().Count) levelunlock_.config_index = ConfigSystem.GetVIPImageConfig().Count - 1;
|
||||||
VIPImageLibrary _leveldata = ConfigSystem.GetConfig<VIPImageLibrary>()[levelunlock_.config_index];
|
VIPImageLibrary _leveldata = ConfigSystem.GetVIPImageConfig()[levelunlock_.config_index];
|
||||||
TextureHelper.SetImgLoader(item.com_loader.GetChild("loader") as GLoader, _leveldata.Name, null, "LevelAlbums/", FolderNames.AlbumName);
|
TextureHelper.SetImgLoader(item.com_loader.GetChild("loader") as GLoader, _leveldata.Name, null, "LevelAlbums/", FolderNames.AlbumName);
|
||||||
file_name = _leveldata.Name;
|
file_name = _leveldata.Name;
|
||||||
}
|
}
|
||||||
item.btn_download.SetClick(() =>
|
item.btn_download.SetClick(() =>
|
||||||
{
|
{
|
||||||
if (GameHelper.GetVipPrivilege(Subscription.FreeDownImage.As<int>()))
|
if (GameHelper.GetVipPrivilege(Subscription.FreeDownImage.As<int>()))
|
||||||
{
|
{
|
||||||
TextureHelper.SaveImageToAlbum(file_name, FolderNames.AlbumName);
|
TextureHelper.SaveImageToAlbum(file_name, FolderNames.AlbumName);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
GameHelper.ShowVideoAd("DownloadImage", isSuccess =>
|
GameHelper.ShowVideoAd("DownloadImage", isSuccess =>
|
||||||
{
|
{
|
||||||
if (isSuccess)
|
if (isSuccess)
|
||||||
{
|
{
|
||||||
TextureHelper.SaveImageToAlbum(file_name, FolderNames.AlbumName);
|
TextureHelper.SaveImageToAlbum(file_name, FolderNames.AlbumName);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
btn_down_coin.SetClick(() =>
|
btn_down_coin.SetClick(() =>
|
||||||
{
|
{
|
||||||
if (GameHelper.Get101() >= downloadCoinNum)
|
if (GameHelper.Get101() >= downloadCoinNum)
|
||||||
{
|
{
|
||||||
GameHelper.AddGold(-downloadCoinNum);
|
GameHelper.AddGold(-downloadCoinNum);
|
||||||
TextureHelper.SaveImageToAlbum(file_name, FolderNames.AlbumName);
|
TextureHelper.SaveImageToAlbum(file_name, FolderNames.AlbumName);
|
||||||
TrackKit.SendEvent(ADEventTrack.Coinsbuy, ADEventTrack.Property.download);
|
TrackKit.SendEvent(ADEventTrack.Coinsbuy, ADEventTrack.Property.download);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
GameHelper.ShowTips("no_enough_gold", true);
|
GameHelper.ShowTips("no_enough_gold", true);
|
||||||
|
|
||||||
uiCtrlDispatcher.Dispatch(UICtrlMsg.BuygoldUI_Open);
|
uiCtrlDispatcher.Dispatch(UICtrlMsg.BuygoldUI_Open);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
TextureHelper.SetImgLoader(item.com_loader.GetChild("loader") as GLoader, LevelData[index].Name, null, "LevelAlbums/", FolderNames.AlbumName);
|
TextureHelper.SetImgLoader(item.com_loader.GetChild("loader") as GLoader, LevelData[index].Name, null, "LevelAlbums/", FolderNames.AlbumName);
|
||||||
item.btn_download.SetClick(() =>
|
item.btn_download.SetClick(() =>
|
||||||
{
|
{
|
||||||
if (GameHelper.GetVipPrivilege(Subscription.FreeDownImage.As<int>()))
|
if (GameHelper.GetVipPrivilege(Subscription.FreeDownImage.As<int>()))
|
||||||
{
|
{
|
||||||
TextureHelper.SaveImageToAlbum(LevelData[index].Name, FolderNames.AlbumName);
|
TextureHelper.SaveImageToAlbum(LevelData[index].Name, FolderNames.AlbumName);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
GameHelper.ShowVideoAd("DownloadImage", isSuccess =>
|
GameHelper.ShowVideoAd("DownloadImage", isSuccess =>
|
||||||
{
|
{
|
||||||
if (isSuccess)
|
if (isSuccess)
|
||||||
{
|
{
|
||||||
TextureHelper.SaveImageToAlbum(LevelData[index].Name, FolderNames.AlbumName);
|
TextureHelper.SaveImageToAlbum(LevelData[index].Name, FolderNames.AlbumName);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
btn_down_coin.SetClick(() =>
|
btn_down_coin.SetClick(() =>
|
||||||
{
|
{
|
||||||
if (GameHelper.Get101() >= downloadCoinNum)
|
if (GameHelper.Get101() >= downloadCoinNum)
|
||||||
{
|
{
|
||||||
GameHelper.AddGold(-downloadCoinNum);
|
GameHelper.AddGold(-downloadCoinNum);
|
||||||
TextureHelper.SaveImageToAlbum(LevelData[index].Name, FolderNames.AlbumName);
|
TextureHelper.SaveImageToAlbum(LevelData[index].Name, FolderNames.AlbumName);
|
||||||
TrackKit.SendEvent(ADEventTrack.Coinsbuy, ADEventTrack.Property.download);
|
TrackKit.SendEvent(ADEventTrack.Coinsbuy, ADEventTrack.Property.download);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
GameHelper.ShowTips("no_enough_gold", true);
|
GameHelper.ShowTips("no_enough_gold", true);
|
||||||
|
|
||||||
uiCtrlDispatcher.Dispatch(UICtrlMsg.BuygoldUI_Open);
|
uiCtrlDispatcher.Dispatch(UICtrlMsg.BuygoldUI_Open);
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,494 +1,494 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using DG.Tweening;
|
using DG.Tweening;
|
||||||
using FairyGUI;
|
using FairyGUI;
|
||||||
using FGUI.LG_albums;
|
using FGUI.LG_albums;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using System;
|
using System;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
namespace RedHotRoast
|
namespace RedHotRoast
|
||||||
|
|
||||||
{
|
{
|
||||||
public class AlubumUI : BaseUI
|
public class AlubumUI : BaseUI
|
||||||
{
|
{
|
||||||
private AlubumUICtrl ctrl;
|
private AlubumUICtrl ctrl;
|
||||||
private AlubumModel model;
|
private AlubumModel model;
|
||||||
private com_albums ui;
|
private com_albums ui;
|
||||||
private long[] UpDatatime;
|
private long[] UpDatatime;
|
||||||
|
|
||||||
public AlubumUI(AlubumUICtrl ctrl) : base(ctrl)
|
public AlubumUI(AlubumUICtrl ctrl) : base(ctrl)
|
||||||
{
|
{
|
||||||
uiName = UIConst.AlubumUI;
|
uiName = UIConst.AlubumUI;
|
||||||
this.ctrl = ctrl;
|
this.ctrl = ctrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void SetUIInfo(UIInfo uiInfo)
|
protected override void SetUIInfo(UIInfo uiInfo)
|
||||||
{
|
{
|
||||||
uiInfo.packageName = "LG_albums";
|
uiInfo.packageName = "LG_albums";
|
||||||
uiInfo.assetName = "com_albums";
|
uiInfo.assetName = "com_albums";
|
||||||
uiInfo.layerType = UILayerType.Popup;
|
uiInfo.layerType = UILayerType.Popup;
|
||||||
uiInfo.isNeedOpenAnim = false;
|
uiInfo.isNeedOpenAnim = false;
|
||||||
uiInfo.isNeedCloseAnim = false;
|
uiInfo.isNeedCloseAnim = false;
|
||||||
uiInfo.isNeedUIMask = true;
|
uiInfo.isNeedUIMask = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//初始化页面逻辑
|
//初始化页面逻辑
|
||||||
private void InitView(object a = null)
|
private void InitView(object a = null)
|
||||||
{
|
{
|
||||||
UpDatatime = new long[LevelData.Count];
|
UpDatatime = new long[LevelData.Count];
|
||||||
ImageName = new string[LevelData.Count];
|
ImageName = new string[LevelData.Count];
|
||||||
ui.list_albums.itemRenderer = RendererList;
|
ui.list_albums.itemRenderer = RendererList;
|
||||||
ui.list_albums.numItems = LevelData.Count;
|
ui.list_albums.numItems = LevelData.Count;
|
||||||
|
|
||||||
InitScroll();
|
InitScroll();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetItemData(object obj = null)
|
private void SetItemData(object obj = null)
|
||||||
{
|
{
|
||||||
UpDatatime[(int)obj] = 0;
|
UpDatatime[(int)obj] = 0;
|
||||||
ui.list_albums.RefreshVirtualList();
|
ui.list_albums.RefreshVirtualList();
|
||||||
}
|
}
|
||||||
|
|
||||||
#region 生命周期
|
#region 生命周期
|
||||||
|
|
||||||
protected override void OnInit()
|
protected override void OnInit()
|
||||||
{
|
{
|
||||||
GLoaderPool.Instance.Init(null, 24, 312, 310);
|
GLoaderPool.Instance.Init(null, 24, 312, 310);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnClose()
|
protected override void OnClose()
|
||||||
{
|
{
|
||||||
foreach (var t in loader_list)
|
foreach (var t in loader_list)
|
||||||
if (t != null && !t.isDisposed && t.texture != null)
|
if (t != null && !t.isDisposed && t.texture != null)
|
||||||
{
|
{
|
||||||
t.texture.Dispose();
|
t.texture.Dispose();
|
||||||
t.texture = null;
|
t.texture = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 1. 解除 UI 对 Loader 的引用
|
// 1. 解除 UI 对 Loader 的引用
|
||||||
for (var i = 0; i < ui.list_albums.numChildren; i++)
|
for (var i = 0; i < ui.list_albums.numChildren; i++)
|
||||||
{
|
{
|
||||||
var item = ui.list_albums.GetChildAt(i) as item_albums;
|
var item = ui.list_albums.GetChildAt(i) as item_albums;
|
||||||
if (item != null && item.com_loader.loader != null) item.com_loader.loader = null; // 清掉 GLoader 引用
|
if (item != null && item.com_loader.loader != null) item.com_loader.loader = null; // 清掉 GLoader 引用
|
||||||
}
|
}
|
||||||
|
|
||||||
activeLoaders.Clear();
|
activeLoaders.Clear();
|
||||||
_fileIsExist.Clear();
|
_fileIsExist.Clear();
|
||||||
|
|
||||||
GLoaderPool.Instance.DisposeAll();
|
GLoaderPool.Instance.DisposeAll();
|
||||||
|
|
||||||
TextureHelper.ClearMaterialPool();
|
TextureHelper.ClearMaterialPool();
|
||||||
|
|
||||||
// 强制卸载未使用的资源
|
// 强制卸载未使用的资源
|
||||||
Resources.UnloadUnusedAssets();
|
Resources.UnloadUnusedAssets();
|
||||||
MemoryManager.CleanMemoryMonitor();
|
MemoryManager.CleanMemoryMonitor();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnBind()
|
protected override void OnBind()
|
||||||
{
|
{
|
||||||
ui = baseUI as com_albums;
|
ui = baseUI as com_albums;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<LevelUnlock> LevelData;
|
private List<LevelUnlock> LevelData;
|
||||||
|
|
||||||
private readonly List<GLoader> loader_list = new();
|
private readonly List<GLoader> loader_list = new();
|
||||||
public SmartInvoker invoker;
|
public SmartInvoker invoker;
|
||||||
protected override void OnOpenBefore(object args)
|
protected override void OnOpenBefore(object args)
|
||||||
{
|
{
|
||||||
invoker = new SmartInvoker(() =>
|
invoker = new SmartInvoker(() =>
|
||||||
{
|
{
|
||||||
for (int i = 0; i < UpDatatime.Length; i++)
|
for (int i = 0; i < UpDatatime.Length; i++)
|
||||||
{
|
{
|
||||||
UpDatatime[i] = 0;
|
UpDatatime[i] = 0;
|
||||||
// ImageName[i] = "";
|
// ImageName[i] = "";
|
||||||
}
|
}
|
||||||
ui.list_albums.RefreshVirtualList();
|
ui.list_albums.RefreshVirtualList();
|
||||||
}, TimeSpan.FromSeconds(0.2f));
|
}, TimeSpan.FromSeconds(0.2f));
|
||||||
|
|
||||||
LevelData = ConfigSystem.GetConfig<LevelUnlock>();
|
LevelData = ConfigSystem.GetLevelUnlockConfig();
|
||||||
ui.list_albums.SetVirtual();
|
ui.list_albums.SetVirtual();
|
||||||
ui.btn_close1.SetClick(() => { CtrlCloseUI(); });
|
ui.btn_close1.SetClick(() => { CtrlCloseUI(); });
|
||||||
InitView();
|
InitView();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private const int MaxVisibleCount = 18; // 一屏显示18个
|
private const int MaxVisibleCount = 18; // 一屏显示18个
|
||||||
private const int PreloadCount = 3; // 上下各预加载一屏
|
private const int PreloadCount = 3; // 上下各预加载一屏
|
||||||
private readonly Dictionary<int, GLoader> activeLoaders = new();
|
private readonly Dictionary<int, GLoader> activeLoaders = new();
|
||||||
private readonly Dictionary<int, bool> _fileIsExist = new();
|
private readonly Dictionary<int, bool> _fileIsExist = new();
|
||||||
|
|
||||||
private Throttle _throttle;
|
private Throttle _throttle;
|
||||||
|
|
||||||
private void InitScroll()
|
private void InitScroll()
|
||||||
{
|
{
|
||||||
// ui.list_albums.scrollPane.onScroll.Add(OnScrollUpdate);
|
// ui.list_albums.scrollPane.onScroll.Add(OnScrollUpdate);
|
||||||
ui.list_albums.scrollPane.onScrollEnd.Add(OnScrollEndCB); // 保留结束时的整理
|
ui.list_albums.scrollPane.onScrollEnd.Add(OnScrollEndCB); // 保留结束时的整理
|
||||||
|
|
||||||
OnScrollEnd();
|
OnScrollEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void OnScrollEndCB()
|
private void OnScrollEndCB()
|
||||||
{
|
{
|
||||||
// UpdateVisibleAndPreload();
|
// UpdateVisibleAndPreload();
|
||||||
|
|
||||||
OnScrollEnd();
|
OnScrollEnd();
|
||||||
|
|
||||||
// Debug.Log("更新一次");
|
// Debug.Log("更新一次");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateVisibleAndPreload()
|
private void UpdateVisibleAndPreload()
|
||||||
{
|
{
|
||||||
// Debug.Log("[UpdateVisibleAndPreload]--------111111--------- ");
|
// Debug.Log("[UpdateVisibleAndPreload]--------111111--------- ");
|
||||||
// if (LevelData == null || LevelData.Count == 0) return;
|
// if (LevelData == null || LevelData.Count == 0) return;
|
||||||
|
|
||||||
// var firstVisibleIndex = ui.list_albums.GetFirstChildInView();
|
// var firstVisibleIndex = ui.list_albums.GetFirstChildInView();
|
||||||
// var lastVisibleIndex = Mathf.Min(firstVisibleIndex + MaxVisibleCount - 1, ui.list_albums.numItems - 1);
|
// var lastVisibleIndex = Mathf.Min(firstVisibleIndex + MaxVisibleCount - 1, ui.list_albums.numItems - 1);
|
||||||
|
|
||||||
// var startIndex = Mathf.Max(0, firstVisibleIndex - PreloadCount);
|
// var startIndex = Mathf.Max(0, firstVisibleIndex - PreloadCount);
|
||||||
// var endIndex = Mathf.Min(ui.list_albums.numItems - 1, lastVisibleIndex + PreloadCount);
|
// var endIndex = Mathf.Min(ui.list_albums.numItems - 1, lastVisibleIndex + PreloadCount);
|
||||||
|
|
||||||
// // 回收超出范围 loader
|
// // 回收超出范围 loader
|
||||||
// var keysToRemove = new List<int>();
|
// var keysToRemove = new List<int>();
|
||||||
// foreach (var kv in activeLoaders)
|
// foreach (var kv in activeLoaders)
|
||||||
// {
|
// {
|
||||||
// var idx = kv.Key;
|
// var idx = kv.Key;
|
||||||
// if (idx < startIndex || idx > endIndex)
|
// if (idx < startIndex || idx > endIndex)
|
||||||
// {
|
// {
|
||||||
// GLoaderPool.Instance.ReturnLoader(kv.Value);
|
// GLoaderPool.Instance.ReturnLoader(kv.Value);
|
||||||
// var oldItem = ui.list_albums.GetChildAt(idx) as item_albums;
|
// var oldItem = ui.list_albums.GetChildAt(idx) as item_albums;
|
||||||
// if (oldItem != null) oldItem.com_loader.loader = null;
|
// if (oldItem != null) oldItem.com_loader.loader = null;
|
||||||
// keysToRemove.Add(idx);
|
// keysToRemove.Add(idx);
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// foreach (var k in keysToRemove) activeLoaders.Remove(k);
|
// foreach (var k in keysToRemove) activeLoaders.Remove(k);
|
||||||
|
|
||||||
|
|
||||||
// // 分配 loader 并加载图片
|
// // 分配 loader 并加载图片
|
||||||
// for (var i = startIndex; i <= endIndex; i++)
|
// for (var i = startIndex; i <= endIndex; i++)
|
||||||
// {
|
// {
|
||||||
// if (activeLoaders.ContainsKey(i)) continue;
|
// if (activeLoaders.ContainsKey(i)) continue;
|
||||||
|
|
||||||
// var item = ui.list_albums.GetChildAt(i) as item_albums;
|
// var item = ui.list_albums.GetChildAt(i) as item_albums;
|
||||||
// if (item == null) continue;
|
// if (item == null) continue;
|
||||||
|
|
||||||
// if (item.com_loader.loader != null && !item.com_loader.loader.isDisposed)
|
// if (item.com_loader.loader != null && !item.com_loader.loader.isDisposed)
|
||||||
// GLoaderPool.Instance.ReturnLoader(item.com_loader.loader);
|
// GLoaderPool.Instance.ReturnLoader(item.com_loader.loader);
|
||||||
|
|
||||||
// var loader = GLoaderPool.Instance.GetLoader();
|
// var loader = GLoaderPool.Instance.GetLoader();
|
||||||
// item.com_loader.loader = loader;
|
// item.com_loader.loader = loader;
|
||||||
// item.com_loader.AddChild(loader);
|
// item.com_loader.AddChild(loader);
|
||||||
// loader.SetSize(item.com_loader.loader.width, item.com_loader.loader.height);
|
// loader.SetSize(item.com_loader.loader.width, item.com_loader.loader.height);
|
||||||
|
|
||||||
// _fileIsExist.TryGetValue(i, out var value);
|
// _fileIsExist.TryGetValue(i, out var value);
|
||||||
// if (!value)
|
// if (!value)
|
||||||
// {
|
// {
|
||||||
// var localPath = Path.Combine(TextureHelper.getResPath(), LevelData[i].Name + ".jpg");
|
// var localPath = Path.Combine(TextureHelper.getResPath(), LevelData[i].Name + ".jpg");
|
||||||
|
|
||||||
// if (File.Exists(localPath))
|
// if (File.Exists(localPath))
|
||||||
// {
|
// {
|
||||||
// _fileIsExist[i] = true;
|
// _fileIsExist[i] = true;
|
||||||
// Debug.Log($"[SetImgLoader] 本地存在,直接加载 {LevelData[i].Name}");
|
// Debug.Log($"[SetImgLoader] 本地存在,直接加载 {LevelData[i].Name}");
|
||||||
// CrazyAsyKit.StartCoroutine(TextureHelper.LoadTexture(LevelData[i].Name, loader, null,
|
// CrazyAsyKit.StartCoroutine(TextureHelper.LoadTexture(LevelData[i].Name, loader, null,
|
||||||
// "LevelAlbums/"));
|
// "LevelAlbums/"));
|
||||||
// }
|
// }
|
||||||
// else
|
// else
|
||||||
// {
|
// {
|
||||||
// _fileIsExist[i] = false;
|
// _fileIsExist[i] = false;
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
// else
|
// else
|
||||||
// {
|
// {
|
||||||
// CrazyAsyKit.StartCoroutine(TextureHelper.LoadTexture(LevelData[i].Name, loader, null,
|
// CrazyAsyKit.StartCoroutine(TextureHelper.LoadTexture(LevelData[i].Name, loader, null,
|
||||||
// "LevelAlbums/"));
|
// "LevelAlbums/"));
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// activeLoaders[i] = loader;
|
// activeLoaders[i] = loader;
|
||||||
// }
|
// }
|
||||||
// Debug.Log($"[ScrollUpdate] active loaders={activeLoaders.Count}, pool={GLoaderPool.Instance.GetPoolCount()}, inUse={GLoaderPool.Instance.GetInUseCount()}");
|
// Debug.Log($"[ScrollUpdate] active loaders={activeLoaders.Count}, pool={GLoaderPool.Instance.GetPoolCount()}, inUse={GLoaderPool.Instance.GetInUseCount()}");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnScrollEnd()
|
private void OnScrollEnd()
|
||||||
{
|
{
|
||||||
invoker.Invoke();
|
invoker.Invoke();
|
||||||
// for (int i = 0; i < UpDatatime.Length; i++)
|
// for (int i = 0; i < UpDatatime.Length; i++)
|
||||||
// {
|
// {
|
||||||
// UpDatatime[i] = 0;
|
// UpDatatime[i] = 0;
|
||||||
// // ImageName[i] = "";
|
// // ImageName[i] = "";
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// DOVirtual.DelayedCall(0.1f, () =>
|
// DOVirtual.DelayedCall(0.1f, () =>
|
||||||
// {
|
// {
|
||||||
// ui.list_albums.RefreshVirtualList();
|
// ui.list_albums.RefreshVirtualList();
|
||||||
// });
|
// });
|
||||||
|
|
||||||
// if (LevelData == null || LevelData.Count == 0) return;
|
// if (LevelData == null || LevelData.Count == 0) return;
|
||||||
|
|
||||||
// var firstVisibleIndex = ui.list_albums.GetFirstChildInView();
|
// var firstVisibleIndex = ui.list_albums.GetFirstChildInView();
|
||||||
// var lastVisibleIndex = Mathf.Min(firstVisibleIndex + MaxVisibleCount - 1, ui.list_albums.numItems - 1);
|
// var lastVisibleIndex = Mathf.Min(firstVisibleIndex + MaxVisibleCount - 1, ui.list_albums.numItems - 1);
|
||||||
|
|
||||||
// var startIndex = Mathf.Max(0, firstVisibleIndex - PreloadCount);
|
// var startIndex = Mathf.Max(0, firstVisibleIndex - PreloadCount);
|
||||||
// var endIndex = Mathf.Min(ui.list_albums.numItems - 1, lastVisibleIndex + PreloadCount);
|
// var endIndex = Mathf.Min(ui.list_albums.numItems - 1, lastVisibleIndex + PreloadCount);
|
||||||
|
|
||||||
// // Debug.Log($"[ScrollEnd] start index={startIndex} end index={endIndex}");
|
// // Debug.Log($"[ScrollEnd] start index={startIndex} end index={endIndex}");
|
||||||
|
|
||||||
|
|
||||||
// var tasks = new List<(GLoader loader, string fileName, Action<NTexture> callback, string folder)>();
|
// var tasks = new List<(GLoader loader, string fileName, Action<NTexture> callback, string folder)>();
|
||||||
// // 分配 loader 并加载图片
|
// // 分配 loader 并加载图片
|
||||||
// for (var i = startIndex; i <= endIndex; i++)
|
// for (var i = startIndex; i <= endIndex; i++)
|
||||||
// {
|
// {
|
||||||
// _fileIsExist.TryGetValue(i, out var value);
|
// _fileIsExist.TryGetValue(i, out var value);
|
||||||
|
|
||||||
// if (value) continue;
|
// if (value) continue;
|
||||||
|
|
||||||
// if (GameHelper.GetLevel() < i + 1) continue;
|
// if (GameHelper.GetLevel() < i + 1) continue;
|
||||||
|
|
||||||
// var item = ui.list_albums.GetChildAt(i) as item_albums;
|
// var item = ui.list_albums.GetChildAt(i) as item_albums;
|
||||||
// if (item == null) continue;
|
// if (item == null) continue;
|
||||||
// if (item.com_loader.loader != null && !item.com_loader.loader.isDisposed)
|
// if (item.com_loader.loader != null && !item.com_loader.loader.isDisposed)
|
||||||
// GLoaderPool.Instance.ReturnLoader(item.com_loader.loader);
|
// GLoaderPool.Instance.ReturnLoader(item.com_loader.loader);
|
||||||
// var loader = GLoaderPool.Instance.GetLoader();
|
// var loader = GLoaderPool.Instance.GetLoader();
|
||||||
// item.com_loader.loader = loader;
|
// item.com_loader.loader = loader;
|
||||||
// item.com_loader.AddChild(loader);
|
// item.com_loader.AddChild(loader);
|
||||||
// loader.SetSize(item.com_loader.loader.width, item.com_loader.loader.height);
|
// loader.SetSize(item.com_loader.loader.width, item.com_loader.loader.height);
|
||||||
|
|
||||||
// var idx = i;
|
// var idx = i;
|
||||||
// tasks.Add((loader, LevelData[i].Name, NTexture =>
|
// tasks.Add((loader, LevelData[i].Name, NTexture =>
|
||||||
// {
|
// {
|
||||||
// if (NTexture != null) _fileIsExist[idx] = true;
|
// if (NTexture != null) _fileIsExist[idx] = true;
|
||||||
// }, "LevelAlbums/"));
|
// }, "LevelAlbums/"));
|
||||||
|
|
||||||
// activeLoaders[i] = loader;
|
// activeLoaders[i] = loader;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// if (tasks.Count > 0) TextureHelper.SetImgLoaders(tasks);
|
// if (tasks.Count > 0) TextureHelper.SetImgLoaders(tasks);
|
||||||
}
|
}
|
||||||
|
|
||||||
private string[] ImageName;
|
private string[] ImageName;
|
||||||
|
|
||||||
private void RendererList(int index, GObject obj)
|
private void RendererList(int index, GObject obj)
|
||||||
{
|
{
|
||||||
// Debug.Log("Render list" );
|
// Debug.Log("Render list" );
|
||||||
|
|
||||||
// Debug.Log(JsonConvert.SerializeObject(LevelData[index]));
|
// Debug.Log(JsonConvert.SerializeObject(LevelData[index]));
|
||||||
|
|
||||||
item_albums item = (item_albums)obj;
|
item_albums item = (item_albums)obj;
|
||||||
item.text_num.text = (index + 1).ToString();
|
item.text_num.text = (index + 1).ToString();
|
||||||
if (index < GameHelper.GetCommonModel().MultiModal - 1)
|
if (index < GameHelper.GetCommonModel().MultiModal - 1)
|
||||||
{
|
{
|
||||||
item.type_.selectedIndex = 0;
|
item.type_.selectedIndex = 0;
|
||||||
if (GameHelper.GetLevel() > index + 1)
|
if (GameHelper.GetLevel() > index + 1)
|
||||||
{
|
{
|
||||||
item.SetClick(() => { uiCtrlDispatcher.Dispatch(UICtrlMsg.AlbumDetailUI_Open, index); });
|
item.SetClick(() => { uiCtrlDispatcher.Dispatch(UICtrlMsg.AlbumDetailUI_Open, index); });
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
item.SetClick(() => { GameHelper.ShowTips("lv_unlock", true); });
|
item.SetClick(() => { GameHelper.ShowTips("lv_unlock", true); });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Levelunlock levelunlock_ = DataMgr.LevelUnlockListNew.Value.FirstOrDefault(x => x.level_ == index + 1);
|
Levelunlock levelunlock_ = DataMgr.LevelUnlockListNew.Value.FirstOrDefault(x => x.level_ == index + 1);
|
||||||
if (levelunlock_ != null)
|
if (levelunlock_ != null)
|
||||||
{
|
{
|
||||||
item.type_.selectedIndex = levelunlock_.type;
|
item.type_.selectedIndex = levelunlock_.type;
|
||||||
}
|
}
|
||||||
else item.type_.selectedIndex = 0;
|
else item.type_.selectedIndex = 0;
|
||||||
if (GameHelper.GetLevel() > index + 1)
|
if (GameHelper.GetLevel() > index + 1)
|
||||||
{
|
{
|
||||||
item.SetClick(() => { uiCtrlDispatcher.Dispatch(UICtrlMsg.AlbumDetailUI_Open, index); });
|
item.SetClick(() => { uiCtrlDispatcher.Dispatch(UICtrlMsg.AlbumDetailUI_Open, index); });
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
item.SetClick(() => { GameHelper.ShowTips("lv_unlock", true); });
|
item.SetClick(() => { GameHelper.ShowTips("lv_unlock", true); });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (GameHelper.GetNowTime() < UpDatatime[index] + 1) return;
|
if (GameHelper.GetNowTime() < UpDatatime[index] + 1) return;
|
||||||
UpDatatime[index] = GameHelper.GetNowTime();
|
UpDatatime[index] = GameHelper.GetNowTime();
|
||||||
// if (!activeLoaders.ContainsValue(item.com_loader.loader)) activeLoaders[index] = item.com_loader.loader;
|
// if (!activeLoaders.ContainsValue(item.com_loader.loader)) activeLoaders[index] = item.com_loader.loader;
|
||||||
if (!loader_list.Contains(item.com_loader.GetChild("loader") as GLoader))
|
if (!loader_list.Contains(item.com_loader.GetChild("loader") as GLoader))
|
||||||
loader_list.Add(item.com_loader.GetChild("loader") as GLoader);
|
loader_list.Add(item.com_loader.GetChild("loader") as GLoader);
|
||||||
|
|
||||||
|
|
||||||
if (index < GameHelper.GetCommonModel().MultiModal - 1)
|
if (index < GameHelper.GetCommonModel().MultiModal - 1)
|
||||||
{
|
{
|
||||||
if (GameHelper.GetLevel() > index + 1)
|
if (GameHelper.GetLevel() > index + 1)
|
||||||
{
|
{
|
||||||
item.isUnlock.selectedIndex = 1;
|
item.isUnlock.selectedIndex = 1;
|
||||||
if (item.com_loader.loader.texture == null ||
|
if (item.com_loader.loader.texture == null ||
|
||||||
item.com_loader.loader.texture.nativeTexture.name != LevelData[index].Name)
|
item.com_loader.loader.texture.nativeTexture.name != LevelData[index].Name)
|
||||||
{
|
{
|
||||||
// item.isUnlock.selectedIndex = 0;
|
// item.isUnlock.selectedIndex = 0;
|
||||||
// if (item.com_loader.loader.texture != null)
|
// if (item.com_loader.loader.texture != null)
|
||||||
// {
|
// {
|
||||||
// item.com_loader.loader.texture.Dispose(); // 释放 GPU 资源
|
// item.com_loader.loader.texture.Dispose(); // 释放 GPU 资源
|
||||||
// item.com_loader.loader.texture = null; // 断开引用
|
// item.com_loader.loader.texture = null; // 断开引用
|
||||||
// }
|
// }
|
||||||
|
|
||||||
TextureHelper.SetImgLoader(item.com_loader.GetChild("loader") as GLoader, LevelData[index].Name,
|
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);
|
(a) => { Debug.Log(item.com_loader.loader.texture.nativeTexture.name); }, "LevelAlbums/", FolderNames.AlbumName);
|
||||||
|
|
||||||
ImageName[index] = LevelData[index].Name;
|
ImageName[index] = LevelData[index].Name;
|
||||||
}
|
}
|
||||||
|
|
||||||
item.touchable = true;
|
item.touchable = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
item.isUnlock.selectedIndex = 0;
|
item.isUnlock.selectedIndex = 0;
|
||||||
// item.touchable = false;
|
// item.touchable = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Levelunlock levelunlock_ = DataMgr.LevelUnlockListNew.Value.FirstOrDefault(x => x.level_ == index + 1);
|
Levelunlock levelunlock_ = DataMgr.LevelUnlockListNew.Value.FirstOrDefault(x => x.level_ == index + 1);
|
||||||
|
|
||||||
if (GameHelper.GetLevel() > index + 1)
|
if (GameHelper.GetLevel() > index + 1)
|
||||||
{
|
{
|
||||||
if (levelunlock_ != null)
|
if (levelunlock_ != null)
|
||||||
{
|
{
|
||||||
item.isUnlock.selectedIndex = 1;
|
item.isUnlock.selectedIndex = 1;
|
||||||
|
|
||||||
if (item.com_loader.loader.texture == null || item.com_loader.loader.texture.nativeTexture.name != ImageName[index])
|
if (item.com_loader.loader.texture == null || item.com_loader.loader.texture.nativeTexture.name != ImageName[index])
|
||||||
{
|
{
|
||||||
|
|
||||||
if (levelunlock_.type == 0)
|
if (levelunlock_.type == 0)
|
||||||
{
|
{
|
||||||
if (levelunlock_.config_index >= ConfigSystem.GetConfig<FreeImageLibrary>().Count) levelunlock_.config_index = ConfigSystem.GetConfig<FreeImageLibrary>().Count - 1;
|
if (levelunlock_.config_index >= ConfigSystem.GetFreeImageConfig().Count) levelunlock_.config_index = ConfigSystem.GetFreeImageConfig().Count - 1;
|
||||||
FreeImageLibrary _leveldata = ConfigSystem.GetConfig<FreeImageLibrary>()[levelunlock_.config_index];
|
FreeImageLibrary _leveldata = ConfigSystem.GetFreeImageConfig()[levelunlock_.config_index];
|
||||||
TextureHelper.SetImgLoader(item.com_loader.GetChild("loader") as GLoader, _leveldata.Name, null, "LevelAlbums/", FolderNames.AlbumName);
|
TextureHelper.SetImgLoader(item.com_loader.GetChild("loader") as GLoader, _leveldata.Name, null, "LevelAlbums/", FolderNames.AlbumName);
|
||||||
ImageName[index] = LevelData[index].Name;
|
ImageName[index] = LevelData[index].Name;
|
||||||
}
|
}
|
||||||
else if (levelunlock_.type == 1)
|
else if (levelunlock_.type == 1)
|
||||||
{
|
{
|
||||||
if (levelunlock_.config_index >= ConfigSystem.GetConfig<ADImageLibrary>().Count) levelunlock_.config_index = ConfigSystem.GetConfig<ADImageLibrary>().Count - 1;
|
if (levelunlock_.config_index >= ConfigSystem.GetADImageConfig().Count) levelunlock_.config_index = ConfigSystem.GetADImageConfig().Count - 1;
|
||||||
ADImageLibrary _leveldata = ConfigSystem.GetConfig<ADImageLibrary>()[levelunlock_.config_index];
|
ADImageLibrary _leveldata = ConfigSystem.GetADImageConfig()[levelunlock_.config_index];
|
||||||
TextureHelper.SetImgLoader(item.com_loader.GetChild("loader") as GLoader, _leveldata.Name, null, "LevelAlbums/", FolderNames.AlbumName);
|
TextureHelper.SetImgLoader(item.com_loader.GetChild("loader") as GLoader, _leveldata.Name, null, "LevelAlbums/", FolderNames.AlbumName);
|
||||||
ImageName[index] = LevelData[index].Name;
|
ImageName[index] = LevelData[index].Name;
|
||||||
}
|
}
|
||||||
else if (levelunlock_.type == 2)
|
else if (levelunlock_.type == 2)
|
||||||
{
|
{
|
||||||
if (levelunlock_.config_index >= ConfigSystem.GetConfig<SpecialImageLibrary>().Count) levelunlock_.config_index = ConfigSystem.GetConfig<SpecialImageLibrary>().Count - 1;
|
if (levelunlock_.config_index >= ConfigSystem.GetSpecialImageConfig().Count) levelunlock_.config_index = ConfigSystem.GetSpecialImageConfig().Count - 1;
|
||||||
SpecialImageLibrary _leveldata = ConfigSystem.GetConfig<SpecialImageLibrary>()[levelunlock_.config_index];
|
SpecialImageLibrary _leveldata = ConfigSystem.GetSpecialImageConfig()[levelunlock_.config_index];
|
||||||
TextureHelper.SetImgLoader(item.com_loader.GetChild("loader") as GLoader, _leveldata.Name, null, "LevelAlbums/", FolderNames.AlbumName);
|
TextureHelper.SetImgLoader(item.com_loader.GetChild("loader") as GLoader, _leveldata.Name, null, "LevelAlbums/", FolderNames.AlbumName);
|
||||||
ImageName[index] = LevelData[index].Name;
|
ImageName[index] = LevelData[index].Name;
|
||||||
}
|
}
|
||||||
else if (levelunlock_.type == 3)
|
else if (levelunlock_.type == 3)
|
||||||
{
|
{
|
||||||
if (levelunlock_.config_index >= ConfigSystem.GetConfig<VIPImageLibrary>().Count) levelunlock_.config_index = ConfigSystem.GetConfig<VIPImageLibrary>().Count - 1;
|
if (levelunlock_.config_index >= ConfigSystem.GetVIPImageConfig().Count) levelunlock_.config_index = ConfigSystem.GetVIPImageConfig().Count - 1;
|
||||||
VIPImageLibrary _leveldata = ConfigSystem.GetConfig<VIPImageLibrary>()[levelunlock_.config_index];
|
VIPImageLibrary _leveldata = ConfigSystem.GetVIPImageConfig()[levelunlock_.config_index];
|
||||||
TextureHelper.SetImgLoader(item.com_loader.GetChild("loader") as GLoader, _leveldata.Name, null, "LevelAlbums/", FolderNames.AlbumName);
|
TextureHelper.SetImgLoader(item.com_loader.GetChild("loader") as GLoader, _leveldata.Name, null, "LevelAlbums/", FolderNames.AlbumName);
|
||||||
ImageName[index] = LevelData[index].Name;
|
ImageName[index] = LevelData[index].Name;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
item.isUnlock.selectedIndex = 1;
|
item.isUnlock.selectedIndex = 1;
|
||||||
if (item.com_loader.loader.texture == null || item.com_loader.loader.texture.nativeTexture.name != LevelData[index].Name)
|
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);
|
TextureHelper.SetImgLoader(item.com_loader.GetChild("loader") as GLoader, LevelData[index].Name, null, "LevelAlbums/", FolderNames.AlbumName);
|
||||||
ImageName[index] = LevelData[index].Name;
|
ImageName[index] = LevelData[index].Name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// item.touchable = false;
|
// item.touchable = false;
|
||||||
item.isUnlock.selectedIndex = 0;
|
item.isUnlock.selectedIndex = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnOpen(object args)
|
protected override void OnOpen(object args)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnHide()
|
protected override void OnHide()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnDisplay(object args)
|
protected override void OnDisplay(object args)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region 消息
|
#region 消息
|
||||||
|
|
||||||
protected override void AddListener()
|
protected override void AddListener()
|
||||||
{
|
{
|
||||||
GameDispatcher.Instance.AddListener(GameMsg.UnlockAlbums, SetItemData);
|
GameDispatcher.Instance.AddListener(GameMsg.UnlockAlbums, SetItemData);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void RemoveListener()
|
protected override void RemoveListener()
|
||||||
{
|
{
|
||||||
GameDispatcher.Instance.RemoveListener(GameMsg.UnlockAlbums, SetItemData);
|
GameDispatcher.Instance.RemoveListener(GameMsg.UnlockAlbums, SetItemData);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
public class SmartInvoker
|
public class SmartInvoker
|
||||||
{
|
{
|
||||||
private readonly Action _action;
|
private readonly Action _action;
|
||||||
private readonly TimeSpan _delay;
|
private readonly TimeSpan _delay;
|
||||||
private DateTime _lastImmediateInvoke = DateTime.MinValue;
|
private DateTime _lastImmediateInvoke = DateTime.MinValue;
|
||||||
private CancellationTokenSource _cts = null;
|
private CancellationTokenSource _cts = null;
|
||||||
private readonly object _lock = new object();
|
private readonly object _lock = new object();
|
||||||
private bool _hasPending = false;
|
private bool _hasPending = false;
|
||||||
|
|
||||||
public SmartInvoker(Action action, TimeSpan delay)
|
public SmartInvoker(Action action, TimeSpan delay)
|
||||||
{
|
{
|
||||||
_action = action;
|
_action = action;
|
||||||
_delay = delay;
|
_delay = delay;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Invoke()
|
public void Invoke()
|
||||||
{
|
{
|
||||||
lock (_lock)
|
lock (_lock)
|
||||||
{
|
{
|
||||||
var now = DateTime.UtcNow;
|
var now = DateTime.UtcNow;
|
||||||
var timeSinceLast = now - _lastImmediateInvoke;
|
var timeSinceLast = now - _lastImmediateInvoke;
|
||||||
|
|
||||||
if (timeSinceLast >= _delay)
|
if (timeSinceLast >= _delay)
|
||||||
{
|
{
|
||||||
_lastImmediateInvoke = now;
|
_lastImmediateInvoke = now;
|
||||||
_action();
|
_action();
|
||||||
Debug.Log("diaoyongyiciiiiiiiiiiiiiii");
|
Debug.Log("diaoyongyiciiiiiiiiiiiiiii");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_hasPending = true;
|
_hasPending = true;
|
||||||
_cts?.Cancel();
|
_cts?.Cancel();
|
||||||
_cts = new CancellationTokenSource();
|
_cts = new CancellationTokenSource();
|
||||||
var token = _cts.Token;
|
var token = _cts.Token;
|
||||||
|
|
||||||
Task.Delay(_delay, token).ContinueWith(t =>
|
Task.Delay(_delay, token).ContinueWith(t =>
|
||||||
{
|
{
|
||||||
if (!t.IsCanceled)
|
if (!t.IsCanceled)
|
||||||
{
|
{
|
||||||
lock (_lock)
|
lock (_lock)
|
||||||
{
|
{
|
||||||
if (_hasPending)
|
if (_hasPending)
|
||||||
{
|
{
|
||||||
_lastImmediateInvoke = DateTime.UtcNow;
|
_lastImmediateInvoke = DateTime.UtcNow;
|
||||||
_hasPending = false;
|
_hasPending = false;
|
||||||
_action();
|
_action();
|
||||||
Debug.Log("diaoyongyiciiiiiiiiiiiiiii");
|
Debug.Log("diaoyongyiciiiiiiiiiiiiiii");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, TaskScheduler.Default);
|
}, TaskScheduler.Default);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -218,8 +218,8 @@ namespace RedHotRoast
|
|||||||
{
|
{
|
||||||
int level_ = GameHelper.GetLevel() - 2;
|
int level_ = GameHelper.GetLevel() - 2;
|
||||||
if (level_ <= 0) level_ = 0;
|
if (level_ <= 0) level_ = 0;
|
||||||
if (level_ >= ConfigSystem.GetConfig<LevelUnlock>().Count) level_ = ConfigSystem.GetConfig<LevelUnlock>().Count - 1;
|
if (level_ >= ConfigSystem.GetLevelUnlockConfig().Count) level_ = ConfigSystem.GetLevelUnlockConfig().Count - 1;
|
||||||
TextureHelper.SetImgLoader(ui.bg_loader, ConfigSystem.GetConfig<LevelUnlock>()[level_].Name, null, "LevelAlbums/", FolderNames.AlbumName);
|
TextureHelper.SetImgLoader(ui.bg_loader, ConfigSystem.GetLevelUnlockConfig()[level_].Name, null, "LevelAlbums/", FolderNames.AlbumName);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -228,26 +228,26 @@ namespace RedHotRoast
|
|||||||
{
|
{
|
||||||
if (levelunlock_.type == 0)
|
if (levelunlock_.type == 0)
|
||||||
{
|
{
|
||||||
if (levelunlock_.config_index >= ConfigSystem.GetConfig<FreeImageLibrary>().Count) levelunlock_.config_index = ConfigSystem.GetConfig<FreeImageLibrary>().Count - 1;
|
if (levelunlock_.config_index >= ConfigSystem.GetFreeImageConfig().Count) levelunlock_.config_index = ConfigSystem.GetFreeImageConfig().Count - 1;
|
||||||
FreeImageLibrary _leveldata = ConfigSystem.GetConfig<FreeImageLibrary>()[levelunlock_.config_index];
|
FreeImageLibrary _leveldata = ConfigSystem.GetFreeImageConfig()[levelunlock_.config_index];
|
||||||
TextureHelper.SetImgLoader(ui.bg_loader, _leveldata.Name, null, "LevelAlbums/", FolderNames.AlbumName);
|
TextureHelper.SetImgLoader(ui.bg_loader, _leveldata.Name, null, "LevelAlbums/", FolderNames.AlbumName);
|
||||||
}
|
}
|
||||||
else if (levelunlock_.type == 1)
|
else if (levelunlock_.type == 1)
|
||||||
{
|
{
|
||||||
if (levelunlock_.config_index >= ConfigSystem.GetConfig<ADImageLibrary>().Count) levelunlock_.config_index = ConfigSystem.GetConfig<ADImageLibrary>().Count - 1;
|
if (levelunlock_.config_index >= ConfigSystem.GetADImageConfig().Count) levelunlock_.config_index = ConfigSystem.GetADImageConfig().Count - 1;
|
||||||
ADImageLibrary _leveldata = ConfigSystem.GetConfig<ADImageLibrary>()[levelunlock_.config_index];
|
ADImageLibrary _leveldata = ConfigSystem.GetADImageConfig()[levelunlock_.config_index];
|
||||||
TextureHelper.SetImgLoader(ui.bg_loader, _leveldata.Name, null, "LevelAlbums/", FolderNames.AlbumName);
|
TextureHelper.SetImgLoader(ui.bg_loader, _leveldata.Name, null, "LevelAlbums/", FolderNames.AlbumName);
|
||||||
}
|
}
|
||||||
else if (levelunlock_.type == 2)
|
else if (levelunlock_.type == 2)
|
||||||
{
|
{
|
||||||
if (levelunlock_.config_index >= ConfigSystem.GetConfig<SpecialImageLibrary>().Count) levelunlock_.config_index = ConfigSystem.GetConfig<SpecialImageLibrary>().Count - 1;
|
if (levelunlock_.config_index >= ConfigSystem.GetSpecialImageConfig().Count) levelunlock_.config_index = ConfigSystem.GetSpecialImageConfig().Count - 1;
|
||||||
SpecialImageLibrary _leveldata = ConfigSystem.GetConfig<SpecialImageLibrary>()[levelunlock_.config_index];
|
SpecialImageLibrary _leveldata = ConfigSystem.GetSpecialImageConfig()[levelunlock_.config_index];
|
||||||
TextureHelper.SetImgLoader(ui.bg_loader, _leveldata.Name, null, "LevelAlbums/", FolderNames.AlbumName);
|
TextureHelper.SetImgLoader(ui.bg_loader, _leveldata.Name, null, "LevelAlbums/", FolderNames.AlbumName);
|
||||||
}
|
}
|
||||||
else if (levelunlock_.type == 3)
|
else if (levelunlock_.type == 3)
|
||||||
{
|
{
|
||||||
if (levelunlock_.config_index >= ConfigSystem.GetConfig<VIPImageLibrary>().Count) levelunlock_.config_index = ConfigSystem.GetConfig<VIPImageLibrary>().Count - 1;
|
if (levelunlock_.config_index >= ConfigSystem.GetVIPImageConfig().Count) levelunlock_.config_index = ConfigSystem.GetVIPImageConfig().Count - 1;
|
||||||
VIPImageLibrary _leveldata = ConfigSystem.GetConfig<VIPImageLibrary>()[levelunlock_.config_index];
|
VIPImageLibrary _leveldata = ConfigSystem.GetVIPImageConfig()[levelunlock_.config_index];
|
||||||
TextureHelper.SetImgLoader(ui.bg_loader, _leveldata.Name, null, "LevelAlbums/", FolderNames.AlbumName);
|
TextureHelper.SetImgLoader(ui.bg_loader, _leveldata.Name, null, "LevelAlbums/", FolderNames.AlbumName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -255,8 +255,8 @@ namespace RedHotRoast
|
|||||||
{
|
{
|
||||||
int level_ = GameHelper.GetLevel() - 1;
|
int level_ = GameHelper.GetLevel() - 1;
|
||||||
if (level_ < 0) level_ = 0;
|
if (level_ < 0) level_ = 0;
|
||||||
if (level_ >= ConfigSystem.GetConfig<LevelUnlock>().Count) level_ = ConfigSystem.GetConfig<LevelUnlock>().Count - 1;
|
if (level_ >= ConfigSystem.GetLevelUnlockConfig().Count) level_ = ConfigSystem.GetLevelUnlockConfig().Count - 1;
|
||||||
TextureHelper.SetImgLoader(ui.bg_loader, ConfigSystem.GetConfig<LevelUnlock>()[level_].Name, null, "LevelAlbums/", FolderNames.AlbumName);
|
TextureHelper.SetImgLoader(ui.bg_loader, ConfigSystem.GetLevelUnlockConfig()[level_].Name, null, "LevelAlbums/", FolderNames.AlbumName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,419 +1,419 @@
|
|||||||
// using System;
|
// using System;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
|
||||||
// using System.IO;
|
// using System.IO;
|
||||||
|
|
||||||
using FairyGUI;
|
using FairyGUI;
|
||||||
using FGUI.LG_Common;
|
using FGUI.LG_Common;
|
||||||
using FGUI.LG_live;
|
using FGUI.LG_live;
|
||||||
using SGModule.Common.Extensions;
|
using SGModule.Common.Extensions;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.Video;
|
using UnityEngine.Video;
|
||||||
|
|
||||||
namespace RedHotRoast
|
namespace RedHotRoast
|
||||||
{
|
{
|
||||||
public class LiveUI : BaseUI
|
public class LiveUI : BaseUI
|
||||||
{
|
{
|
||||||
private const int MaxVisibleCount = 6; // 一屏最多6个播放器
|
private const int MaxVisibleCount = 6; // 一屏最多6个播放器
|
||||||
private const int PreloadCount = 2; // 上下各预加载一屏
|
private const int PreloadCount = 2; // 上下各预加载一屏
|
||||||
private static readonly Dictionary<item_live, VideoPlayer> dictionary_ = new();
|
private static readonly Dictionary<item_live, VideoPlayer> dictionary_ = new();
|
||||||
private readonly Dictionary<int, GLoader> activeLoaders = new();
|
private readonly Dictionary<int, GLoader> activeLoaders = new();
|
||||||
private readonly Dictionary<int, bool> _fileIsExist = new();
|
private readonly Dictionary<int, bool> _fileIsExist = new();
|
||||||
private LiveUICtrl ctrl;
|
private LiveUICtrl ctrl;
|
||||||
|
|
||||||
private float late_time = 0.1f;
|
private float late_time = 0.1f;
|
||||||
private List<Live> LiveConfig;
|
private List<Live> LiveConfig;
|
||||||
private LiveModel model;
|
private LiveModel model;
|
||||||
private com_live ui;
|
private com_live ui;
|
||||||
|
|
||||||
|
|
||||||
private GameObject videoParent;
|
private GameObject videoParent;
|
||||||
|
|
||||||
public LiveUI(LiveUICtrl ctrl) : base(ctrl)
|
public LiveUI(LiveUICtrl ctrl) : base(ctrl)
|
||||||
{
|
{
|
||||||
uiName = UIConst.LiveUI;
|
uiName = UIConst.LiveUI;
|
||||||
this.ctrl = ctrl;
|
this.ctrl = ctrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void SetUIInfo(UIInfo uiInfo)
|
protected override void SetUIInfo(UIInfo uiInfo)
|
||||||
{
|
{
|
||||||
uiInfo.packageName = "LG_live";
|
uiInfo.packageName = "LG_live";
|
||||||
uiInfo.assetName = "com_live";
|
uiInfo.assetName = "com_live";
|
||||||
uiInfo.layerType = UILayerType.Popup;
|
uiInfo.layerType = UILayerType.Popup;
|
||||||
uiInfo.isNeedOpenAnim = false;
|
uiInfo.isNeedOpenAnim = false;
|
||||||
uiInfo.isNeedCloseAnim = false;
|
uiInfo.isNeedCloseAnim = false;
|
||||||
uiInfo.isNeedUIMask = true;
|
uiInfo.isNeedUIMask = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateEvent()
|
private void UpdateEvent()
|
||||||
{
|
{
|
||||||
late_time = 0.1f;
|
late_time = 0.1f;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Refresh(object param = null)
|
private void Refresh(object param = null)
|
||||||
{
|
{
|
||||||
var index = param.As<int>();
|
var index = param.As<int>();
|
||||||
// ui.list_.itemRenderer = RendererList;
|
// ui.list_.itemRenderer = RendererList;
|
||||||
// Debug.Log($"LiveConfig.Count==2=== {LiveConfig.Count}");
|
// Debug.Log($"LiveConfig.Count==2=== {LiveConfig.Count}");
|
||||||
// ui.list_.numItems = LiveConfig.Count;
|
// ui.list_.numItems = LiveConfig.Count;
|
||||||
|
|
||||||
|
|
||||||
if (ui.list_.GetChildAt(index) is item_live item)
|
if (ui.list_.GetChildAt(index) is item_live item)
|
||||||
{
|
{
|
||||||
var livedata_ = PreDownloadManager.GetLiveDataByIndex(LiveConfig[index], index);
|
var livedata_ = PreDownloadManager.GetLiveDataByIndex(LiveConfig[index], index);
|
||||||
item.state.selectedIndex = livedata_.progress >= 100 ? 0 : 1;
|
item.state.selectedIndex = livedata_.progress >= 100 ? 0 : 1;
|
||||||
item.img_mask.fillAmount = (float)(100 - livedata_.progress) / 100;
|
item.img_mask.fillAmount = (float)(100 - livedata_.progress) / 100;
|
||||||
BindPlayerToItem(item, index);
|
BindPlayerToItem(item, index);
|
||||||
|
|
||||||
if (LiveConfig[index].SubscribeUnlock == 1)
|
if (LiveConfig[index].SubscribeUnlock == 1)
|
||||||
{
|
{
|
||||||
if (livedata_.progress < 100) item.vip.selectedIndex = 1;
|
if (livedata_.progress < 100) item.vip.selectedIndex = 1;
|
||||||
else item.vip.selectedIndex = 2;
|
else item.vip.selectedIndex = 2;
|
||||||
}
|
}
|
||||||
else item.vip.selectedIndex = 0;
|
else item.vip.selectedIndex = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 初始化页面逻辑
|
// 初始化页面逻辑
|
||||||
private void InitView()
|
private void InitView()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
#region 生命周期
|
#region 生命周期
|
||||||
|
|
||||||
protected override void OnInit()
|
protected override void OnInit()
|
||||||
{
|
{
|
||||||
videoParent = new GameObject("VideoPlayerParent");
|
videoParent = new GameObject("VideoPlayerParent");
|
||||||
VideoPlayerPool.Instance.Init(videoParent, MaxVisibleCount);
|
VideoPlayerPool.Instance.Init(videoParent, MaxVisibleCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnClose()
|
protected override void OnClose()
|
||||||
{
|
{
|
||||||
// 归还所有播放器
|
// 归还所有播放器
|
||||||
foreach (var kvp in dictionary_)
|
foreach (var kvp in dictionary_)
|
||||||
VideoPlayerPool.Instance.ReturnPlayer(kvp.Value);
|
VideoPlayerPool.Instance.ReturnPlayer(kvp.Value);
|
||||||
|
|
||||||
dictionary_.Clear();
|
dictionary_.Clear();
|
||||||
VideoPlayerPool.Instance.DisposeAll();
|
VideoPlayerPool.Instance.DisposeAll();
|
||||||
UnityEngine.Object.Destroy(videoParent);
|
UnityEngine.Object.Destroy(videoParent);
|
||||||
|
|
||||||
foreach (var t in loader_list)
|
foreach (var t in loader_list)
|
||||||
if (t != null && !t.isDisposed && t.texture != null)
|
if (t != null && !t.isDisposed && t.texture != null)
|
||||||
{
|
{
|
||||||
t.texture.Dispose();
|
t.texture.Dispose();
|
||||||
t.texture = null;
|
t.texture = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
MemoryManager.CleanMemoryMonitor();
|
MemoryManager.CleanMemoryMonitor();
|
||||||
activeLoaders.Clear();
|
activeLoaders.Clear();
|
||||||
_fileIsExist.Clear();
|
_fileIsExist.Clear();
|
||||||
|
|
||||||
GLoaderPool.Instance.DisposeAll();
|
GLoaderPool.Instance.DisposeAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnBind()
|
protected override void OnBind()
|
||||||
{
|
{
|
||||||
ui = baseUI as com_live;
|
ui = baseUI as com_live;
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly List<GLoader> loader_list = new();
|
private readonly List<GLoader> loader_list = new();
|
||||||
|
|
||||||
|
|
||||||
protected override void OnOpenBefore(object args)
|
protected override void OnOpenBefore(object args)
|
||||||
{
|
{
|
||||||
LiveConfig = ConfigSystem.GetConfig<Live>();
|
LiveConfig = ConfigSystem.GetLiveConfig();
|
||||||
|
|
||||||
ui.list_.itemRenderer = RendererList;
|
ui.list_.itemRenderer = RendererList;
|
||||||
Debug.Log($"LiveConfig.Count==1=== {LiveConfig.Count}");
|
Debug.Log($"LiveConfig.Count==1=== {LiveConfig.Count}");
|
||||||
ui.list_.numItems = LiveConfig.Count;
|
ui.list_.numItems = LiveConfig.Count;
|
||||||
|
|
||||||
ui.btn_close.SetClick(() => { CtrlCloseUI(); });
|
ui.btn_close.SetClick(() => { CtrlCloseUI(); });
|
||||||
|
|
||||||
InitView();
|
InitView();
|
||||||
|
|
||||||
// 滚动过程中实时刷新可见播放器
|
// 滚动过程中实时刷新可见播放器
|
||||||
ui.list_.scrollPane.onScroll.Add(OnScrollUpdate);
|
ui.list_.scrollPane.onScroll.Add(OnScrollUpdate);
|
||||||
ui.list_.scrollPane.onScrollEnd.Add(OnScrollEnd);
|
ui.list_.scrollPane.onScrollEnd.Add(OnScrollEnd);
|
||||||
|
|
||||||
// 打开页面时初始化一次
|
// 打开页面时初始化一次
|
||||||
OnScrollEnd();
|
OnScrollEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnScrollUpdate()
|
private void OnScrollUpdate()
|
||||||
{
|
{
|
||||||
if (LiveConfig == null || LiveConfig.Count == 0) return;
|
if (LiveConfig == null || LiveConfig.Count == 0) return;
|
||||||
var firstVisibleIndex = ui.list_.GetFirstChildInView();
|
var firstVisibleIndex = ui.list_.GetFirstChildInView();
|
||||||
var lastVisibleIndex = Mathf.Min(firstVisibleIndex + MaxVisibleCount - 1, ui.list_.numItems - 1);
|
var lastVisibleIndex = Mathf.Min(firstVisibleIndex + MaxVisibleCount - 1, ui.list_.numItems - 1);
|
||||||
|
|
||||||
var startIndex = Mathf.Max(0, firstVisibleIndex - PreloadCount);
|
var startIndex = Mathf.Max(0, firstVisibleIndex - PreloadCount);
|
||||||
var endIndex = Mathf.Min(ui.list_.numItems - 1, lastVisibleIndex + PreloadCount);
|
var endIndex = Mathf.Min(ui.list_.numItems - 1, lastVisibleIndex + PreloadCount);
|
||||||
|
|
||||||
// 回收超出范围 loader
|
// 回收超出范围 loader
|
||||||
var keysToRemove = new List<int>();
|
var keysToRemove = new List<int>();
|
||||||
foreach (var kv in activeLoaders)
|
foreach (var kv in activeLoaders)
|
||||||
{
|
{
|
||||||
var idx = kv.Key;
|
var idx = kv.Key;
|
||||||
if (idx < startIndex || idx > endIndex)
|
if (idx < startIndex || idx > endIndex)
|
||||||
{
|
{
|
||||||
GLoaderPool.Instance.ReturnLoader(kv.Value);
|
GLoaderPool.Instance.ReturnLoader(kv.Value);
|
||||||
var oldItem = ui.list_.GetChildAt(idx) as item_live;
|
var oldItem = ui.list_.GetChildAt(idx) as item_live;
|
||||||
if (oldItem != null) {
|
if (oldItem != null) {
|
||||||
(oldItem.img_cover as com_loaderMask_circlle).loader = null;
|
(oldItem.img_cover as com_loaderMask_circlle).loader = null;
|
||||||
}
|
}
|
||||||
keysToRemove.Add(idx);
|
keysToRemove.Add(idx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var k in keysToRemove) activeLoaders.Remove(k);
|
foreach (var k in keysToRemove) activeLoaders.Remove(k);
|
||||||
|
|
||||||
// 分配 loader 并加载图片
|
// 分配 loader 并加载图片
|
||||||
for (var i = startIndex; i <= endIndex; i++)
|
for (var i = startIndex; i <= endIndex; i++)
|
||||||
{
|
{
|
||||||
if (activeLoaders.ContainsKey(i)) continue;
|
if (activeLoaders.ContainsKey(i)) continue;
|
||||||
|
|
||||||
var item = ui.list_.GetChildAt(i) as item_live;
|
var item = ui.list_.GetChildAt(i) as item_live;
|
||||||
if (item == null) continue;
|
if (item == null) continue;
|
||||||
|
|
||||||
if ((item.img_cover as com_loaderMask_circlle).loader != null && !(item.img_cover as com_loaderMask_circlle).loader.isDisposed)
|
if ((item.img_cover as com_loaderMask_circlle).loader != null && !(item.img_cover as com_loaderMask_circlle).loader.isDisposed)
|
||||||
GLoaderPool.Instance.ReturnLoader((item.img_cover as com_loaderMask_circlle).loader);
|
GLoaderPool.Instance.ReturnLoader((item.img_cover as com_loaderMask_circlle).loader);
|
||||||
|
|
||||||
var loader = GLoaderPool.Instance.GetLoader();
|
var loader = GLoaderPool.Instance.GetLoader();
|
||||||
(item.img_cover as com_loaderMask_circlle).loader = loader;
|
(item.img_cover as com_loaderMask_circlle).loader = loader;
|
||||||
item.img_cover.AddChild(loader);
|
item.img_cover.AddChild(loader);
|
||||||
loader.SetSize(item.img_cover.width, item.img_cover.height);
|
loader.SetSize(item.img_cover.width, item.img_cover.height);
|
||||||
item.img_cover.visible = true;
|
item.img_cover.visible = true;
|
||||||
|
|
||||||
_fileIsExist.TryGetValue(i, out var value);
|
_fileIsExist.TryGetValue(i, out var value);
|
||||||
if (!value)
|
if (!value)
|
||||||
{
|
{
|
||||||
var localPath = Path.Combine(TextureHelper.getResPath(), "LiveVideoCovers", LiveConfig[i].Name + "_cover" + ".jpg");
|
var localPath = Path.Combine(TextureHelper.getResPath(), "LiveVideoCovers", LiveConfig[i].Name + "_cover" + ".jpg");
|
||||||
if (File.Exists(localPath))
|
if (File.Exists(localPath))
|
||||||
{
|
{
|
||||||
_fileIsExist[i] = true;
|
_fileIsExist[i] = true;
|
||||||
Debug.Log($"[SetImgLoader] 本地存在,直接加载 {LiveConfig[i].Name + "_cover"}");
|
Debug.Log($"[SetImgLoader] 本地存在,直接加载 {LiveConfig[i].Name + "_cover"}");
|
||||||
CrazyAsyKit.StartCoroutine(TextureHelper.LoadTexture(LiveConfig[i].Name + "_cover", loader, null,
|
CrazyAsyKit.StartCoroutine(TextureHelper.LoadTexture(LiveConfig[i].Name + "_cover", loader, null,
|
||||||
"LiveVideoCovers/"));
|
"LiveVideoCovers/"));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_fileIsExist[i] = false;
|
_fileIsExist[i] = false;
|
||||||
CrazyAsyKit.StartCoroutine(LiveVideoManager.Instance.LoadCover(LiveConfig[i].Name + "_cover", tex =>
|
CrazyAsyKit.StartCoroutine(LiveVideoManager.Instance.LoadCover(LiveConfig[i].Name + "_cover", tex =>
|
||||||
{
|
{
|
||||||
if (tex != null)
|
if (tex != null)
|
||||||
{
|
{
|
||||||
if (loader != null)
|
if (loader != null)
|
||||||
{
|
{
|
||||||
loader.texture = new NTexture(tex);
|
loader.texture = new NTexture(tex);
|
||||||
loader.visible = true;
|
loader.visible = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Debug.LogWarning("封面获取失败");
|
Debug.LogWarning("封面获取失败");
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
CrazyAsyKit.StartCoroutine(TextureHelper.LoadTexture(LiveConfig[i].Name + "_cover", loader, null,
|
CrazyAsyKit.StartCoroutine(TextureHelper.LoadTexture(LiveConfig[i].Name + "_cover", loader, null,
|
||||||
"LiveVideoCovers/"));
|
"LiveVideoCovers/"));
|
||||||
}
|
}
|
||||||
|
|
||||||
activeLoaders[i] = loader;
|
activeLoaders[i] = loader;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private HashSet<item_live> lastVisibleItems = new();
|
private HashSet<item_live> lastVisibleItems = new();
|
||||||
|
|
||||||
private void OnScrollEnd()
|
private void OnScrollEnd()
|
||||||
{
|
{
|
||||||
var tasks = new List<(GLoader loader, string fileName, Action<NTexture> callback, string folder, string localFolder)>();
|
var tasks = new List<(GLoader loader, string fileName, Action<NTexture> callback, string folder, string localFolder)>();
|
||||||
var firstVisibleIndex = ui.list_.GetFirstChildInView();
|
var firstVisibleIndex = ui.list_.GetFirstChildInView();
|
||||||
var lastVisibleIndex = Mathf.Min(firstVisibleIndex + MaxVisibleCount - 1, ui.list_.numItems - 1);
|
var lastVisibleIndex = Mathf.Min(firstVisibleIndex + MaxVisibleCount - 1, ui.list_.numItems - 1);
|
||||||
|
|
||||||
var startIndex = Mathf.Max(0, firstVisibleIndex - PreloadCount);
|
var startIndex = Mathf.Max(0, firstVisibleIndex - PreloadCount);
|
||||||
var endIndex = Mathf.Min(ui.list_.numItems - 1, lastVisibleIndex + PreloadCount);
|
var endIndex = Mathf.Min(ui.list_.numItems - 1, lastVisibleIndex + PreloadCount);
|
||||||
for (var i = startIndex; i <= endIndex; i++)
|
for (var i = startIndex; i <= endIndex; i++)
|
||||||
{
|
{
|
||||||
_fileIsExist.TryGetValue(i, out var value);
|
_fileIsExist.TryGetValue(i, out var value);
|
||||||
|
|
||||||
if (value) continue;
|
if (value) continue;
|
||||||
if (ui.list_.GetChildAt(i) is item_live item)
|
if (ui.list_.GetChildAt(i) is item_live item)
|
||||||
{
|
{
|
||||||
if ((item.img_cover as com_loaderMask_circlle).loader != null && !(item.img_cover as com_loaderMask_circlle).loader.isDisposed)
|
if ((item.img_cover as com_loaderMask_circlle).loader != null && !(item.img_cover as com_loaderMask_circlle).loader.isDisposed)
|
||||||
GLoaderPool.Instance.ReturnLoader((item.img_cover as com_loaderMask_circlle).loader);
|
GLoaderPool.Instance.ReturnLoader((item.img_cover as com_loaderMask_circlle).loader);
|
||||||
var loader = GLoaderPool.Instance.GetLoader();
|
var loader = GLoaderPool.Instance.GetLoader();
|
||||||
(item.img_cover as com_loaderMask_circlle).loader = loader;
|
(item.img_cover as com_loaderMask_circlle).loader = loader;
|
||||||
item.img_cover.AddChild(loader);
|
item.img_cover.AddChild(loader);
|
||||||
loader.SetSize(item.img_cover.width, item.img_cover.height);
|
loader.SetSize(item.img_cover.width, item.img_cover.height);
|
||||||
|
|
||||||
var idx = i;
|
var idx = i;
|
||||||
tasks.Add((loader, LiveConfig[i].Name + "_cover", texture =>
|
tasks.Add((loader, LiveConfig[i].Name + "_cover", texture =>
|
||||||
{
|
{
|
||||||
if (texture != null) _fileIsExist[idx] = true;
|
if (texture != null) _fileIsExist[idx] = true;
|
||||||
}, "LiveAlbums/", FolderNames.VideoCoversName));
|
}, "LiveAlbums/", FolderNames.VideoCoversName));
|
||||||
|
|
||||||
activeLoaders[i] = loader;
|
activeLoaders[i] = loader;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TextureHelper.SetImgLoaders(tasks);
|
TextureHelper.SetImgLoaders(tasks);
|
||||||
|
|
||||||
Debug.Log($"[OnScrollEnd]==lastVisibleItems=== {lastVisibleItems.Count}");
|
Debug.Log($"[OnScrollEnd]==lastVisibleItems=== {lastVisibleItems.Count}");
|
||||||
VideoLoadScheduler.ClearAll();
|
VideoLoadScheduler.ClearAll();
|
||||||
// 1️⃣ 回收上一次的可见播放器
|
// 1️⃣ 回收上一次的可见播放器
|
||||||
foreach (var oldItem in lastVisibleItems)
|
foreach (var oldItem in lastVisibleItems)
|
||||||
if (dictionary_.TryGetValue(oldItem, out var player))
|
if (dictionary_.TryGetValue(oldItem, out var player))
|
||||||
{
|
{
|
||||||
player.Pause();
|
player.Pause();
|
||||||
player.targetTexture?.Release();
|
player.targetTexture?.Release();
|
||||||
VideoPlayerPool.Instance.ReturnPlayer(player);
|
VideoPlayerPool.Instance.ReturnPlayer(player);
|
||||||
dictionary_.Remove(oldItem);
|
dictionary_.Remove(oldItem);
|
||||||
oldItem.com_loader.visible = false;
|
oldItem.com_loader.visible = false;
|
||||||
oldItem.img_cover.visible = true;
|
oldItem.img_cover.visible = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
lastVisibleItems.Clear();
|
lastVisibleItems.Clear();
|
||||||
|
|
||||||
|
|
||||||
// 2️⃣ 获取当前可见项
|
// 2️⃣ 获取当前可见项
|
||||||
var firstIndex = ui.list_.GetFirstChildInView();
|
var firstIndex = ui.list_.GetFirstChildInView();
|
||||||
var lastIndex = Mathf.Min(firstIndex + MaxVisibleCount, ui.list_.numItems);
|
var lastIndex = Mathf.Min(firstIndex + MaxVisibleCount, ui.list_.numItems);
|
||||||
|
|
||||||
HashSet<item_live> newVisibleItems = new();
|
HashSet<item_live> newVisibleItems = new();
|
||||||
for (var i = firstIndex; i < lastIndex; i++)
|
for (var i = firstIndex; i < lastIndex; i++)
|
||||||
{
|
{
|
||||||
if (ui.list_.GetChildAt(i) is item_live item)
|
if (ui.list_.GetChildAt(i) is item_live item)
|
||||||
{
|
{
|
||||||
// 分配播放器
|
// 分配播放器
|
||||||
newVisibleItems.Add(item);
|
newVisibleItems.Add(item);
|
||||||
if (!dictionary_.ContainsKey(item))
|
if (!dictionary_.ContainsKey(item))
|
||||||
{
|
{
|
||||||
var player = VideoPlayerPool.Instance.GetPlayer();
|
var player = VideoPlayerPool.Instance.GetPlayer();
|
||||||
if (player != null)
|
if (player != null)
|
||||||
{
|
{
|
||||||
dictionary_[item] = player;
|
dictionary_[item] = player;
|
||||||
BindPlayerToItem(item, i);
|
BindPlayerToItem(item, i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3️⃣ 保存为“上一次可见项”
|
// 3️⃣ 保存为“上一次可见项”
|
||||||
lastVisibleItems = newVisibleItems;
|
lastVisibleItems = newVisibleItems;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void BindPlayerToItem(item_live item, int index)
|
private void BindPlayerToItem(item_live item, int index)
|
||||||
{
|
{
|
||||||
var data = PreDownloadManager.GetLiveDataByIndex(LiveConfig[index], index);
|
var data = PreDownloadManager.GetLiveDataByIndex(LiveConfig[index], index);
|
||||||
|
|
||||||
Debug.Log($"[绑定播放器 进度] progress==1=== {data.progress}");
|
Debug.Log($"[绑定播放器 进度] progress==1=== {data.progress}");
|
||||||
if (data.progress < 100) return;
|
if (data.progress < 100) return;
|
||||||
|
|
||||||
var player = dictionary_[item];
|
var player = dictionary_[item];
|
||||||
var loader = item.com_loader.GetChild("loader") as GLoader;
|
var loader = item.com_loader.GetChild("loader") as GLoader;
|
||||||
item.com_loader.visible = true;
|
item.com_loader.visible = true;
|
||||||
|
|
||||||
if (!loader_list.Contains(loader)) loader_list.Add(loader);
|
if (!loader_list.Contains(loader)) loader_list.Add(loader);
|
||||||
|
|
||||||
TextureHelper.SetVideoLoader(player, loader, LiveConfig[index].Name, vp =>
|
TextureHelper.SetVideoLoader(player, loader, LiveConfig[index].Name, vp =>
|
||||||
{
|
{
|
||||||
if (vp != null && !item.isDisposed)
|
if (vp != null && !item.isDisposed)
|
||||||
{
|
{
|
||||||
if (data.progress >= 100)
|
if (data.progress >= 100)
|
||||||
{
|
{
|
||||||
item.img_cover.visible = false;
|
item.img_cover.visible = false;
|
||||||
GameDispatcher.Instance.Dispatch(GameMsg.liveVideoLoaded);
|
GameDispatcher.Instance.Dispatch(GameMsg.liveVideoLoaded);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void RendererList(int index, GObject obj)
|
private void RendererList(int index, GObject obj)
|
||||||
{
|
{
|
||||||
var livedata_ = PreDownloadManager.GetLiveDataByIndex(LiveConfig[index], index);
|
var livedata_ = PreDownloadManager.GetLiveDataByIndex(LiveConfig[index], index);
|
||||||
|
|
||||||
var item = (item_live)obj;
|
var item = (item_live)obj;
|
||||||
|
|
||||||
// UI状态显示
|
// UI状态显示
|
||||||
item.state.selectedIndex = livedata_.progress < 100 ? 1 : 0;
|
item.state.selectedIndex = livedata_.progress < 100 ? 1 : 0;
|
||||||
|
|
||||||
if (LiveConfig[index].SubscribeUnlock == 1)
|
if (LiveConfig[index].SubscribeUnlock == 1)
|
||||||
{
|
{
|
||||||
if (livedata_.progress < 100) item.vip.selectedIndex = 1;
|
if (livedata_.progress < 100) item.vip.selectedIndex = 1;
|
||||||
else item.vip.selectedIndex = 2;
|
else item.vip.selectedIndex = 2;
|
||||||
}
|
}
|
||||||
else item.vip.selectedIndex = 0;
|
else item.vip.selectedIndex = 0;
|
||||||
|
|
||||||
item.img_mask.fillAmount = (float)(100 - livedata_.progress) / 100;
|
item.img_mask.fillAmount = (float)(100 - livedata_.progress) / 100;
|
||||||
|
|
||||||
// 点击事件
|
// 点击事件
|
||||||
item.SetClick(() =>
|
item.SetClick(() =>
|
||||||
{
|
{
|
||||||
if (GameHelper.GetLevel() < GameHelper.GetCommonModel().UnlockLive[1])
|
if (GameHelper.GetLevel() < GameHelper.GetCommonModel().UnlockLive[1])
|
||||||
{
|
{
|
||||||
if (DataMgr.IsUnlockLive.Value < 0 && !GameHelper.GetVipPrivilege(Subscription.UnlockLive.As<int>()))
|
if (DataMgr.IsUnlockLive.Value < 0 && !GameHelper.GetVipPrivilege(Subscription.UnlockLive.As<int>()))
|
||||||
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.SecretUnlockUI_Open, 2);
|
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.SecretUnlockUI_Open, 2);
|
||||||
else if (DataMgr.IsUnlockLive.Value == 0)
|
else if (DataMgr.IsUnlockLive.Value == 0)
|
||||||
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.UnlockTipsUI_Open, 2);
|
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.UnlockTipsUI_Open, 2);
|
||||||
else
|
else
|
||||||
HandleDetailOpen(item, index);
|
HandleDetailOpen(item, index);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
HandleDetailOpen(item, index);
|
HandleDetailOpen(item, index);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void HandleDetailOpen(item_live item, int index)
|
private void HandleDetailOpen(item_live item, int index)
|
||||||
{
|
{
|
||||||
dictionary_.TryGetValue(item, out var player);
|
dictionary_.TryGetValue(item, out var player);
|
||||||
// if (dictionary_.TryGetValue(item, out var player))
|
// if (dictionary_.TryGetValue(item, out var player))
|
||||||
uiCtrlDispatcher.Dispatch(UICtrlMsg.LiveDetailUI_Open, (index, player));
|
uiCtrlDispatcher.Dispatch(UICtrlMsg.LiveDetailUI_Open, (index, player));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnOpen(object args)
|
protected override void OnOpen(object args)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnHide()
|
protected override void OnHide()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnDisplay(object args)
|
protected override void OnDisplay(object args)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region 消息
|
#region 消息
|
||||||
|
|
||||||
protected override void AddListener()
|
protected override void AddListener()
|
||||||
{
|
{
|
||||||
GameDispatcher.Instance.AddListener(GameMsg.LiveChange, Refresh);
|
GameDispatcher.Instance.AddListener(GameMsg.LiveChange, Refresh);
|
||||||
HallManager.Instance.UpdateEvent += UpdateEvent;
|
HallManager.Instance.UpdateEvent += UpdateEvent;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void RemoveListener()
|
protected override void RemoveListener()
|
||||||
{
|
{
|
||||||
GameDispatcher.Instance.RemoveListener(GameMsg.LiveChange, Refresh);
|
GameDispatcher.Instance.RemoveListener(GameMsg.LiveChange, Refresh);
|
||||||
HallManager.Instance.UpdateEvent -= UpdateEvent;
|
HallManager.Instance.UpdateEvent -= UpdateEvent;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
||||||
public class LiveData
|
public class LiveData
|
||||||
{
|
{
|
||||||
public int AD_num;
|
public int AD_num;
|
||||||
public int progress;
|
public int progress;
|
||||||
public int Singleprogress;
|
public int Singleprogress;
|
||||||
public long LiveADTime;
|
public long LiveADTime;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -262,7 +262,7 @@ namespace RedHotRoast
|
|||||||
player.audioOutputMode = VideoAudioOutputMode.None;
|
player.audioOutputMode = VideoAudioOutputMode.None;
|
||||||
|
|
||||||
// 从配置表取配置(这里还是 List,如果有 Id 字段可改成字典)
|
// 从配置表取配置(这里还是 List,如果有 Id 字段可改成字典)
|
||||||
LiveConfig = ConfigSystem.GetConfig<Live>()[index];
|
LiveConfig = ConfigSystem.GetLiveConfig()[index];
|
||||||
|
|
||||||
livedata_ = PreDownloadManager.GetLiveDataByIndex(LiveConfig, index);
|
livedata_ = PreDownloadManager.GetLiveDataByIndex(LiveConfig, index);
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -51,9 +51,9 @@ namespace RedHotRoast
|
|||||||
InitView();
|
InitView();
|
||||||
// DOVirtual.DelayedCall(0.2f, () =>
|
// DOVirtual.DelayedCall(0.2f, () =>
|
||||||
// {
|
// {
|
||||||
// if (GameHelper.GetLevel() - 1 < ConfigSystem.GetConfig<LevelUnlock>().Count&&GameHelper.IsGiftSwitch())
|
// if (GameHelper.GetLevel() - 1 < ConfigSystem.GetLevelUnlockConfig().Count&&GameHelper.IsGiftSwitch())
|
||||||
// {
|
// {
|
||||||
// LevelUnlock levelUnlock_ = ConfigSystem.GetConfig<LevelUnlock>()[GameHelper.GetLevel() - 1];
|
// LevelUnlock levelUnlock_ = ConfigSystem.GetLevelUnlockConfig()[GameHelper.GetLevel() - 1];
|
||||||
// if (levelUnlock_.LeveType != 0)
|
// if (levelUnlock_.LeveType != 0)
|
||||||
// {
|
// {
|
||||||
// if (!DataMgr.LevelUnlockList.Value.Contains(GameHelper.GetLevel() - 1))
|
// if (!DataMgr.LevelUnlockList.Value.Contains(GameHelper.GetLevel() - 1))
|
||||||
|
|||||||
@@ -593,7 +593,7 @@ namespace RedHotRoast
|
|||||||
{
|
{
|
||||||
if (GameHelper.GetLevel() < GameHelper.GetCommonModel().MultiModal)
|
if (GameHelper.GetLevel() < GameHelper.GetCommonModel().MultiModal)
|
||||||
{
|
{
|
||||||
TextureHelper.setGamebg(ConfigSystem.GetConfig<LevelUnlock>()[GameHelper.GetLevel() - 1].Name);
|
TextureHelper.setGamebg(ConfigSystem.GetLevelUnlockConfig()[GameHelper.GetLevel() - 1].Name);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -603,27 +603,27 @@ namespace RedHotRoast
|
|||||||
{
|
{
|
||||||
if (levelunlock_.type == 0)
|
if (levelunlock_.type == 0)
|
||||||
{
|
{
|
||||||
if (levelunlock_.config_index >= ConfigSystem.GetConfig<FreeImageLibrary>().Count) levelunlock_.config_index = ConfigSystem.GetConfig<FreeImageLibrary>().Count - 1;
|
if (levelunlock_.config_index >= ConfigSystem.GetFreeImageConfig().Count) levelunlock_.config_index = ConfigSystem.GetFreeImageConfig().Count - 1;
|
||||||
FreeImageLibrary _leveldata = ConfigSystem.GetConfig<FreeImageLibrary>()[levelunlock_.config_index];
|
FreeImageLibrary _leveldata = ConfigSystem.GetFreeImageConfig()[levelunlock_.config_index];
|
||||||
TextureHelper.setGamebg(_leveldata.Name);
|
TextureHelper.setGamebg(_leveldata.Name);
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (levelunlock_.type == 1)
|
else if (levelunlock_.type == 1)
|
||||||
{
|
{
|
||||||
if (levelunlock_.config_index >= ConfigSystem.GetConfig<ADImageLibrary>().Count) levelunlock_.config_index = ConfigSystem.GetConfig<ADImageLibrary>().Count - 1;
|
if (levelunlock_.config_index >= ConfigSystem.GetADImageConfig().Count) levelunlock_.config_index = ConfigSystem.GetADImageConfig().Count - 1;
|
||||||
ADImageLibrary _leveldata = ConfigSystem.GetConfig<ADImageLibrary>()[levelunlock_.config_index];
|
ADImageLibrary _leveldata = ConfigSystem.GetADImageConfig()[levelunlock_.config_index];
|
||||||
TextureHelper.setGamebg(_leveldata.Name);
|
TextureHelper.setGamebg(_leveldata.Name);
|
||||||
}
|
}
|
||||||
else if (levelunlock_.type == 2)
|
else if (levelunlock_.type == 2)
|
||||||
{
|
{
|
||||||
if (levelunlock_.config_index >= ConfigSystem.GetConfig<SpecialImageLibrary>().Count) levelunlock_.config_index = ConfigSystem.GetConfig<SpecialImageLibrary>().Count - 1;
|
if (levelunlock_.config_index >= ConfigSystem.GetSpecialImageConfig().Count) levelunlock_.config_index = ConfigSystem.GetSpecialImageConfig().Count - 1;
|
||||||
SpecialImageLibrary _leveldata = ConfigSystem.GetConfig<SpecialImageLibrary>()[levelunlock_.config_index];
|
SpecialImageLibrary _leveldata = ConfigSystem.GetSpecialImageConfig()[levelunlock_.config_index];
|
||||||
TextureHelper.setGamebg(_leveldata.Name);
|
TextureHelper.setGamebg(_leveldata.Name);
|
||||||
}
|
}
|
||||||
else if (levelunlock_.type == 3)
|
else if (levelunlock_.type == 3)
|
||||||
{
|
{
|
||||||
if (levelunlock_.config_index >= ConfigSystem.GetConfig<VIPImageLibrary>().Count) levelunlock_.config_index = ConfigSystem.GetConfig<VIPImageLibrary>().Count - 1;
|
if (levelunlock_.config_index >= ConfigSystem.GetVIPImageConfig().Count) levelunlock_.config_index = ConfigSystem.GetVIPImageConfig().Count - 1;
|
||||||
VIPImageLibrary _leveldata = ConfigSystem.GetConfig<VIPImageLibrary>()[levelunlock_.config_index];
|
VIPImageLibrary _leveldata = ConfigSystem.GetVIPImageConfig()[levelunlock_.config_index];
|
||||||
TextureHelper.setGamebg(_leveldata.Name);
|
TextureHelper.setGamebg(_leveldata.Name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -633,13 +633,13 @@ namespace RedHotRoast
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (GameHelper.GetLevel() - 1 < ConfigSystem.GetConfig<LevelUnlock>().Count)
|
if (GameHelper.GetLevel() - 1 < ConfigSystem.GetLevelUnlockConfig().Count)
|
||||||
{
|
{
|
||||||
TextureHelper.setGamebg(ConfigSystem.GetConfig<LevelUnlock>()[GameHelper.GetLevel() - 1].Name);
|
TextureHelper.setGamebg(ConfigSystem.GetLevelUnlockConfig()[GameHelper.GetLevel() - 1].Name);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
TextureHelper.setGamebg(ConfigSystem.GetConfig<LevelUnlock>()[ConfigSystem.GetConfig<LevelUnlock>().Count - 1].Name);
|
TextureHelper.setGamebg(ConfigSystem.GetLevelUnlockConfig()[ConfigSystem.GetLevelUnlockConfig().Count - 1].Name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,308 +1,308 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using AppsFlyerSDK;
|
using AppsFlyerSDK;
|
||||||
using IgnoreOPS;
|
using IgnoreOPS;
|
||||||
using SGModule.Common.Extensions;
|
using SGModule.Common.Extensions;
|
||||||
using SGModule.Net;
|
using SGModule.Net;
|
||||||
using SGModule.NetKit;
|
using SGModule.NetKit;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace RedHotRoast
|
namespace RedHotRoast
|
||||||
{
|
{
|
||||||
public class RainPlayUICtrl : BaseUICtrl
|
public class RainPlayUICtrl : BaseUICtrl
|
||||||
{
|
{
|
||||||
private RainPlayUI ui;
|
private RainPlayUI ui;
|
||||||
private RainPlayModel model;
|
private RainPlayModel model;
|
||||||
|
|
||||||
private uint openUIMsg = UICtrlMsg.RainPlayUI_Open;
|
private uint openUIMsg = UICtrlMsg.RainPlayUI_Open;
|
||||||
private uint closeUIMsg = UICtrlMsg.RainPlayUI_Close;
|
private uint closeUIMsg = UICtrlMsg.RainPlayUI_Close;
|
||||||
|
|
||||||
#region 生命周期
|
#region 生命周期
|
||||||
protected override void OnInit()
|
protected override void OnInit()
|
||||||
{
|
{
|
||||||
//model = ModuleManager.Instance.GetModel(ModelConst.RainPlayModel) as RainPlayModel;
|
//model = ModuleManager.Instance.GetModel(ModelConst.RainPlayModel) as RainPlayModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnDispose()
|
protected override void OnDispose()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OpenUI(object args = null)
|
public override void OpenUI(object args = null)
|
||||||
{
|
{
|
||||||
if (ui == null)
|
if (ui == null)
|
||||||
{
|
{
|
||||||
ui = new RainPlayUI(this);
|
ui = new RainPlayUI(this);
|
||||||
ui.Open(args);
|
ui.Open(args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void CloseUI(object args = null)
|
public override void CloseUI(object args = null)
|
||||||
{
|
{
|
||||||
if (ui != null && !ui.isClose)
|
if (ui != null && !ui.isClose)
|
||||||
{
|
{
|
||||||
ui.Close();
|
ui.Close();
|
||||||
}
|
}
|
||||||
ui = null;
|
ui = null;
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region 消息
|
#region 消息
|
||||||
public override uint GetOpenUIMsg(string uiName)
|
public override uint GetOpenUIMsg(string uiName)
|
||||||
{
|
{
|
||||||
return openUIMsg;
|
return openUIMsg;
|
||||||
}
|
}
|
||||||
public override uint GetCloseUIMsg(string uiName)
|
public override uint GetCloseUIMsg(string uiName)
|
||||||
{
|
{
|
||||||
return closeUIMsg;
|
return closeUIMsg;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void AddListener()
|
protected override void AddListener()
|
||||||
{
|
{
|
||||||
uiCtrlDispatcher.AddListener(openUIMsg, OpenUI);
|
uiCtrlDispatcher.AddListener(openUIMsg, OpenUI);
|
||||||
uiCtrlDispatcher.AddListener(closeUIMsg, CloseUI);
|
uiCtrlDispatcher.AddListener(closeUIMsg, CloseUI);
|
||||||
GameDispatcher.Instance.AddListener(GameMsg.apple_pay_success, pay_success);
|
GameDispatcher.Instance.AddListener(GameMsg.apple_pay_success, pay_success);
|
||||||
|
|
||||||
}
|
}
|
||||||
protected override void RemoveListener()
|
protected override void RemoveListener()
|
||||||
{
|
{
|
||||||
uiCtrlDispatcher.RemoveListener(openUIMsg, OpenUI);
|
uiCtrlDispatcher.RemoveListener(openUIMsg, OpenUI);
|
||||||
uiCtrlDispatcher.RemoveListener(closeUIMsg, CloseUI);
|
uiCtrlDispatcher.RemoveListener(closeUIMsg, CloseUI);
|
||||||
GameDispatcher.Instance.RemoveListener(GameMsg.apple_pay_success, pay_success);
|
GameDispatcher.Instance.RemoveListener(GameMsg.apple_pay_success, pay_success);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void AddServerListener()
|
protected override void AddServerListener()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
protected override void RemoveServerListener()
|
protected override void RemoveServerListener()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void GetPayReward(decimal goldNum)
|
private void GetPayReward(decimal goldNum)
|
||||||
{
|
{
|
||||||
if (goldNum == 0) return;
|
if (goldNum == 0) return;
|
||||||
|
|
||||||
var start = new Vector2(540, 960);
|
var start = new Vector2(540, 960);
|
||||||
var end = new Vector2(236, 62);
|
var end = new Vector2(236, 62);
|
||||||
var rewardData = new RewardData();
|
var rewardData = new RewardData();
|
||||||
var rewardSingleData = new RewardSingleData(101, goldNum, RewardOrigin.AdTask)
|
var rewardSingleData = new RewardSingleData(101, goldNum, RewardOrigin.AdTask)
|
||||||
{
|
{
|
||||||
startPosition = start,
|
startPosition = start,
|
||||||
};
|
};
|
||||||
rewardData.AddReward(rewardSingleData);
|
rewardData.AddReward(rewardSingleData);
|
||||||
rewardData.displayType = RewardDisplayType.RewardFly | RewardDisplayType.ValueChange;
|
rewardData.displayType = RewardDisplayType.RewardFly | RewardDisplayType.ValueChange;
|
||||||
|
|
||||||
GameDispatcher.Instance.Dispatch(GameMsg.GetReward, rewardData);
|
GameDispatcher.Instance.Dispatch(GameMsg.GetReward, rewardData);
|
||||||
}
|
}
|
||||||
|
|
||||||
void pay_success(object str)
|
void pay_success(object str)
|
||||||
{
|
{
|
||||||
bool is_maxPay = false; // 第三方支付
|
bool is_maxPay = false; // 第三方支付
|
||||||
string type = (string)str;
|
string type = (string)str;
|
||||||
string purch_number = "";
|
string purch_number = "";
|
||||||
if (type.Contains("buy_gold"))
|
if (type.Contains("buy_gold"))
|
||||||
{
|
{
|
||||||
if (type.StartsWith("buy_gold"))
|
if (type.StartsWith("buy_gold"))
|
||||||
{
|
{
|
||||||
int startIndex = "buy_gold".Length;
|
int startIndex = "buy_gold".Length;
|
||||||
string suffix = type[startIndex..]; // 截取 "gold" 后的所有字符
|
string suffix = type[startIndex..]; // 截取 "gold" 后的所有字符
|
||||||
int suffix_num = int.Parse(suffix);
|
int suffix_num = int.Parse(suffix);
|
||||||
|
|
||||||
purch_number = ConfigSystem.GetConfig<Paidcoins>()[suffix_num].Payment_amount2.ToString();
|
purch_number = ConfigSystem.GetConfig<Paidcoins>()[suffix_num].Payment_amount2.ToString();
|
||||||
|
|
||||||
if (!UIManager.Instance.IsExistUI(UIConst.BuygoldUI))
|
if (!UIManager.Instance.IsExistUI(UIConst.BuygoldUI))
|
||||||
{
|
{
|
||||||
List<Paidcoins> list = ConfigSystem.GetConfig<Paidcoins>();
|
List<Paidcoins> list = ConfigSystem.GetConfig<Paidcoins>();
|
||||||
// GameHelper.AddGoldNumber(list[suffix_num].Actual_coins);
|
// GameHelper.AddGoldNumber(list[suffix_num].Actual_coins);
|
||||||
int gold_num = list[suffix_num].Actual_coins;
|
int gold_num = list[suffix_num].Actual_coins;
|
||||||
GetPayReward(gold_num);
|
GetPayReward(gold_num);
|
||||||
SaveData.GetSaveObject()._goldtime[suffix_num] = (int)GameHelper.GetNowTime();
|
SaveData.GetSaveObject()._goldtime[suffix_num] = (int)GameHelper.GetNowTime();
|
||||||
SaveData.SaveDataFunc();
|
SaveData.SaveDataFunc();
|
||||||
GameDispatcher.Instance.Dispatch(GameMsg.Gold_refresh);
|
GameDispatcher.Instance.Dispatch(GameMsg.Gold_refresh);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (type == PurchasingManager.GetPaySku(PayType.battle_pass))
|
else if (type == PurchasingManager.GetPaySku(PayType.battle_pass))
|
||||||
{
|
{
|
||||||
SaveData.GetSaveObject().is_get_battlepass = true;
|
SaveData.GetSaveObject().is_get_battlepass = true;
|
||||||
int gold = 0;
|
int gold = 0;
|
||||||
int out_ = 0;
|
int out_ = 0;
|
||||||
int back_ = 0;
|
int back_ = 0;
|
||||||
int refresh_ = 0;
|
int refresh_ = 0;
|
||||||
List<Passportrewards> Passportrewards_list = ConfigSystem.GetConfig<Passportrewards>();
|
List<Passportrewards> Passportrewards_list = ConfigSystem.GetConfig<Passportrewards>();
|
||||||
for (int i = 0; i < Passportrewards_list.Count; i++)
|
for (int i = 0; i < Passportrewards_list.Count; i++)
|
||||||
{
|
{
|
||||||
if (GameHelper.GetBattleLv() > i || (GameHelper.GetGameExp() >= Passportrewards_list[Passportrewards_list.Count - 1].Eliminating_quantity))
|
if (GameHelper.GetBattleLv() > i || (GameHelper.GetGameExp() >= Passportrewards_list[Passportrewards_list.Count - 1].Eliminating_quantity))
|
||||||
{
|
{
|
||||||
if (Passportrewards_list[i].Paid_rewards_type == 0) gold += Passportrewards_list[i].Paid_rewards_num;
|
if (Passportrewards_list[i].Paid_rewards_type == 0) gold += Passportrewards_list[i].Paid_rewards_num;
|
||||||
else if (Passportrewards_list[i].Paid_rewards_type == 1) out_ += Passportrewards_list[i].Paid_rewards_num;
|
else if (Passportrewards_list[i].Paid_rewards_type == 1) out_ += Passportrewards_list[i].Paid_rewards_num;
|
||||||
else if (Passportrewards_list[i].Paid_rewards_type == 2) back_ += Passportrewards_list[i].Paid_rewards_num;
|
else if (Passportrewards_list[i].Paid_rewards_type == 2) back_ += Passportrewards_list[i].Paid_rewards_num;
|
||||||
else if (Passportrewards_list[i].Paid_rewards_type == 3) refresh_ += Passportrewards_list[i].Paid_rewards_num;
|
else if (Passportrewards_list[i].Paid_rewards_type == 3) refresh_ += Passportrewards_list[i].Paid_rewards_num;
|
||||||
SaveData.GetSaveObject().battle_pass_paylist.Add(i + 1);
|
SaveData.GetSaveObject().battle_pass_paylist.Add(i + 1);
|
||||||
}
|
}
|
||||||
else break;
|
else break;
|
||||||
}
|
}
|
||||||
var purch = ConfigSystem.GetCommonConf().Passportgift2;
|
var purch = ConfigSystem.GetCommonConf().Passportgift2;
|
||||||
purch_number = purch.ToString();
|
purch_number = purch.ToString();
|
||||||
if (UIManager.Instance.IsExistUI(UIConst.PassViewUI))
|
if (UIManager.Instance.IsExistUI(UIConst.PassViewUI))
|
||||||
{
|
{
|
||||||
GameHelper.AddItemNumber(0, out_);
|
GameHelper.AddItemNumber(0, out_);
|
||||||
GameHelper.AddItemNumber(1, back_);
|
GameHelper.AddItemNumber(1, back_);
|
||||||
GameHelper.AddItemNumber(2, refresh_);
|
GameHelper.AddItemNumber(2, refresh_);
|
||||||
GameDispatcher.Instance.Dispatch(GameMsg.Sheep_item_refresh);
|
GameDispatcher.Instance.Dispatch(GameMsg.Sheep_item_refresh);
|
||||||
// DataMgr.Coin.Value += gold;
|
// DataMgr.Coin.Value += gold;
|
||||||
GetPayReward(gold);
|
GetPayReward(gold);
|
||||||
GameDispatcher.Instance.Dispatch(GameMsg.Gold_refresh);
|
GameDispatcher.Instance.Dispatch(GameMsg.Gold_refresh);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (type == PurchasingManager.GetPaySku(PayType.buy_one))
|
else if (type == PurchasingManager.GetPaySku(PayType.buy_one))
|
||||||
{
|
{
|
||||||
SaveData.GetSaveObject().have_slot = true;
|
SaveData.GetSaveObject().have_slot = true;
|
||||||
SaveData.SaveDataFunc();
|
SaveData.SaveDataFunc();
|
||||||
GameDispatcher.Instance.Dispatch(GameMsg.Slot_refresh);
|
GameDispatcher.Instance.Dispatch(GameMsg.Slot_refresh);
|
||||||
GameHelper.ShowTips("purchase_succ", true);
|
GameHelper.ShowTips("purchase_succ", true);
|
||||||
|
|
||||||
purch_number = GameHelper.GetCommonModel().addspace2.ToString();
|
purch_number = GameHelper.GetCommonModel().addspace2.ToString();
|
||||||
}
|
}
|
||||||
else if (type == PurchasingManager.GetPaySku(PayType.remove_ad))
|
else if (type == PurchasingManager.GetPaySku(PayType.remove_ad))
|
||||||
{
|
{
|
||||||
SaveData.GetSaveObject().remove_ad_time = (int)GameHelper.GetNowTime() + GameHelper.GetCommonModel().RemoveADsPackDuration * 3600;
|
SaveData.GetSaveObject().remove_ad_time = (int)GameHelper.GetNowTime() + GameHelper.GetCommonModel().RemoveADsPackDuration * 3600;
|
||||||
SaveData.GetSaveObject().is_get_removead = true;
|
SaveData.GetSaveObject().is_get_removead = true;
|
||||||
SaveData.SaveDataFunc();
|
SaveData.SaveDataFunc();
|
||||||
// GameHelper.AddGoldNumber(ConfigSystem.GetConfig<PaidgiftModel>().DataList[1].coins_quantity);
|
// GameHelper.AddGoldNumber(ConfigSystem.GetConfig<PaidgiftModel>().DataList[1].coins_quantity);
|
||||||
// GameDispatcher.Instance.Dispatch(GameMsg.Gold_refresh);
|
// GameDispatcher.Instance.Dispatch(GameMsg.Gold_refresh);
|
||||||
ui?.setBtnAds();
|
ui?.setBtnAds();
|
||||||
GameDispatcher.Instance.Dispatch(GameMsg.UpdateNoads);
|
GameDispatcher.Instance.Dispatch(GameMsg.UpdateNoads);
|
||||||
GameHelper.ShowTips("purchase_succ", true);
|
GameHelper.ShowTips("purchase_succ", true);
|
||||||
purch_number = ConfigSystem.GetConfig<Paidgift>()[1].Paid_price2.ToString();
|
purch_number = ConfigSystem.GetConfig<Paidgift>()[1].Paid_price2.ToString();
|
||||||
}
|
}
|
||||||
else if (type == PurchasingManager.GetPaySku(PayType.pack_reward))
|
else if (type == PurchasingManager.GetPaySku(PayType.pack_reward))
|
||||||
{
|
{
|
||||||
List<Paidgift> list = ConfigSystem.GetConfig<Paidgift>();
|
List<Paidgift> list = ConfigSystem.GetConfig<Paidgift>();
|
||||||
int gold_num = list[0].coins_quantity;
|
int gold_num = list[0].coins_quantity;
|
||||||
int back_num = list[0].props_quantity[1];
|
int back_num = list[0].props_quantity[1];
|
||||||
int out_num = list[0].props_quantity[0];
|
int out_num = list[0].props_quantity[0];
|
||||||
int refresh_num = list[0].props_quantity[2];
|
int refresh_num = list[0].props_quantity[2];
|
||||||
|
|
||||||
GameHelper.AddItemNumber(0, out_num);
|
GameHelper.AddItemNumber(0, out_num);
|
||||||
GameHelper.AddItemNumber(1, back_num);
|
GameHelper.AddItemNumber(1, back_num);
|
||||||
GameHelper.AddItemNumber(2, refresh_num);
|
GameHelper.AddItemNumber(2, refresh_num);
|
||||||
SaveData.GetSaveObject().is_get_packreward = true;
|
SaveData.GetSaveObject().is_get_packreward = true;
|
||||||
SaveData.SaveDataFunc();
|
SaveData.SaveDataFunc();
|
||||||
GameDispatcher.Instance.Dispatch(GameMsg.Gold_refresh);
|
GameDispatcher.Instance.Dispatch(GameMsg.Gold_refresh);
|
||||||
GameDispatcher.Instance.Dispatch(GameMsg.Sheep_item_refresh);
|
GameDispatcher.Instance.Dispatch(GameMsg.Sheep_item_refresh);
|
||||||
ui?.setBtnAds();
|
ui?.setBtnAds();
|
||||||
GameDispatcher.Instance.Dispatch(GameMsg.UpdateNoads);
|
GameDispatcher.Instance.Dispatch(GameMsg.UpdateNoads);
|
||||||
GameHelper.ShowTips("purchase_succ", true);
|
GameHelper.ShowTips("purchase_succ", true);
|
||||||
purch_number = ConfigSystem.GetConfig<Paidgift>()[0].Paid_price2.ToString();
|
purch_number = ConfigSystem.GetConfig<Paidgift>()[0].Paid_price2.ToString();
|
||||||
}
|
}
|
||||||
else if (type == PurchasingManager.GetPaySku(PayType.fail_pack))
|
else if (type == PurchasingManager.GetPaySku(PayType.fail_pack))
|
||||||
{
|
{
|
||||||
List<Paidgift> list = ConfigSystem.GetConfig<Paidgift>();
|
List<Paidgift> list = ConfigSystem.GetConfig<Paidgift>();
|
||||||
purch_number = ConfigSystem.GetConfig<Paidgift>()[2].Paid_price2.ToString();
|
purch_number = ConfigSystem.GetConfig<Paidgift>()[2].Paid_price2.ToString();
|
||||||
//ui?.setBtnAds();
|
//ui?.setBtnAds();
|
||||||
GameDispatcher.Instance.Dispatch(GameMsg.resurgence);
|
GameDispatcher.Instance.Dispatch(GameMsg.resurgence);
|
||||||
|
|
||||||
// DataMgr.Coin.Value += ConfigSystem.GetConfig<PaidgiftModel>().DataList[1].coins_quantity;
|
// DataMgr.Coin.Value += ConfigSystem.GetConfig<PaidgiftModel>().DataList[1].coins_quantity;
|
||||||
// GameDispatcher.Instance.Dispatch(GameMsg.Gold_refresh);
|
// GameDispatcher.Instance.Dispatch(GameMsg.Gold_refresh);
|
||||||
int back_num = list[2].props_quantity[1];
|
int back_num = list[2].props_quantity[1];
|
||||||
int out_num = list[2].props_quantity[0];
|
int out_num = list[2].props_quantity[0];
|
||||||
int refresh_num = list[2].props_quantity[2];
|
int refresh_num = list[2].props_quantity[2];
|
||||||
//GameHelper.addGoldNumber(gold_num);
|
//GameHelper.addGoldNumber(gold_num);
|
||||||
int gold_num = list[2].coins_quantity;
|
int gold_num = list[2].coins_quantity;
|
||||||
if (!UIManager.Instance.IsExistUI(UIConst.ResurgenceUI)) DataMgr.Coin.Value += gold_num;
|
if (!UIManager.Instance.IsExistUI(UIConst.ResurgenceUI)) DataMgr.Coin.Value += gold_num;
|
||||||
GameHelper.AddItemNumber(0, out_num);
|
GameHelper.AddItemNumber(0, out_num);
|
||||||
GameHelper.AddItemNumber(1, back_num);
|
GameHelper.AddItemNumber(1, back_num);
|
||||||
GameHelper.AddItemNumber(2, refresh_num);
|
GameHelper.AddItemNumber(2, refresh_num);
|
||||||
GameDispatcher.Instance.Dispatch(GameMsg.Sheep_item_refresh);
|
GameDispatcher.Instance.Dispatch(GameMsg.Sheep_item_refresh);
|
||||||
SaveData.SaveDataFunc();
|
SaveData.SaveDataFunc();
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (type == PurchasingManager.GetPaySku(PayType.three_days_gift))
|
else if (type == PurchasingManager.GetPaySku(PayType.three_days_gift))
|
||||||
{
|
{
|
||||||
SaveData.GetSaveObject().is_get_ThreeDaysGift = true;
|
SaveData.GetSaveObject().is_get_ThreeDaysGift = true;
|
||||||
SaveData.SaveDataFunc();
|
SaveData.SaveDataFunc();
|
||||||
purch_number = ConfigSystem.GetConfig<Multigift>()[0].Paid_price2.ToString();
|
purch_number = ConfigSystem.GetConfig<Multigift>()[0].Paid_price2.ToString();
|
||||||
}
|
}
|
||||||
else if (type.StartsWith("vip_club"))
|
else if (type.StartsWith("vip_club"))
|
||||||
{
|
{
|
||||||
is_maxPay = true;
|
is_maxPay = true;
|
||||||
int startIndex = "vip_club".Length;
|
int startIndex = "vip_club".Length;
|
||||||
string suffix = type[startIndex..]; // 截取 "gold" 后的所有字符
|
string suffix = type[startIndex..]; // 截取 "gold" 后的所有字符
|
||||||
int suffixNum = int.Parse(suffix);
|
int suffixNum = int.Parse(suffix);
|
||||||
|
|
||||||
if (!MaxPayManager.isIOSPay)
|
if (!MaxPayManager.isIOSPay)
|
||||||
{
|
{
|
||||||
var days = 0;
|
var days = 0;
|
||||||
switch (suffixNum)
|
switch (suffixNum)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
days = (int)VipDay.Week;
|
days = (int)VipDay.Week;
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
days = (int)VipDay.Month;
|
days = (int)VipDay.Month;
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
days = (int)VipDay.Year;
|
days = (int)VipDay.Year;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (days > 0)
|
if (days > 0)
|
||||||
{
|
{
|
||||||
// 设置 VIP 到期时间(当前时间戳 + VIP 天数对应的秒数)
|
// 设置 VIP 到期时间(当前时间戳 + VIP 天数对应的秒数)
|
||||||
if (DataMgr.VipExpirationTime.Value > ServerClock.GetCurrentServerTime())
|
if (DataMgr.VipExpirationTime.Value > ServerClock.GetCurrentServerTime())
|
||||||
{
|
{
|
||||||
DataMgr.VipExpirationTime.Value = DataMgr.VipExpirationTime.Value + days * 24 * 60 * 60;
|
DataMgr.VipExpirationTime.Value = DataMgr.VipExpirationTime.Value + days * 24 * 60 * 60;
|
||||||
}
|
}
|
||||||
else DataMgr.VipExpirationTime.Value = ServerClock.GetCurrentServerTime() + days * 24 * 60 * 60;
|
else DataMgr.VipExpirationTime.Value = ServerClock.GetCurrentServerTime() + days * 24 * 60 * 60;
|
||||||
}
|
}
|
||||||
DataMgr.VipLevel.Value = suffixNum + 1;
|
DataMgr.VipLevel.Value = suffixNum + 1;
|
||||||
}
|
}
|
||||||
purch_number = ConfigSystem.GetConfig<VipClub>()[suffixNum].DiscountPrice.ToString();
|
purch_number = ConfigSystem.GetConfig<VipClub>()[suffixNum].DiscountPrice.ToString();
|
||||||
GameDispatcher.Instance.Dispatch(GameMsg.BuyVip);
|
GameDispatcher.Instance.Dispatch(GameMsg.BuyVip);
|
||||||
}
|
}
|
||||||
else if (type.StartsWith("secret_albnums"))
|
else if (type.StartsWith("secret_albnums"))
|
||||||
{
|
{
|
||||||
is_maxPay = true;
|
is_maxPay = true;
|
||||||
int startIndex = "secret_albnums".Length;
|
int startIndex = "secret_albnums".Length;
|
||||||
string suffix = type[startIndex..]; // 截取 "gold" 后的所有字符
|
string suffix = type[startIndex..]; // 截取 "gold" 后的所有字符
|
||||||
int suffix_num = int.Parse(suffix);
|
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 && !GameHelper.isVipUnlock)
|
if (model.PayType == (int)UnlockPayType.Pay && !GameHelper.isVipUnlock)
|
||||||
{
|
{
|
||||||
purch_number = ConfigSystem.GetConfig<SecretAlbums>()[suffix_num].DiscountPrice.ToString();
|
purch_number = ConfigSystem.GetSecretAlbumsConfig()[suffix_num].DiscountPrice.ToString();
|
||||||
}
|
}
|
||||||
GameHelper.isVipUnlock = false;
|
GameHelper.isVipUnlock = false;
|
||||||
}
|
}
|
||||||
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.PayloadingUI_Close);
|
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.PayloadingUI_Close);
|
||||||
|
|
||||||
if ((!GameHelper.IsAdModelOfPay() || is_maxPay) && !string.IsNullOrEmpty(purch_number) && decimal.TryParse(purch_number, out decimal revenue))
|
if ((!GameHelper.IsAdModelOfPay() || is_maxPay) && !string.IsNullOrEmpty(purch_number) && decimal.TryParse(purch_number, out decimal revenue))
|
||||||
{
|
{
|
||||||
var revenueNum = (int)(purch_number.As<decimal>() * 10000);
|
var revenueNum = (int)(purch_number.As<decimal>() * 10000);
|
||||||
var payType = MaxPayManager.isIOSPay ? 0 : 1;
|
var payType = MaxPayManager.isIOSPay ? 0 : 1;
|
||||||
|
|
||||||
// 付费上报BI
|
// 付费上报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);
|
Debug.Log("付费收益上报AF----------- " + revenue);
|
||||||
adCallbackInfo.Clear();
|
adCallbackInfo.Clear();
|
||||||
adCallbackInfo.Add("appsflyer_id", AppsFlyer.getAppsFlyerId());
|
adCallbackInfo.Add("appsflyer_id", AppsFlyer.getAppsFlyerId());
|
||||||
adCallbackInfo.Add("customer_user_id", GameHelper.GetLoginModel().Uid.ToString());
|
adCallbackInfo.Add("customer_user_id", GameHelper.GetLoginModel().Uid.ToString());
|
||||||
adCallbackInfo.Add("af_currency", "USD");
|
adCallbackInfo.Add("af_currency", "USD");
|
||||||
adCallbackInfo.Add("af_revenue", revenue.ToString(CultureInfo.InvariantCulture));
|
adCallbackInfo.Add("af_revenue", revenue.ToString(CultureInfo.InvariantCulture));
|
||||||
AppsFlyer.sendEvent("af_purchase", adCallbackInfo);
|
AppsFlyer.sendEvent("af_purchase", adCallbackInfo);
|
||||||
|
|
||||||
TrackKit.SendEvent(AfPurchaseTrack.Event, AfPurchaseTrack.Property.af_revenue, (int)(purch_number.As<decimal>() * 10000));
|
TrackKit.SendEvent(AfPurchaseTrack.Event, AfPurchaseTrack.Property.af_revenue, (int)(purch_number.As<decimal>() * 10000));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
public static Dictionary<string, string> adCallbackInfo = new Dictionary<string, string>();
|
public static Dictionary<string, string> adCallbackInfo = new Dictionary<string, string>();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,378 +1,378 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using FairyGUI;
|
using FairyGUI;
|
||||||
using FGUI.LG_secretAlbums;
|
using FGUI.LG_secretAlbums;
|
||||||
using SGModule.NetKit;
|
using SGModule.NetKit;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace RedHotRoast
|
namespace RedHotRoast
|
||||||
{
|
{
|
||||||
public class SecretAlbumsUI : BaseUI
|
public class SecretAlbumsUI : BaseUI
|
||||||
{
|
{
|
||||||
private const int MaxVisibleCount = 6; // 一屏显示6个
|
private const int MaxVisibleCount = 6; // 一屏显示6个
|
||||||
private const int PreloadCount = 2; // 上下各预加载一屏
|
private const int PreloadCount = 2; // 上下各预加载一屏
|
||||||
|
|
||||||
private readonly Dictionary<int, bool> _fileIsExist = new();
|
private readonly Dictionary<int, bool> _fileIsExist = new();
|
||||||
private readonly Dictionary<int, GLoader> activeLoaders = new();
|
private readonly Dictionary<int, GLoader> activeLoaders = new();
|
||||||
private SecretAlbumsUICtrl ctrl;
|
private SecretAlbumsUICtrl ctrl;
|
||||||
private SecretAlbumsModel model;
|
private SecretAlbumsModel model;
|
||||||
private com_scAlbums ui;
|
private com_scAlbums ui;
|
||||||
|
|
||||||
public SecretAlbumsUI(SecretAlbumsUICtrl ctrl) : base(ctrl)
|
public SecretAlbumsUI(SecretAlbumsUICtrl ctrl) : base(ctrl)
|
||||||
{
|
{
|
||||||
uiName = UIConst.SecretAlbumsUI;
|
uiName = UIConst.SecretAlbumsUI;
|
||||||
this.ctrl = ctrl;
|
this.ctrl = ctrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void SetUIInfo(UIInfo uiInfo)
|
protected override void SetUIInfo(UIInfo uiInfo)
|
||||||
{
|
{
|
||||||
uiInfo.packageName = "LG_secretAlbums";
|
uiInfo.packageName = "LG_secretAlbums";
|
||||||
uiInfo.assetName = "com_scAlbums";
|
uiInfo.assetName = "com_scAlbums";
|
||||||
uiInfo.layerType = UILayerType.Popup;
|
uiInfo.layerType = UILayerType.Popup;
|
||||||
uiInfo.isNeedOpenAnim = false;
|
uiInfo.isNeedOpenAnim = false;
|
||||||
uiInfo.isNeedCloseAnim = false;
|
uiInfo.isNeedCloseAnim = false;
|
||||||
uiInfo.isNeedUIMask = true;
|
uiInfo.isNeedUIMask = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UnlockSuccess(object str = null)
|
private void UnlockSuccess(object str = null)
|
||||||
{
|
{
|
||||||
ui.sc_list.itemRenderer = ItemRender;
|
ui.sc_list.itemRenderer = ItemRender;
|
||||||
ui.sc_list.numItems = _secretData.Count;
|
ui.sc_list.numItems = _secretData.Count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// 初始化页面逻辑
|
// 初始化页面逻辑
|
||||||
private void InitView()
|
private void InitView()
|
||||||
{
|
{
|
||||||
ui.btn_gold.GetChild("text_gold").text = GameHelper.Get101Str();
|
ui.btn_gold.GetChild("text_gold").text = GameHelper.Get101Str();
|
||||||
ui.btn_close.SetClick(CtrlCloseUI);
|
ui.btn_close.SetClick(CtrlCloseUI);
|
||||||
|
|
||||||
UnlockSuccess();
|
UnlockSuccess();
|
||||||
|
|
||||||
|
|
||||||
// 滚动过程中实时刷新可见播放器
|
// 滚动过程中实时刷新可见播放器
|
||||||
// ui.sc_list.scrollPane.onScrollEnd.Add(OnScrollEnd);
|
// ui.sc_list.scrollPane.onScrollEnd.Add(OnScrollEnd);
|
||||||
|
|
||||||
// 打开页面时初始化一次
|
// 打开页面时初始化一次
|
||||||
// OnScrollEnd();
|
// OnScrollEnd();
|
||||||
InitScroll();
|
InitScroll();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void InitScroll()
|
private void InitScroll()
|
||||||
{
|
{
|
||||||
ui.sc_list.scrollPane.onScroll.Add(OnScrollUpdate);
|
ui.sc_list.scrollPane.onScroll.Add(OnScrollUpdate);
|
||||||
ui.sc_list.scrollPane.onScrollEnd.Add(OnScrollEnd); // 保留结束时的整理
|
ui.sc_list.scrollPane.onScrollEnd.Add(OnScrollEnd); // 保留结束时的整理
|
||||||
|
|
||||||
OnScrollEnd();
|
OnScrollEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 滑动过程中实时更新
|
// 滑动过程中实时更新
|
||||||
private void OnScrollUpdate()
|
private void OnScrollUpdate()
|
||||||
{
|
{
|
||||||
UpdateVisibleAndPreload();
|
UpdateVisibleAndPreload();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 核心刷新逻辑
|
// 核心刷新逻辑
|
||||||
private void UpdateVisibleAndPreload()
|
private void UpdateVisibleAndPreload()
|
||||||
{
|
{
|
||||||
if (_secretData == null || _secretData.Count == 0) return;
|
if (_secretData == null || _secretData.Count == 0) return;
|
||||||
|
|
||||||
var firstVisibleIndex = ui.sc_list.GetFirstChildInView();
|
var firstVisibleIndex = ui.sc_list.GetFirstChildInView();
|
||||||
var lastVisibleIndex = Mathf.Min(firstVisibleIndex + MaxVisibleCount - 1, ui.sc_list.numItems - 1);
|
var lastVisibleIndex = Mathf.Min(firstVisibleIndex + MaxVisibleCount - 1, ui.sc_list.numItems - 1);
|
||||||
|
|
||||||
var startIndex = Mathf.Max(0, firstVisibleIndex - PreloadCount);
|
var startIndex = Mathf.Max(0, firstVisibleIndex - PreloadCount);
|
||||||
var endIndex = Mathf.Min(ui.sc_list.numItems - 1, lastVisibleIndex + PreloadCount);
|
var endIndex = Mathf.Min(ui.sc_list.numItems - 1, lastVisibleIndex + PreloadCount);
|
||||||
|
|
||||||
// 回收超出范围 loader
|
// 回收超出范围 loader
|
||||||
var keysToRemove = new List<int>();
|
var keysToRemove = new List<int>();
|
||||||
foreach (var kv in activeLoaders)
|
foreach (var kv in activeLoaders)
|
||||||
{
|
{
|
||||||
var idx = kv.Key;
|
var idx = kv.Key;
|
||||||
if (idx < startIndex || idx > endIndex)
|
if (idx < startIndex || idx > endIndex)
|
||||||
{
|
{
|
||||||
GLoaderPool.Instance.ReturnLoader(kv.Value);
|
GLoaderPool.Instance.ReturnLoader(kv.Value);
|
||||||
var oldItem = ui.sc_list.GetChildAt(idx) as item_scalnums;
|
var oldItem = ui.sc_list.GetChildAt(idx) as item_scalnums;
|
||||||
if (oldItem != null) oldItem.com_pic.picture = null;
|
if (oldItem != null) oldItem.com_pic.picture = null;
|
||||||
keysToRemove.Add(idx);
|
keysToRemove.Add(idx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var k in keysToRemove) activeLoaders.Remove(k);
|
foreach (var k in keysToRemove) activeLoaders.Remove(k);
|
||||||
|
|
||||||
|
|
||||||
// 分配 loader 并加载图片
|
// 分配 loader 并加载图片
|
||||||
for (var i = startIndex; i <= endIndex; i++)
|
for (var i = startIndex; i <= endIndex; i++)
|
||||||
{
|
{
|
||||||
if (activeLoaders.ContainsKey(i)) continue;
|
if (activeLoaders.ContainsKey(i)) continue;
|
||||||
|
|
||||||
var item = ui.sc_list.GetChildAt(i) as item_scalnums;
|
var item = ui.sc_list.GetChildAt(i) as item_scalnums;
|
||||||
if (item == null) continue;
|
if (item == null) continue;
|
||||||
|
|
||||||
if (item.com_pic.picture != null && !item.com_pic.picture.isDisposed)
|
if (item.com_pic.picture != null && !item.com_pic.picture.isDisposed)
|
||||||
GLoaderPool.Instance.ReturnLoader(item.com_pic.picture);
|
GLoaderPool.Instance.ReturnLoader(item.com_pic.picture);
|
||||||
|
|
||||||
var loader = GLoaderPool.Instance.GetLoader();
|
var loader = GLoaderPool.Instance.GetLoader();
|
||||||
item.com_pic.picture = loader;
|
item.com_pic.picture = loader;
|
||||||
item.com_pic.AddChild(loader);
|
item.com_pic.AddChild(loader);
|
||||||
loader.SetSize(item.com_pic.width, item.com_pic.height);
|
loader.SetSize(item.com_pic.width, item.com_pic.height);
|
||||||
|
|
||||||
_fileIsExist.TryGetValue(i, out var value);
|
_fileIsExist.TryGetValue(i, out var value);
|
||||||
if (!value)
|
if (!value)
|
||||||
{
|
{
|
||||||
var localPath = Path.Combine(TextureHelper.getResPath(), _secretData[i].Name + ".jpg");
|
var localPath = Path.Combine(TextureHelper.getResPath(), _secretData[i].Name + ".jpg");
|
||||||
|
|
||||||
if (File.Exists(localPath))
|
if (File.Exists(localPath))
|
||||||
{
|
{
|
||||||
_fileIsExist[i] = true;
|
_fileIsExist[i] = true;
|
||||||
Debug.Log($"[SetImgLoader] 本地存在,直接加载 {_secretData[i].Name}");
|
Debug.Log($"[SetImgLoader] 本地存在,直接加载 {_secretData[i].Name}");
|
||||||
CrazyAsyKit.StartCoroutine(TextureHelper.LoadTexture(_secretData[i].Name, loader, null,
|
CrazyAsyKit.StartCoroutine(TextureHelper.LoadTexture(_secretData[i].Name, loader, null,
|
||||||
"SecretAlbums/"));
|
"SecretAlbums/"));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_fileIsExist[i] = false;
|
_fileIsExist[i] = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
CrazyAsyKit.StartCoroutine(TextureHelper.LoadTexture(_secretData[i].Name, loader, null,
|
CrazyAsyKit.StartCoroutine(TextureHelper.LoadTexture(_secretData[i].Name, loader, null,
|
||||||
"SecretAlbums/"));
|
"SecretAlbums/"));
|
||||||
}
|
}
|
||||||
|
|
||||||
activeLoaders[i] = loader;
|
activeLoaders[i] = loader;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Debug.Log($"[ScrollUpdate] active loaders={activeLoaders.Count}, pool={GLoaderPool.Instance.GetPoolCount()}, inUse={GLoaderPool.Instance.GetInUseCount()}");
|
// Debug.Log($"[ScrollUpdate] active loaders={activeLoaders.Count}, pool={GLoaderPool.Instance.GetPoolCount()}, inUse={GLoaderPool.Instance.GetInUseCount()}");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnScrollEnd()
|
private void OnScrollEnd()
|
||||||
{
|
{
|
||||||
if (_secretData == null || _secretData.Count == 0) return;
|
if (_secretData == null || _secretData.Count == 0) return;
|
||||||
|
|
||||||
var firstVisibleIndex = ui.sc_list.GetFirstChildInView();
|
var firstVisibleIndex = ui.sc_list.GetFirstChildInView();
|
||||||
var lastVisibleIndex = Mathf.Min(firstVisibleIndex + MaxVisibleCount - 1, ui.sc_list.numItems - 1);
|
var lastVisibleIndex = Mathf.Min(firstVisibleIndex + MaxVisibleCount - 1, ui.sc_list.numItems - 1);
|
||||||
|
|
||||||
var startIndex = Mathf.Max(0, firstVisibleIndex - PreloadCount);
|
var startIndex = Mathf.Max(0, firstVisibleIndex - PreloadCount);
|
||||||
var endIndex = Mathf.Min(ui.sc_list.numItems - 1, lastVisibleIndex + PreloadCount);
|
var endIndex = Mathf.Min(ui.sc_list.numItems - 1, lastVisibleIndex + PreloadCount);
|
||||||
|
|
||||||
// Debug.Log($"[ScrollEnd] start index={startIndex} end index={endIndex}");
|
// Debug.Log($"[ScrollEnd] start index={startIndex} end index={endIndex}");
|
||||||
|
|
||||||
|
|
||||||
var tasks = new List<(GLoader loader, string fileName, Action<NTexture> callback, string folder, string localFolder)>();
|
var tasks = new List<(GLoader loader, string fileName, Action<NTexture> callback, string folder, string localFolder)>();
|
||||||
// 分配 loader 并加载图片
|
// 分配 loader 并加载图片
|
||||||
for (var i = startIndex; i <= endIndex; i++)
|
for (var i = startIndex; i <= endIndex; i++)
|
||||||
{
|
{
|
||||||
_fileIsExist.TryGetValue(i, out var value);
|
_fileIsExist.TryGetValue(i, out var value);
|
||||||
|
|
||||||
if (value) continue;
|
if (value) continue;
|
||||||
var item = ui.sc_list.GetChildAt(i) as item_scalnums;
|
var item = ui.sc_list.GetChildAt(i) as item_scalnums;
|
||||||
if (item == null) continue;
|
if (item == null) continue;
|
||||||
if (item.com_pic.picture != null && !item.com_pic.picture.isDisposed)
|
if (item.com_pic.picture != null && !item.com_pic.picture.isDisposed)
|
||||||
GLoaderPool.Instance.ReturnLoader(item.com_pic.picture);
|
GLoaderPool.Instance.ReturnLoader(item.com_pic.picture);
|
||||||
var loader = GLoaderPool.Instance.GetLoader();
|
var loader = GLoaderPool.Instance.GetLoader();
|
||||||
item.com_pic.picture = loader;
|
item.com_pic.picture = loader;
|
||||||
item.com_pic.AddChild(loader);
|
item.com_pic.AddChild(loader);
|
||||||
loader.SetSize(item.com_pic.width, item.com_pic.height);
|
loader.SetSize(item.com_pic.width, item.com_pic.height);
|
||||||
|
|
||||||
var idx = i;
|
var idx = i;
|
||||||
tasks.Add((loader, _secretData[i].Name, texture =>
|
tasks.Add((loader, _secretData[i].Name, texture =>
|
||||||
{
|
{
|
||||||
if (texture != null) _fileIsExist[idx] = true;
|
if (texture != null) _fileIsExist[idx] = true;
|
||||||
}, "SecretAlbums/", FolderNames.SecretName));
|
}, "SecretAlbums/", FolderNames.SecretName));
|
||||||
|
|
||||||
activeLoaders[i] = loader;
|
activeLoaders[i] = loader;
|
||||||
}
|
}
|
||||||
|
|
||||||
TextureHelper.SetImgLoaders(tasks);
|
TextureHelper.SetImgLoaders(tasks);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void ItemRender(int index, GObject obj)
|
private void ItemRender(int index, GObject obj)
|
||||||
{
|
{
|
||||||
var item = (item_scalnums)obj;
|
var item = (item_scalnums)obj;
|
||||||
|
|
||||||
item.text_id.text = _secretData[index].id.ToString();
|
item.text_id.text = _secretData[index].id.ToString();
|
||||||
|
|
||||||
var isUnlock = DataMgr.SecretUnlockList.Value.Contains(index);
|
var isUnlock = DataMgr.SecretUnlockList.Value.Contains(index);
|
||||||
|
|
||||||
item.btn_unlock.pay_type.selectedIndex = _secretData[index].PayType;
|
item.btn_unlock.pay_type.selectedIndex = _secretData[index].PayType;
|
||||||
|
|
||||||
if (_secretData[index].PayType == 0)
|
if (_secretData[index].PayType == 0)
|
||||||
item.btn_unlock.title = GameHelper.getPrice((decimal)_secretData[index].DiscountPrice);
|
item.btn_unlock.title = GameHelper.getPrice((decimal)_secretData[index].DiscountPrice);
|
||||||
else if (_secretData[index].PayType == 1)
|
else if (_secretData[index].PayType == 1)
|
||||||
item.btn_unlock.title = _secretData[index].GoldCoins.ToString();
|
item.btn_unlock.title = _secretData[index].GoldCoins.ToString();
|
||||||
else if (_secretData[index].PayType == 2) item.btn_unlock.title = _secretData[index].AD + "AD";
|
else if (_secretData[index].PayType == 2) item.btn_unlock.title = _secretData[index].AD + "AD";
|
||||||
|
|
||||||
if (isUnlock)
|
if (isUnlock)
|
||||||
{
|
{
|
||||||
item.btn_unlock.pay_type.selectedIndex = 3;
|
item.btn_unlock.pay_type.selectedIndex = 3;
|
||||||
if (_secretData[index].SubscribeUnlock == 1)
|
if (_secretData[index].SubscribeUnlock == 1)
|
||||||
{
|
{
|
||||||
item.vip.selectedIndex = 1;
|
item.vip.selectedIndex = 1;
|
||||||
item.btn_unlock.pay_type.selectedIndex = 5;
|
item.btn_unlock.pay_type.selectedIndex = 5;
|
||||||
}
|
}
|
||||||
item.btn_unlock.title = Language.GetContent("go");
|
item.btn_unlock.title = Language.GetContent("go");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (_secretData[index].SubscribeUnlock == 1)
|
if (_secretData[index].SubscribeUnlock == 1)
|
||||||
{
|
{
|
||||||
item.vip.selectedIndex = 1;
|
item.vip.selectedIndex = 1;
|
||||||
item.btn_unlock.pay_type.selectedIndex = 4;
|
item.btn_unlock.pay_type.selectedIndex = 4;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
item.btn_null.SetClick(GotoNext);
|
item.btn_null.SetClick(GotoNext);
|
||||||
|
|
||||||
item.un_lock.selectedIndex = isUnlock ? 1 : 0;
|
item.un_lock.selectedIndex = isUnlock ? 1 : 0;
|
||||||
|
|
||||||
item.btn_unlock.SetClick(GotoNext);
|
item.btn_unlock.SetClick(GotoNext);
|
||||||
|
|
||||||
item.peple_num.text = GetPepleNum(_secretData[index].Quantity).ToString();
|
item.peple_num.text = GetPepleNum(_secretData[index].Quantity).ToString();
|
||||||
|
|
||||||
item.hot.selectedIndex = _secretData[index].HotType;
|
item.hot.selectedIndex = _secretData[index].HotType;
|
||||||
|
|
||||||
void GotoNext()
|
void GotoNext()
|
||||||
{
|
{
|
||||||
var data = new AlbumPreviewData
|
var data = new AlbumPreviewData
|
||||||
{
|
{
|
||||||
Index = index,
|
Index = index,
|
||||||
State = _secretData[index].State,
|
State = _secretData[index].State,
|
||||||
Price = _secretData[index].Price,
|
Price = _secretData[index].Price,
|
||||||
PayType = _secretData[index].PayType,
|
PayType = _secretData[index].PayType,
|
||||||
SubscribeUnlock = _secretData[index].SubscribeUnlock,
|
SubscribeUnlock = _secretData[index].SubscribeUnlock,
|
||||||
DiscountPrice = _secretData[index].DiscountPrice,
|
DiscountPrice = _secretData[index].DiscountPrice,
|
||||||
Name = _secretData[index].Name,
|
Name = _secretData[index].Name,
|
||||||
Name2 = _secretData[index].Name2,
|
Name2 = _secretData[index].Name2,
|
||||||
GoldCoins = _secretData[index].GoldCoins,
|
GoldCoins = _secretData[index].GoldCoins,
|
||||||
AD = _secretData[index].AD,
|
AD = _secretData[index].AD,
|
||||||
CD = _secretData[index].CD
|
CD = _secretData[index].CD
|
||||||
};
|
};
|
||||||
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.SecretAlbumsNextUI_Open, data);
|
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.SecretAlbumsNextUI_Open, data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private int GetPepleNum(float quantity)
|
private int GetPepleNum(float quantity)
|
||||||
{
|
{
|
||||||
// 获取当前时间
|
// 获取当前时间
|
||||||
var now = DateTime.Now;
|
var now = DateTime.Now;
|
||||||
|
|
||||||
// 计算当天已经过去的分钟数(从凌晨 0 点开始算)
|
// 计算当天已经过去的分钟数(从凌晨 0 点开始算)
|
||||||
var minutesPassedToday = now.Hour * 60 + now.Minute;
|
var minutesPassedToday = now.Hour * 60 + now.Minute;
|
||||||
|
|
||||||
// 计算人数
|
// 计算人数
|
||||||
var num = Mathf.FloorToInt(quantity * minutesPassedToday);
|
var num = Mathf.FloorToInt(quantity * minutesPassedToday);
|
||||||
|
|
||||||
return num;
|
return num;
|
||||||
}
|
}
|
||||||
|
|
||||||
#region 生命周期
|
#region 生命周期
|
||||||
|
|
||||||
protected override void OnInit()
|
protected override void OnInit()
|
||||||
{
|
{
|
||||||
// 初始化GLoader池,设置最大缓存数
|
// 初始化GLoader池,设置最大缓存数
|
||||||
GLoaderPool.Instance.Init(null, 10, 464, 642);
|
GLoaderPool.Instance.Init(null, 10, 464, 642);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnClose()
|
protected override void OnClose()
|
||||||
{
|
{
|
||||||
// 1. 解除 UI 对 Loader 的引用
|
// 1. 解除 UI 对 Loader 的引用
|
||||||
for (var i = 0; i < ui.sc_list.numChildren; i++)
|
for (var i = 0; i < ui.sc_list.numChildren; i++)
|
||||||
{
|
{
|
||||||
var item = ui.sc_list.GetChildAt(i) as item_scalnums;
|
var item = ui.sc_list.GetChildAt(i) as item_scalnums;
|
||||||
if (item != null && item.com_pic.picture != null) item.com_pic.picture = null; // 清掉 GLoader 引用
|
if (item != null && item.com_pic.picture != null) item.com_pic.picture = null; // 清掉 GLoader 引用
|
||||||
}
|
}
|
||||||
|
|
||||||
activeLoaders.Clear();
|
activeLoaders.Clear();
|
||||||
_fileIsExist.Clear();
|
_fileIsExist.Clear();
|
||||||
|
|
||||||
GLoaderPool.Instance.DisposeAll();
|
GLoaderPool.Instance.DisposeAll();
|
||||||
|
|
||||||
TextureHelper.ClearMaterialPool();
|
TextureHelper.ClearMaterialPool();
|
||||||
|
|
||||||
// 强制卸载未使用的资源
|
// 强制卸载未使用的资源
|
||||||
Resources.UnloadUnusedAssets();
|
Resources.UnloadUnusedAssets();
|
||||||
MemoryManager.CleanMemoryMonitor();
|
MemoryManager.CleanMemoryMonitor();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnBind()
|
protected override void OnBind()
|
||||||
{
|
{
|
||||||
ui = baseUI as com_scAlbums;
|
ui = baseUI as com_scAlbums;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<SecretAlbums> _secretData = new();
|
private List<SecretAlbums> _secretData = new();
|
||||||
|
|
||||||
protected override void OnOpenBefore(object args)
|
protected override void OnOpenBefore(object args)
|
||||||
{
|
{
|
||||||
if (Screen.safeArea.y != 0)
|
if (Screen.safeArea.y != 0)
|
||||||
{
|
{
|
||||||
ui.btn_gold.y += 68;
|
ui.btn_gold.y += 68;
|
||||||
ui.btn_close.y += 68;
|
ui.btn_close.y += 68;
|
||||||
ui.sc_list.y += 68;
|
ui.sc_list.y += 68;
|
||||||
}
|
}
|
||||||
|
|
||||||
var eventName = GameHelper.IsAdModelOfPay() ? ADEventTrack.Event : ADEventTrack.MaxPayEvent;
|
var eventName = GameHelper.IsAdModelOfPay() ? ADEventTrack.Event : ADEventTrack.MaxPayEvent;
|
||||||
TrackKit.SendEvent(eventName, ADEventTrack.Property.shop_show);
|
TrackKit.SendEvent(eventName, ADEventTrack.Property.shop_show);
|
||||||
|
|
||||||
_secretData = ConfigSystem.GetConfig<SecretAlbums>();
|
_secretData = ConfigSystem.GetSecretAlbumsConfig();
|
||||||
InitView();
|
InitView();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnOpen(object args)
|
protected override void OnOpen(object args)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnHide()
|
protected override void OnHide()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnDisplay(object args)
|
protected override void OnDisplay(object args)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region 消息
|
#region 消息
|
||||||
public void SetTopCurr(object a = null)
|
public void SetTopCurr(object a = null)
|
||||||
{
|
{
|
||||||
ui.btn_gold.GetChild("text_gold").text = GameHelper.Get101Str();
|
ui.btn_gold.GetChild("text_gold").text = GameHelper.Get101Str();
|
||||||
}
|
}
|
||||||
protected override void AddListener()
|
protected override void AddListener()
|
||||||
{
|
{
|
||||||
GameDispatcher.Instance.AddListener(GameMsg.UnlockSecretSuccess, UnlockSuccess);
|
GameDispatcher.Instance.AddListener(GameMsg.UnlockSecretSuccess, UnlockSuccess);
|
||||||
GameDispatcher.Instance.AddListener(GameMsg.Update101, SetTopCurr);
|
GameDispatcher.Instance.AddListener(GameMsg.Update101, SetTopCurr);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void RemoveListener()
|
protected override void RemoveListener()
|
||||||
{
|
{
|
||||||
GameDispatcher.Instance.RemoveListener(GameMsg.UnlockSecretSuccess, UnlockSuccess);
|
GameDispatcher.Instance.RemoveListener(GameMsg.UnlockSecretSuccess, UnlockSuccess);
|
||||||
GameDispatcher.Instance.RemoveListener(GameMsg.Update101, SetTopCurr);
|
GameDispatcher.Instance.RemoveListener(GameMsg.Update101, SetTopCurr);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
||||||
public class AlbumPreviewData
|
public class AlbumPreviewData
|
||||||
{
|
{
|
||||||
public int AD;
|
public int AD;
|
||||||
public int CD;
|
public int CD;
|
||||||
public float DiscountPrice;
|
public float DiscountPrice;
|
||||||
public int GoldCoins;
|
public int GoldCoins;
|
||||||
public int Index;
|
public int Index;
|
||||||
public string Name;
|
public string Name;
|
||||||
public string Name2;
|
public string Name2;
|
||||||
public int PayType;
|
public int PayType;
|
||||||
public float Price;
|
public float Price;
|
||||||
public int[] State;
|
public int[] State;
|
||||||
public int SubscribeUnlock;
|
public int SubscribeUnlock;
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum UnlockPayType
|
public enum UnlockPayType
|
||||||
{
|
{
|
||||||
Pay = 0,
|
Pay = 0,
|
||||||
Coin = 1,
|
Coin = 1,
|
||||||
Ad = 2,
|
Ad = 2,
|
||||||
None = 3
|
None = 3
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,248 +1,248 @@
|
|||||||
|
|
||||||
using FGUI.ZM_Common_01;
|
using FGUI.ZM_Common_01;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using FairyGUI;
|
using FairyGUI;
|
||||||
using FGUI.LG_Common;
|
using FGUI.LG_Common;
|
||||||
using DG.Tweening;
|
using DG.Tweening;
|
||||||
using SGModule.NetKit;
|
using SGModule.NetKit;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using SGModule.Common.Extensions;
|
using SGModule.Common.Extensions;
|
||||||
|
|
||||||
namespace RedHotRoast
|
namespace RedHotRoast
|
||||||
{
|
{
|
||||||
public class UnlockLevelUI : BaseUI
|
public class UnlockLevelUI : BaseUI
|
||||||
{
|
{
|
||||||
private UnlockLevelUICtrl ctrl;
|
private UnlockLevelUICtrl ctrl;
|
||||||
private UnlockLevelModel model;
|
private UnlockLevelModel model;
|
||||||
private FGUI.LG_End.com_unlockLevel ui;
|
private FGUI.LG_End.com_unlockLevel ui;
|
||||||
|
|
||||||
public UnlockLevelUI(UnlockLevelUICtrl ctrl) : base(ctrl)
|
public UnlockLevelUI(UnlockLevelUICtrl ctrl) : base(ctrl)
|
||||||
{
|
{
|
||||||
uiName = UIConst.UnlockLevelUI;
|
uiName = UIConst.UnlockLevelUI;
|
||||||
this.ctrl = ctrl;
|
this.ctrl = ctrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void SetUIInfo(UIInfo uiInfo)
|
protected override void SetUIInfo(UIInfo uiInfo)
|
||||||
{
|
{
|
||||||
uiInfo.packageName = "LG_End";
|
uiInfo.packageName = "LG_End";
|
||||||
uiInfo.assetName = "com_unlockLevel";
|
uiInfo.assetName = "com_unlockLevel";
|
||||||
uiInfo.layerType = UILayerType.Popup;
|
uiInfo.layerType = UILayerType.Popup;
|
||||||
uiInfo.isNeedOpenAnim = false;
|
uiInfo.isNeedOpenAnim = false;
|
||||||
uiInfo.isNeedCloseAnim = false;
|
uiInfo.isNeedCloseAnim = false;
|
||||||
uiInfo.isNeedUIMask = true;
|
uiInfo.isNeedUIMask = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#region 生命周期
|
#region 生命周期
|
||||||
protected override void OnInit()
|
protected override void OnInit()
|
||||||
{
|
{
|
||||||
//model = ModuleManager.Instance.GetModel(ModelConst.UnlockLevelModel) as UnlockLevelModel;
|
//model = ModuleManager.Instance.GetModel(ModelConst.UnlockLevelModel) as UnlockLevelModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnClose()
|
protected override void OnClose()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < loader_list.Count; i++)
|
for (int i = 0; i < loader_list.Count; i++)
|
||||||
{
|
{
|
||||||
if (loader_list[i] != null && !loader_list[i].isDisposed && loader_list[i].texture != null)
|
if (loader_list[i] != null && !loader_list[i].isDisposed && loader_list[i].texture != null)
|
||||||
{
|
{
|
||||||
loader_list[i].texture.Dispose();
|
loader_list[i].texture.Dispose();
|
||||||
loader_list[i].texture = null;
|
loader_list[i].texture = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
loader_list.Clear();
|
loader_list.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnBind()
|
protected override void OnBind()
|
||||||
{
|
{
|
||||||
ui = baseUI as FGUI.LG_End.com_unlockLevel;
|
ui = baseUI as FGUI.LG_End.com_unlockLevel;
|
||||||
}
|
}
|
||||||
private LevelUnlock levelUnlock_;
|
private LevelUnlock levelUnlock_;
|
||||||
private int level_;
|
private int level_;
|
||||||
protected override void OnOpenBefore(object args)
|
protected override void OnOpenBefore(object args)
|
||||||
{
|
{
|
||||||
level_ = (int)args;
|
level_ = (int)args;
|
||||||
Debug.Log(level_);
|
Debug.Log(level_);
|
||||||
|
|
||||||
if (!loader_list.Contains(ui.com_loader.GetChild("loader") as GLoader))
|
if (!loader_list.Contains(ui.com_loader.GetChild("loader") as GLoader))
|
||||||
{
|
{
|
||||||
loader_list.Add(ui.com_loader.GetChild("loader") as GLoader);
|
loader_list.Add(ui.com_loader.GetChild("loader") as GLoader);
|
||||||
}
|
}
|
||||||
|
|
||||||
levelUnlock_ = ConfigSystem.GetConfig<LevelUnlock>()[level_];
|
levelUnlock_ = ConfigSystem.GetLevelUnlockConfig()[level_];
|
||||||
TextureHelper.SetImgLoader(ui.com_loader.GetChild("loader") as GLoader, levelUnlock_.Name, (s) =>
|
TextureHelper.SetImgLoader(ui.com_loader.GetChild("loader") as GLoader, levelUnlock_.Name, (s) =>
|
||||||
{
|
{
|
||||||
TextureHelper.SetImageBlur(ui.com_loader.GetChild("loader") as GLoader);
|
TextureHelper.SetImageBlur(ui.com_loader.GetChild("loader") as GLoader);
|
||||||
}, "LevelAlbums/", FolderNames.AlbumName);
|
}, "LevelAlbums/", FolderNames.AlbumName);
|
||||||
InitView();
|
InitView();
|
||||||
if (levelUnlock_.LeveType == 1)
|
if (levelUnlock_.LeveType == 1)
|
||||||
{
|
{
|
||||||
TrackKit.SendEvent(ADEventTrack.Special, ADEventTrack.Property.speciallevel);
|
TrackKit.SendEvent(ADEventTrack.Special, ADEventTrack.Property.speciallevel);
|
||||||
}
|
}
|
||||||
else if (levelUnlock_.LeveType == 2)
|
else if (levelUnlock_.LeveType == 2)
|
||||||
{
|
{
|
||||||
TrackKit.SendEvent(ADEventTrack.VipLevel, ADEventTrack.Property.viplevel);
|
TrackKit.SendEvent(ADEventTrack.VipLevel, ADEventTrack.Property.viplevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
private List<GLoader> loader_list = new List<GLoader>();
|
private List<GLoader> loader_list = new List<GLoader>();
|
||||||
protected override void OnOpen(object args)
|
protected override void OnOpen(object args)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnHide()
|
protected override void OnHide()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnDisplay(object args)
|
protected override void OnDisplay(object args)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region 消息
|
#region 消息
|
||||||
protected override void AddListener()
|
protected override void AddListener()
|
||||||
{
|
{
|
||||||
GameDispatcher.Instance.AddListener(GameMsg.BuyVip, refrsh);
|
GameDispatcher.Instance.AddListener(GameMsg.BuyVip, refrsh);
|
||||||
}
|
}
|
||||||
protected override void RemoveListener()
|
protected override void RemoveListener()
|
||||||
{
|
{
|
||||||
GameDispatcher.Instance.RemoveListener(GameMsg.BuyVip, refrsh);
|
GameDispatcher.Instance.RemoveListener(GameMsg.BuyVip, refrsh);
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
private void refrsh(object a = null)
|
private void refrsh(object a = null)
|
||||||
{
|
{
|
||||||
DOVirtual.DelayedCall(0.5f, () =>
|
DOVirtual.DelayedCall(0.5f, () =>
|
||||||
{
|
{
|
||||||
InitView();
|
InitView();
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
//初始化页面逻辑
|
//初始化页面逻辑
|
||||||
private void InitView()
|
private void InitView()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
if (GameHelper.GetVipPrivilege(Subscription.VipLevel.As<int>()))
|
if (GameHelper.GetVipPrivilege(Subscription.VipLevel.As<int>()))
|
||||||
{
|
{
|
||||||
(ui.btn_vip as btn_claim_2).have_vip.selectedIndex = 1;
|
(ui.btn_vip as btn_claim_2).have_vip.selectedIndex = 1;
|
||||||
}
|
}
|
||||||
if (GameHelper.GetVipPrivilege(Subscription.SLVLevel.As<int>()))
|
if (GameHelper.GetVipPrivilege(Subscription.SLVLevel.As<int>()))
|
||||||
{
|
{
|
||||||
(ui.btn_watch as btn_claim_1).have_vip.selectedIndex = 1;
|
(ui.btn_watch as btn_claim_1).have_vip.selectedIndex = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (levelUnlock_.LeveType == 1) //特殊关
|
if (levelUnlock_.LeveType == 1) //特殊关
|
||||||
{
|
{
|
||||||
ui.type.selectedIndex = 0;
|
ui.type.selectedIndex = 0;
|
||||||
ui.btn_pay.title = levelUnlock_.GoldCoins.ToString();
|
ui.btn_pay.title = levelUnlock_.GoldCoins.ToString();
|
||||||
|
|
||||||
ui.btn_pay.SetClick(() =>
|
ui.btn_pay.SetClick(() =>
|
||||||
{
|
{
|
||||||
if (DataMgr.Coin.Value >= levelUnlock_.GoldCoins)
|
if (DataMgr.Coin.Value >= levelUnlock_.GoldCoins)
|
||||||
{
|
{
|
||||||
DataMgr.Coin.Value -= levelUnlock_.GoldCoins;
|
DataMgr.Coin.Value -= levelUnlock_.GoldCoins;
|
||||||
GameDispatcher.Instance.Dispatch(GameMsg.Gold_refresh);
|
GameDispatcher.Instance.Dispatch(GameMsg.Gold_refresh);
|
||||||
DataMgr.LevelUnlockList.Value.Add(level_);
|
DataMgr.LevelUnlockList.Value.Add(level_);
|
||||||
GameHelper.ShowTips("unlocked", true);
|
GameHelper.ShowTips("unlocked", true);
|
||||||
DataMgr.LevelUnlockList.Save();
|
DataMgr.LevelUnlockList.Save();
|
||||||
GameDispatcher.Instance.Dispatch(GameMsg.UnlockLevelsuccess);
|
GameDispatcher.Instance.Dispatch(GameMsg.UnlockLevelsuccess);
|
||||||
CtrlCloseUI();
|
CtrlCloseUI();
|
||||||
TrackKit.SendEvent(ADEventTrack.Special, ADEventTrack.Property.speciallevelcoin);
|
TrackKit.SendEvent(ADEventTrack.Special, ADEventTrack.Property.speciallevelcoin);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
GameHelper.ShowTips("no_enough_gold", true);
|
GameHelper.ShowTips("no_enough_gold", true);
|
||||||
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.BuygoldUI_Open);
|
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.BuygoldUI_Open);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
ui.btn_watch.SetClick(() => //7天都不包含。30天包含特殊,365全部包含
|
ui.btn_watch.SetClick(() => //7天都不包含。30天包含特殊,365全部包含
|
||||||
{
|
{
|
||||||
if (GameHelper.GetVipPrivilege(Subscription.SLVLevel.As<int>()))
|
if (GameHelper.GetVipPrivilege(Subscription.SLVLevel.As<int>()))
|
||||||
{
|
{
|
||||||
DataMgr.LevelUnlockList.Value.Add(level_);
|
DataMgr.LevelUnlockList.Value.Add(level_);
|
||||||
GameHelper.ShowTips("unlocked", true);
|
GameHelper.ShowTips("unlocked", true);
|
||||||
DataMgr.LevelUnlockList.Save();
|
DataMgr.LevelUnlockList.Save();
|
||||||
GameDispatcher.Instance.Dispatch(GameMsg.UnlockLevelsuccess);
|
GameDispatcher.Instance.Dispatch(GameMsg.UnlockLevelsuccess);
|
||||||
CtrlCloseUI();
|
CtrlCloseUI();
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
GameHelper.ShowVideoAd("UnlockSpecialLevel", isSuccess =>
|
GameHelper.ShowVideoAd("UnlockSpecialLevel", isSuccess =>
|
||||||
{
|
{
|
||||||
if (isSuccess)
|
if (isSuccess)
|
||||||
{
|
{
|
||||||
DataMgr.LevelUnlockList.Value.Add(level_);
|
DataMgr.LevelUnlockList.Value.Add(level_);
|
||||||
GameHelper.ShowTips("unlocked", true);
|
GameHelper.ShowTips("unlocked", true);
|
||||||
DataMgr.LevelUnlockList.Save();
|
DataMgr.LevelUnlockList.Save();
|
||||||
GameDispatcher.Instance.Dispatch(GameMsg.UnlockLevelsuccess);
|
GameDispatcher.Instance.Dispatch(GameMsg.UnlockLevelsuccess);
|
||||||
CtrlCloseUI();
|
CtrlCloseUI();
|
||||||
}
|
}
|
||||||
TrackKit.SendEvent(ADEventTrack.Special, ADEventTrack.Property.speciallevelvideo);
|
TrackKit.SendEvent(ADEventTrack.Special, ADEventTrack.Property.speciallevelvideo);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else if (levelUnlock_.LeveType == 2)//vip关
|
else if (levelUnlock_.LeveType == 2)//vip关
|
||||||
{
|
{
|
||||||
ui.type.selectedIndex = 1;
|
ui.type.selectedIndex = 1;
|
||||||
ui.btn_pay.title = levelUnlock_.GoldCoins.ToString();
|
ui.btn_pay.title = levelUnlock_.GoldCoins.ToString();
|
||||||
|
|
||||||
ui.btn_pay.SetClick(() =>
|
ui.btn_pay.SetClick(() =>
|
||||||
{
|
{
|
||||||
if (DataMgr.Coin.Value >= levelUnlock_.GoldCoins)
|
if (DataMgr.Coin.Value >= levelUnlock_.GoldCoins)
|
||||||
{
|
{
|
||||||
DataMgr.Coin.Value -= levelUnlock_.GoldCoins;
|
DataMgr.Coin.Value -= levelUnlock_.GoldCoins;
|
||||||
GameDispatcher.Instance.Dispatch(GameMsg.Gold_refresh);
|
GameDispatcher.Instance.Dispatch(GameMsg.Gold_refresh);
|
||||||
DataMgr.LevelUnlockList.Value.Add(level_);
|
DataMgr.LevelUnlockList.Value.Add(level_);
|
||||||
GameHelper.ShowTips("unlocked", true);
|
GameHelper.ShowTips("unlocked", true);
|
||||||
DataMgr.LevelUnlockList.Save();
|
DataMgr.LevelUnlockList.Save();
|
||||||
GameDispatcher.Instance.Dispatch(GameMsg.UnlockLevelsuccess);
|
GameDispatcher.Instance.Dispatch(GameMsg.UnlockLevelsuccess);
|
||||||
TrackKit.SendEvent(ADEventTrack.VipLevel, ADEventTrack.Property.viplevelcoin);
|
TrackKit.SendEvent(ADEventTrack.VipLevel, ADEventTrack.Property.viplevelcoin);
|
||||||
CtrlCloseUI();
|
CtrlCloseUI();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
GameHelper.ShowTips("no_enough_gold", true);
|
GameHelper.ShowTips("no_enough_gold", true);
|
||||||
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.BuygoldUI_Open);
|
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.BuygoldUI_Open);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
ui.btn_vip.SetClick(() =>
|
ui.btn_vip.SetClick(() =>
|
||||||
{
|
{
|
||||||
if (GameHelper.GetVipPrivilege(Subscription.VipLevel.As<int>()))
|
if (GameHelper.GetVipPrivilege(Subscription.VipLevel.As<int>()))
|
||||||
{
|
{
|
||||||
DataMgr.LevelUnlockList.Value.Add(level_);
|
DataMgr.LevelUnlockList.Value.Add(level_);
|
||||||
GameHelper.ShowTips("unlocked", true);
|
GameHelper.ShowTips("unlocked", true);
|
||||||
DataMgr.LevelUnlockList.Save();
|
DataMgr.LevelUnlockList.Save();
|
||||||
GameDispatcher.Instance.Dispatch(GameMsg.UnlockLevelsuccess);
|
GameDispatcher.Instance.Dispatch(GameMsg.UnlockLevelsuccess);
|
||||||
CtrlCloseUI();
|
CtrlCloseUI();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
uiCtrlDispatcher.Dispatch(UICtrlMsg.VipClubViewUI_Open, 2);
|
uiCtrlDispatcher.Dispatch(UICtrlMsg.VipClubViewUI_Open, 2);
|
||||||
TrackKit.SendEvent(ADEventTrack.VipLevel, ADEventTrack.Property.viplevelsub);
|
TrackKit.SendEvent(ADEventTrack.VipLevel, ADEventTrack.Property.viplevelsub);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
ui.btn_close.SetClick(() =>
|
ui.btn_close.SetClick(() =>
|
||||||
{
|
{
|
||||||
GameHelper.SetLevel(GameHelper.GetLevel() + 1);
|
GameHelper.SetLevel(GameHelper.GetLevel() + 1);
|
||||||
if (UIManager.Instance.IsExistUI(UIConst.NewEndUI))
|
if (UIManager.Instance.IsExistUI(UIConst.NewEndUI))
|
||||||
{
|
{
|
||||||
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.NewEndUI_Close);
|
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.NewEndUI_Close);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.OpenGameUI_Open);
|
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.OpenGameUI_Open);
|
||||||
}
|
}
|
||||||
|
|
||||||
CtrlCloseUI();
|
CtrlCloseUI();
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,490 +1,490 @@
|
|||||||
|
|
||||||
using FGUI.ZM_Common_01;
|
using FGUI.ZM_Common_01;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using FairyGUI;
|
using FairyGUI;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using SGModule.Common.Extensions;
|
using SGModule.Common.Extensions;
|
||||||
using DG.Tweening;
|
using DG.Tweening;
|
||||||
using UnityEngine.UIElements;
|
using UnityEngine.UIElements;
|
||||||
using SGModule.NetKit;
|
using SGModule.NetKit;
|
||||||
|
|
||||||
namespace RedHotRoast
|
namespace RedHotRoast
|
||||||
{
|
{
|
||||||
public class UnlockLevelNewUI : BaseUI
|
public class UnlockLevelNewUI : BaseUI
|
||||||
{
|
{
|
||||||
private UnlockLevelNewUICtrl ctrl;
|
private UnlockLevelNewUICtrl ctrl;
|
||||||
private UnlockLevelNewModel model;
|
private UnlockLevelNewModel model;
|
||||||
private FGUI.LG_End.com_unlockLevelNew ui;
|
private FGUI.LG_End.com_unlockLevelNew ui;
|
||||||
|
|
||||||
public UnlockLevelNewUI(UnlockLevelNewUICtrl ctrl) : base(ctrl)
|
public UnlockLevelNewUI(UnlockLevelNewUICtrl ctrl) : base(ctrl)
|
||||||
{
|
{
|
||||||
uiName = UIConst.UnlockLevelNewUI;
|
uiName = UIConst.UnlockLevelNewUI;
|
||||||
this.ctrl = ctrl;
|
this.ctrl = ctrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void SetUIInfo(UIInfo uiInfo)
|
protected override void SetUIInfo(UIInfo uiInfo)
|
||||||
{
|
{
|
||||||
uiInfo.packageName = "LG_End";
|
uiInfo.packageName = "LG_End";
|
||||||
uiInfo.assetName = "com_unlockLevelNew";
|
uiInfo.assetName = "com_unlockLevelNew";
|
||||||
uiInfo.layerType = UILayerType.Popup;
|
uiInfo.layerType = UILayerType.Popup;
|
||||||
uiInfo.isNeedOpenAnim = false;
|
uiInfo.isNeedOpenAnim = false;
|
||||||
uiInfo.isNeedCloseAnim = false;
|
uiInfo.isNeedCloseAnim = false;
|
||||||
uiInfo.isNeedUIMask = true;
|
uiInfo.isNeedUIMask = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#region 生命周期
|
#region 生命周期
|
||||||
protected override void OnInit()
|
protected override void OnInit()
|
||||||
{
|
{
|
||||||
//model = ModuleManager.Instance.GetModel(ModelConst.UnlockLevelNewModel) as UnlockLevelNewModel;
|
//model = ModuleManager.Instance.GetModel(ModelConst.UnlockLevelNewModel) as UnlockLevelNewModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnClose()
|
protected override void OnClose()
|
||||||
{
|
{
|
||||||
// for (int i = 0; i < loader_list.Count; i++)
|
// for (int i = 0; i < loader_list.Count; i++)
|
||||||
// {
|
// {
|
||||||
// if (loader_list[i] != null && !loader_list[i].isDisposed && loader_list[i].texture != null)
|
// if (loader_list[i] != null && !loader_list[i].isDisposed && loader_list[i].texture != null)
|
||||||
// {
|
// {
|
||||||
// loader_list[i].texture = null;
|
// loader_list[i].texture = null;
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
// loader_list.Clear();
|
// loader_list.Clear();
|
||||||
foreach (var loader in loader_list)
|
foreach (var loader in loader_list)
|
||||||
{
|
{
|
||||||
if (loader == null || loader.isDisposed) continue;
|
if (loader == null || loader.isDisposed) continue;
|
||||||
|
|
||||||
// 释放材质到材质池
|
// 释放材质到材质池
|
||||||
if (loader.material != null)
|
if (loader.material != null)
|
||||||
{
|
{
|
||||||
TextureHelper.CancelImageBlur(loader); // 自动返回材质池
|
TextureHelper.CancelImageBlur(loader); // 自动返回材质池
|
||||||
loader.material = null;
|
loader.material = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 清理 NTexture
|
// 清理 NTexture
|
||||||
if (loader.texture != null)
|
if (loader.texture != null)
|
||||||
{
|
{
|
||||||
loader.texture.Dispose(); // 销毁 NTexture 对象
|
loader.texture.Dispose(); // 销毁 NTexture 对象
|
||||||
loader.texture = null;
|
loader.texture = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
loader_list.Clear();
|
loader_list.Clear();
|
||||||
}
|
}
|
||||||
private List<GLoader> loader_list = new List<GLoader>();
|
private List<GLoader> loader_list = new List<GLoader>();
|
||||||
protected override void OnBind()
|
protected override void OnBind()
|
||||||
{
|
{
|
||||||
ui = baseUI as FGUI.LG_End.com_unlockLevelNew;
|
ui = baseUI as FGUI.LG_End.com_unlockLevelNew;
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool isHallEnter = false;
|
private bool isHallEnter = false;
|
||||||
protected override void OnOpenBefore(object args)
|
protected override void OnOpenBefore(object args)
|
||||||
{
|
{
|
||||||
if (args != null)
|
if (args != null)
|
||||||
{
|
{
|
||||||
isHallEnter = (bool)args;
|
isHallEnter = (bool)args;
|
||||||
}
|
}
|
||||||
InitView();
|
InitView();
|
||||||
ui.btn_close.SetClick(() =>
|
ui.btn_close.SetClick(() =>
|
||||||
{
|
{
|
||||||
GameDispatcher.Instance.Dispatch(GameMsg.ExitGame);
|
GameDispatcher.Instance.Dispatch(GameMsg.ExitGame);
|
||||||
uiCtrlDispatcher.Dispatch(UICtrlMsg.NewEndUI_Close);
|
uiCtrlDispatcher.Dispatch(UICtrlMsg.NewEndUI_Close);
|
||||||
CtrlCloseUI();
|
CtrlCloseUI();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnOpen(object args)
|
protected override void OnOpen(object args)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnHide()
|
protected override void OnHide()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnDisplay(object args)
|
protected override void OnDisplay(object args)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region 消息
|
#region 消息
|
||||||
protected override void AddListener()
|
protected override void AddListener()
|
||||||
{
|
{
|
||||||
GameDispatcher.Instance.AddListener(GameMsg.BuyVip, RefreshVip);
|
GameDispatcher.Instance.AddListener(GameMsg.BuyVip, RefreshVip);
|
||||||
}
|
}
|
||||||
protected override void RemoveListener()
|
protected override void RemoveListener()
|
||||||
{
|
{
|
||||||
GameDispatcher.Instance.RemoveListener(GameMsg.BuyVip, RefreshVip);
|
GameDispatcher.Instance.RemoveListener(GameMsg.BuyVip, RefreshVip);
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
private void RefreshVip(object a = null)
|
private void RefreshVip(object a = null)
|
||||||
{
|
{
|
||||||
bool have_special = GameHelper.GetVipPrivilege(Subscription.SLVLevel.As<int>());
|
bool have_special = GameHelper.GetVipPrivilege(Subscription.SLVLevel.As<int>());
|
||||||
SpecialImageLibrary special_ImageLibrary = ConfigSystem.GetConfig<SpecialImageLibrary>()[DataMgr.LevelUnlockSpecial.Value];
|
SpecialImageLibrary special_ImageLibrary = ConfigSystem.GetSpecialImageConfig()[DataMgr.LevelUnlockSpecial.Value];
|
||||||
if (special_ImageLibrary.State == 1 && !have_special) TextureHelper.SetImageBlur(ui.item_2.com_pic.picture);
|
if (special_ImageLibrary.State == 1 && !have_special) TextureHelper.SetImageBlur(ui.item_2.com_pic.picture);
|
||||||
else TextureHelper.CancelImageBlur(ui.item_2.com_pic.picture);
|
else TextureHelper.CancelImageBlur(ui.item_2.com_pic.picture);
|
||||||
|
|
||||||
if (have_special)
|
if (have_special)
|
||||||
{
|
{
|
||||||
ui.item_2.btn_unlock.visible = false;
|
ui.item_2.btn_unlock.visible = false;
|
||||||
ui.item_2.type.selectedIndex = 0;
|
ui.item_2.type.selectedIndex = 0;
|
||||||
ui.item_2.btn_skip.SetClick(() =>
|
ui.item_2.btn_skip.SetClick(() =>
|
||||||
{
|
{
|
||||||
SelectLevel(2, DataMgr.LevelUnlockSpecial.Value);
|
SelectLevel(2, DataMgr.LevelUnlockSpecial.Value);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ui.item_2.type.selectedIndex = 2;
|
ui.item_2.type.selectedIndex = 2;
|
||||||
ui.item_2.btn_unlock.visible = true;
|
ui.item_2.btn_unlock.visible = true;
|
||||||
ui.item_2.btn_skip.SetClick(() =>
|
ui.item_2.btn_skip.SetClick(() =>
|
||||||
{
|
{
|
||||||
uiCtrlDispatcher.Dispatch(UICtrlMsg.VipClubViewUI_Open);
|
uiCtrlDispatcher.Dispatch(UICtrlMsg.VipClubViewUI_Open);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (special_ImageLibrary.GoldCoins > 0)
|
if (special_ImageLibrary.GoldCoins > 0)
|
||||||
{
|
{
|
||||||
ui.item_2.btn_unlock.pay_type.selectedIndex = 1;
|
ui.item_2.btn_unlock.pay_type.selectedIndex = 1;
|
||||||
ui.item_2.btn_unlock.title = special_ImageLibrary.GoldCoins.ToString();
|
ui.item_2.btn_unlock.title = special_ImageLibrary.GoldCoins.ToString();
|
||||||
ui.item_2.btn_unlock.SetClick(() =>
|
ui.item_2.btn_unlock.SetClick(() =>
|
||||||
{
|
{
|
||||||
if (DataMgr.Coin.Value >= special_ImageLibrary.GoldCoins)
|
if (DataMgr.Coin.Value >= special_ImageLibrary.GoldCoins)
|
||||||
{
|
{
|
||||||
GameHelper.AddGold(-special_ImageLibrary.GoldCoins);
|
GameHelper.AddGold(-special_ImageLibrary.GoldCoins);
|
||||||
SelectLevel(2, DataMgr.LevelUnlockSpecial.Value);
|
SelectLevel(2, DataMgr.LevelUnlockSpecial.Value);
|
||||||
Debug.Log("///////金币解锁");
|
Debug.Log("///////金币解锁");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
GameHelper.ShowTips("no_enough_gold", true);
|
GameHelper.ShowTips("no_enough_gold", true);
|
||||||
|
|
||||||
uiCtrlDispatcher.Dispatch(UICtrlMsg.BuygoldUI_Open);
|
uiCtrlDispatcher.Dispatch(UICtrlMsg.BuygoldUI_Open);
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ui.item_2.btn_unlock.visible = false;
|
ui.item_2.btn_unlock.visible = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool have_vip = GameHelper.GetVipPrivilege(Subscription.VipLevel.As<int>());
|
bool have_vip = GameHelper.GetVipPrivilege(Subscription.VipLevel.As<int>());
|
||||||
VIPImageLibrary vip_ImageLibrary = ConfigSystem.GetConfig<VIPImageLibrary>()[DataMgr.LevelUnlockVIP.Value];
|
VIPImageLibrary vip_ImageLibrary = ConfigSystem.GetVIPImageConfig()[DataMgr.LevelUnlockVIP.Value];
|
||||||
if (vip_ImageLibrary.State == 1 && !have_vip) TextureHelper.SetImageBlur(ui.item_3.com_pic.picture);
|
if (vip_ImageLibrary.State == 1 && !have_vip) TextureHelper.SetImageBlur(ui.item_3.com_pic.picture);
|
||||||
else TextureHelper.CancelImageBlur(ui.item_3.com_pic.picture);
|
else TextureHelper.CancelImageBlur(ui.item_3.com_pic.picture);
|
||||||
if (have_vip)
|
if (have_vip)
|
||||||
{
|
{
|
||||||
ui.item_3.btn_unlock.visible = false;
|
ui.item_3.btn_unlock.visible = false;
|
||||||
ui.item_3.type.selectedIndex = 0;
|
ui.item_3.type.selectedIndex = 0;
|
||||||
ui.item_3.btn_skip.SetClick(() =>
|
ui.item_3.btn_skip.SetClick(() =>
|
||||||
{
|
{
|
||||||
SelectLevel(3, DataMgr.LevelUnlockVIP.Value);
|
SelectLevel(3, DataMgr.LevelUnlockVIP.Value);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ui.item_3.type.selectedIndex = 3;
|
ui.item_3.type.selectedIndex = 3;
|
||||||
ui.item_3.btn_unlock.visible = true;
|
ui.item_3.btn_unlock.visible = true;
|
||||||
ui.item_3.btn_skip.SetClick(() =>
|
ui.item_3.btn_skip.SetClick(() =>
|
||||||
{
|
{
|
||||||
uiCtrlDispatcher.Dispatch(UICtrlMsg.VipClubViewUI_Open);
|
uiCtrlDispatcher.Dispatch(UICtrlMsg.VipClubViewUI_Open);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (vip_ImageLibrary.GoldCoins > 0)
|
if (vip_ImageLibrary.GoldCoins > 0)
|
||||||
{
|
{
|
||||||
ui.item_3.btn_unlock.pay_type.selectedIndex = 1;
|
ui.item_3.btn_unlock.pay_type.selectedIndex = 1;
|
||||||
ui.item_3.btn_unlock.title = vip_ImageLibrary.GoldCoins.ToString();
|
ui.item_3.btn_unlock.title = vip_ImageLibrary.GoldCoins.ToString();
|
||||||
ui.item_3.btn_unlock.SetClick(() =>
|
ui.item_3.btn_unlock.SetClick(() =>
|
||||||
{
|
{
|
||||||
if (DataMgr.Coin.Value >= vip_ImageLibrary.GoldCoins)
|
if (DataMgr.Coin.Value >= vip_ImageLibrary.GoldCoins)
|
||||||
{
|
{
|
||||||
GameHelper.AddGold(-vip_ImageLibrary.GoldCoins);
|
GameHelper.AddGold(-vip_ImageLibrary.GoldCoins);
|
||||||
SelectLevel(3, DataMgr.LevelUnlockVIP.Value);
|
SelectLevel(3, DataMgr.LevelUnlockVIP.Value);
|
||||||
Debug.Log("///////金币解锁");
|
Debug.Log("///////金币解锁");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
GameHelper.ShowTips("no_enough_gold", true);
|
GameHelper.ShowTips("no_enough_gold", true);
|
||||||
|
|
||||||
uiCtrlDispatcher.Dispatch(UICtrlMsg.BuygoldUI_Open);
|
uiCtrlDispatcher.Dispatch(UICtrlMsg.BuygoldUI_Open);
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ui.item_3.btn_unlock.visible = false;
|
ui.item_3.btn_unlock.visible = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//初始化页面逻辑
|
//初始化页面逻辑
|
||||||
private void InitView()
|
private void InitView()
|
||||||
{
|
{
|
||||||
Debug.Log(JsonConvert.SerializeObject(ConfigSystem.GetConfig<FreeImageLibrary>()) + "..................");
|
Debug.Log(JsonConvert.SerializeObject(ConfigSystem.GetConfig<FreeImageLibrary>()) + "..................");
|
||||||
Debug.Log(JsonConvert.SerializeObject(ConfigSystem.GetConfig<ADImageLibrary>()) + "..................");
|
Debug.Log(JsonConvert.SerializeObject(ConfigSystem.GetConfig<ADImageLibrary>()) + "..................");
|
||||||
Debug.Log(JsonConvert.SerializeObject(ConfigSystem.GetConfig<SpecialImageLibrary>()) + "..................");
|
Debug.Log(JsonConvert.SerializeObject(ConfigSystem.GetConfig<SpecialImageLibrary>()) + "..................");
|
||||||
Debug.Log(JsonConvert.SerializeObject(ConfigSystem.GetConfig<VIPImageLibrary>()) + "..................");
|
Debug.Log(JsonConvert.SerializeObject(ConfigSystem.GetConfig<VIPImageLibrary>()) + "..................");
|
||||||
|
|
||||||
ConfigSystem.GetConfig<VIPImageLibrary>();
|
ConfigSystem.GetVIPImageConfig();
|
||||||
|
|
||||||
loader_list.Add(ui.item_0.com_pic.picture);
|
loader_list.Add(ui.item_0.com_pic.picture);
|
||||||
loader_list.Add(ui.item_1.com_pic.picture);
|
loader_list.Add(ui.item_1.com_pic.picture);
|
||||||
loader_list.Add(ui.item_2.com_pic.picture);
|
loader_list.Add(ui.item_2.com_pic.picture);
|
||||||
loader_list.Add(ui.item_3.com_pic.picture);
|
loader_list.Add(ui.item_3.com_pic.picture);
|
||||||
|
|
||||||
// List<int> free_level_list = new List<int>();
|
// List<int> free_level_list = new List<int>();
|
||||||
// List<int> ad_level_list = new List<int>();
|
// List<int> ad_level_list = new List<int>();
|
||||||
// List<int> special_level_list = new List<int>();
|
// List<int> special_level_list = new List<int>();
|
||||||
// List<int> vip_level_list = new List<int>();
|
// List<int> vip_level_list = new List<int>();
|
||||||
// for (int i = 0; i < DataMgr.LevelUnlockListNew.Value.Count; i++)
|
// for (int i = 0; i < DataMgr.LevelUnlockListNew.Value.Count; i++)
|
||||||
// {
|
// {
|
||||||
// if (DataMgr.LevelUnlockListNew.Value[i].type == 0) free_level_list.Add(DataMgr.LevelUnlockListNew.Value[i].config_index);
|
// if (DataMgr.LevelUnlockListNew.Value[i].type == 0) free_level_list.Add(DataMgr.LevelUnlockListNew.Value[i].config_index);
|
||||||
// else if (DataMgr.LevelUnlockListNew.Value[i].type == 1) ad_level_list.Add(DataMgr.LevelUnlockListNew.Value[i].config_index);
|
// else if (DataMgr.LevelUnlockListNew.Value[i].type == 1) ad_level_list.Add(DataMgr.LevelUnlockListNew.Value[i].config_index);
|
||||||
// else if (DataMgr.LevelUnlockListNew.Value[i].type == 2) special_level_list.Add(DataMgr.LevelUnlockListNew.Value[i].config_index);
|
// else if (DataMgr.LevelUnlockListNew.Value[i].type == 2) special_level_list.Add(DataMgr.LevelUnlockListNew.Value[i].config_index);
|
||||||
// else if (DataMgr.LevelUnlockListNew.Value[i].type == 3) vip_level_list.Add(DataMgr.LevelUnlockListNew.Value[i].config_index);
|
// else if (DataMgr.LevelUnlockListNew.Value[i].type == 3) vip_level_list.Add(DataMgr.LevelUnlockListNew.Value[i].config_index);
|
||||||
// }
|
// }
|
||||||
int Free_Alubum_0 = PlayerPrefs.GetInt("Free_Alubum_0", -1);
|
int Free_Alubum_0 = PlayerPrefs.GetInt("Free_Alubum_0", -1);
|
||||||
|
|
||||||
int AD_Alubum = PlayerPrefs.GetInt("AD_Alubum", -1);
|
int AD_Alubum = PlayerPrefs.GetInt("AD_Alubum", -1);
|
||||||
int Spec_Alubum = PlayerPrefs.GetInt("Spec_Alubum", -1);
|
int Spec_Alubum = PlayerPrefs.GetInt("Spec_Alubum", -1);
|
||||||
int Vip_Alubum = PlayerPrefs.GetInt("Vip_Alubum", -1);
|
int Vip_Alubum = PlayerPrefs.GetInt("Vip_Alubum", -1);
|
||||||
|
|
||||||
if (DataMgr.LevelUnlockFree.Value < 0)
|
if (DataMgr.LevelUnlockFree.Value < 0)
|
||||||
{
|
{
|
||||||
DataMgr.LevelUnlockFree.Value = Free_Alubum_0;
|
DataMgr.LevelUnlockFree.Value = Free_Alubum_0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DataMgr.LevelUnlockAD.Value < 0)
|
if (DataMgr.LevelUnlockAD.Value < 0)
|
||||||
{
|
{
|
||||||
DataMgr.LevelUnlockAD.Value = AD_Alubum;
|
DataMgr.LevelUnlockAD.Value = AD_Alubum;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DataMgr.LevelUnlockSpecial.Value < 0)
|
if (DataMgr.LevelUnlockSpecial.Value < 0)
|
||||||
{
|
{
|
||||||
DataMgr.LevelUnlockSpecial.Value = Spec_Alubum;
|
DataMgr.LevelUnlockSpecial.Value = Spec_Alubum;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DataMgr.LevelUnlockVIP.Value < 0)
|
if (DataMgr.LevelUnlockVIP.Value < 0)
|
||||||
{
|
{
|
||||||
DataMgr.LevelUnlockVIP.Value = Vip_Alubum;
|
DataMgr.LevelUnlockVIP.Value = Vip_Alubum;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
FreeImageLibrary free_ImageLibrary = ConfigSystem.GetConfig<FreeImageLibrary>()[DataMgr.LevelUnlockFree.Value];
|
FreeImageLibrary free_ImageLibrary = ConfigSystem.GetFreeImageConfig()[DataMgr.LevelUnlockFree.Value];
|
||||||
ui.item_0.btn_unlock.pay_type.selectedIndex = 2;
|
ui.item_0.btn_unlock.pay_type.selectedIndex = 2;
|
||||||
ui.item_0_re.btn_unlock.visible = false;
|
ui.item_0_re.btn_unlock.visible = false;
|
||||||
TextureHelper.SetImgLoader(ui.item_0.com_pic.picture, free_ImageLibrary.Name, (s) =>
|
TextureHelper.SetImgLoader(ui.item_0.com_pic.picture, free_ImageLibrary.Name, (s) =>
|
||||||
{
|
{
|
||||||
if (free_ImageLibrary.State == 1) TextureHelper.SetImageBlur(ui.item_0.com_pic.picture);
|
if (free_ImageLibrary.State == 1) TextureHelper.SetImageBlur(ui.item_0.com_pic.picture);
|
||||||
}, "LevelAlbums/", FolderNames.AlbumName);
|
}, "LevelAlbums/", FolderNames.AlbumName);
|
||||||
|
|
||||||
int Free_Alubum_1 = PlayerPrefs.GetInt("Free_Alubum_1", -1);
|
int Free_Alubum_1 = PlayerPrefs.GetInt("Free_Alubum_1", -1);
|
||||||
FreeImageLibrary free_ImageLibrary_re = ConfigSystem.GetConfig<FreeImageLibrary>()[Free_Alubum_1];
|
FreeImageLibrary free_ImageLibrary_re = ConfigSystem.GetFreeImageConfig()[Free_Alubum_1];
|
||||||
TextureHelper.SetImgLoader(ui.item_0_re.com_pic.picture, free_ImageLibrary_re.Name, (s) =>
|
TextureHelper.SetImgLoader(ui.item_0_re.com_pic.picture, free_ImageLibrary_re.Name, (s) =>
|
||||||
{
|
{
|
||||||
if (free_ImageLibrary_re.State == 1) TextureHelper.SetImageBlur(ui.item_0_re.com_pic.picture);
|
if (free_ImageLibrary_re.State == 1) TextureHelper.SetImageBlur(ui.item_0_re.com_pic.picture);
|
||||||
}, "LevelAlbums/", FolderNames.AlbumName);
|
}, "LevelAlbums/", FolderNames.AlbumName);
|
||||||
|
|
||||||
ui.item_0.btn_unlock.SetClick(() =>
|
ui.item_0.btn_unlock.SetClick(() =>
|
||||||
{
|
{
|
||||||
PlayerPrefs.SetInt("unlock_refresh", 0);
|
PlayerPrefs.SetInt("unlock_refresh", 0);
|
||||||
DataMgr.LevelUnlockFree.Value = Free_Alubum_1;
|
DataMgr.LevelUnlockFree.Value = Free_Alubum_1;
|
||||||
ui.item_0.visible = false;
|
ui.item_0.visible = false;
|
||||||
ui.item_0_re.visible = true;
|
ui.item_0_re.visible = true;
|
||||||
});
|
});
|
||||||
|
|
||||||
if (PlayerPrefs.GetInt("unlock_refresh", 1) == 1)
|
if (PlayerPrefs.GetInt("unlock_refresh", 1) == 1)
|
||||||
{
|
{
|
||||||
ui.item_0.visible = true;
|
ui.item_0.visible = true;
|
||||||
ui.item_0_re.visible = false;
|
ui.item_0_re.visible = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ui.item_0.visible = false;
|
ui.item_0.visible = false;
|
||||||
ui.item_0_re.visible = true;
|
ui.item_0_re.visible = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
ui.item_0.btn_skip.SetClick(() =>
|
ui.item_0.btn_skip.SetClick(() =>
|
||||||
{
|
{
|
||||||
SelectLevel(0, DataMgr.LevelUnlockFree.Value);
|
SelectLevel(0, DataMgr.LevelUnlockFree.Value);
|
||||||
});
|
});
|
||||||
ui.item_0_re.btn_skip.SetClick(() =>
|
ui.item_0_re.btn_skip.SetClick(() =>
|
||||||
{
|
{
|
||||||
SelectLevel(0, DataMgr.LevelUnlockFree.Value);
|
SelectLevel(0, DataMgr.LevelUnlockFree.Value);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ADImageLibrary ad_ImageLibrary = ConfigSystem.GetConfig<ADImageLibrary>()[DataMgr.LevelUnlockAD.Value];
|
ADImageLibrary ad_ImageLibrary = ConfigSystem.GetADImageConfig()[DataMgr.LevelUnlockAD.Value];
|
||||||
TextureHelper.SetImgLoader(ui.item_1.com_pic.picture, ad_ImageLibrary.Name, (s) =>
|
TextureHelper.SetImgLoader(ui.item_1.com_pic.picture, ad_ImageLibrary.Name, (s) =>
|
||||||
{
|
{
|
||||||
if (ad_ImageLibrary.State == 1) TextureHelper.SetImageBlur(ui.item_1.com_pic.picture);
|
if (ad_ImageLibrary.State == 1) TextureHelper.SetImageBlur(ui.item_1.com_pic.picture);
|
||||||
}, "LevelAlbums/", FolderNames.AlbumName);
|
}, "LevelAlbums/", FolderNames.AlbumName);
|
||||||
|
|
||||||
ui.item_1.btn_unlock.pay_type.selectedIndex = 3;
|
ui.item_1.btn_unlock.pay_type.selectedIndex = 3;
|
||||||
|
|
||||||
ui.item_1.btn_skip.SetClick(() =>
|
ui.item_1.btn_skip.SetClick(() =>
|
||||||
{
|
{
|
||||||
Debug.Log("///////播放广告解锁");
|
Debug.Log("///////播放广告解锁");
|
||||||
GameHelper.ShowVideoAd("UnlockLevel", isSuccess =>
|
GameHelper.ShowVideoAd("UnlockLevel", isSuccess =>
|
||||||
{
|
{
|
||||||
if (isSuccess)
|
if (isSuccess)
|
||||||
{
|
{
|
||||||
SelectLevel(1, DataMgr.LevelUnlockAD.Value);
|
SelectLevel(1, DataMgr.LevelUnlockAD.Value);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
bool have_special = GameHelper.GetVipPrivilege(Subscription.SLVLevel.As<int>());
|
bool have_special = GameHelper.GetVipPrivilege(Subscription.SLVLevel.As<int>());
|
||||||
SpecialImageLibrary special_ImageLibrary = ConfigSystem.GetConfig<SpecialImageLibrary>()[DataMgr.LevelUnlockSpecial.Value];
|
SpecialImageLibrary special_ImageLibrary = ConfigSystem.GetSpecialImageConfig()[DataMgr.LevelUnlockSpecial.Value];
|
||||||
TextureHelper.SetImgLoader(ui.item_2.com_pic.picture, special_ImageLibrary.Name, (s) =>
|
TextureHelper.SetImgLoader(ui.item_2.com_pic.picture, special_ImageLibrary.Name, (s) =>
|
||||||
{
|
{
|
||||||
if (special_ImageLibrary.State == 1 && !have_special) TextureHelper.SetImageBlur(ui.item_2.com_pic.picture);
|
if (special_ImageLibrary.State == 1 && !have_special) TextureHelper.SetImageBlur(ui.item_2.com_pic.picture);
|
||||||
}, "LevelAlbums/", FolderNames.AlbumName);
|
}, "LevelAlbums/", FolderNames.AlbumName);
|
||||||
if (have_special)
|
if (have_special)
|
||||||
{
|
{
|
||||||
ui.item_2.btn_unlock.visible = false;
|
ui.item_2.btn_unlock.visible = false;
|
||||||
ui.item_2.type.selectedIndex = 0;
|
ui.item_2.type.selectedIndex = 0;
|
||||||
ui.item_2.btn_skip.SetClick(() =>
|
ui.item_2.btn_skip.SetClick(() =>
|
||||||
{
|
{
|
||||||
SelectLevel(2, DataMgr.LevelUnlockSpecial.Value);
|
SelectLevel(2, DataMgr.LevelUnlockSpecial.Value);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ui.item_2.type.selectedIndex = 2;
|
ui.item_2.type.selectedIndex = 2;
|
||||||
ui.item_2.btn_unlock.visible = true;
|
ui.item_2.btn_unlock.visible = true;
|
||||||
ui.item_2.btn_skip.SetClick(() =>
|
ui.item_2.btn_skip.SetClick(() =>
|
||||||
{
|
{
|
||||||
uiCtrlDispatcher.Dispatch(UICtrlMsg.VipClubViewUI_Open);
|
uiCtrlDispatcher.Dispatch(UICtrlMsg.VipClubViewUI_Open);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (special_ImageLibrary.GoldCoins > 0)
|
if (special_ImageLibrary.GoldCoins > 0)
|
||||||
{
|
{
|
||||||
ui.item_2.btn_unlock.pay_type.selectedIndex = 1;
|
ui.item_2.btn_unlock.pay_type.selectedIndex = 1;
|
||||||
ui.item_2.btn_unlock.title = special_ImageLibrary.GoldCoins.ToString();
|
ui.item_2.btn_unlock.title = special_ImageLibrary.GoldCoins.ToString();
|
||||||
ui.item_2.btn_unlock.SetClick(() =>
|
ui.item_2.btn_unlock.SetClick(() =>
|
||||||
{
|
{
|
||||||
if (DataMgr.Coin.Value >= special_ImageLibrary.GoldCoins)
|
if (DataMgr.Coin.Value >= special_ImageLibrary.GoldCoins)
|
||||||
{
|
{
|
||||||
GameHelper.AddGold(-special_ImageLibrary.GoldCoins);
|
GameHelper.AddGold(-special_ImageLibrary.GoldCoins);
|
||||||
SelectLevel(2, DataMgr.LevelUnlockSpecial.Value);
|
SelectLevel(2, DataMgr.LevelUnlockSpecial.Value);
|
||||||
TrackKit.SendEvent(ADEventTrack.Coinsbuy, ADEventTrack.Property.unlock_svip);
|
TrackKit.SendEvent(ADEventTrack.Coinsbuy, ADEventTrack.Property.unlock_svip);
|
||||||
Debug.Log("///////金币解锁");
|
Debug.Log("///////金币解锁");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
GameHelper.ShowTips("no_enough_gold", true);
|
GameHelper.ShowTips("no_enough_gold", true);
|
||||||
|
|
||||||
uiCtrlDispatcher.Dispatch(UICtrlMsg.BuygoldUI_Open);
|
uiCtrlDispatcher.Dispatch(UICtrlMsg.BuygoldUI_Open);
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ui.item_2.btn_unlock.visible = false;
|
ui.item_2.btn_unlock.visible = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool have_vip = GameHelper.GetVipPrivilege(Subscription.VipLevel.As<int>());
|
bool have_vip = GameHelper.GetVipPrivilege(Subscription.VipLevel.As<int>());
|
||||||
VIPImageLibrary vip_ImageLibrary = ConfigSystem.GetConfig<VIPImageLibrary>()[DataMgr.LevelUnlockVIP.Value];
|
VIPImageLibrary vip_ImageLibrary = ConfigSystem.GetVIPImageConfig()[DataMgr.LevelUnlockVIP.Value];
|
||||||
|
|
||||||
TextureHelper.SetImgLoader(ui.item_3.com_pic.picture, vip_ImageLibrary.Name, (s) =>
|
TextureHelper.SetImgLoader(ui.item_3.com_pic.picture, vip_ImageLibrary.Name, (s) =>
|
||||||
{
|
{
|
||||||
if (vip_ImageLibrary.State == 1 && !have_vip) TextureHelper.SetImageBlur(ui.item_3.com_pic.picture);
|
if (vip_ImageLibrary.State == 1 && !have_vip) TextureHelper.SetImageBlur(ui.item_3.com_pic.picture);
|
||||||
}, "LevelAlbums/", FolderNames.AlbumName);
|
}, "LevelAlbums/", FolderNames.AlbumName);
|
||||||
if (have_vip)
|
if (have_vip)
|
||||||
{
|
{
|
||||||
ui.item_3.btn_unlock.visible = false;
|
ui.item_3.btn_unlock.visible = false;
|
||||||
ui.item_3.type.selectedIndex = 0;
|
ui.item_3.type.selectedIndex = 0;
|
||||||
ui.item_3.btn_skip.SetClick(() =>
|
ui.item_3.btn_skip.SetClick(() =>
|
||||||
{
|
{
|
||||||
SelectLevel(3, DataMgr.LevelUnlockVIP.Value);
|
SelectLevel(3, DataMgr.LevelUnlockVIP.Value);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ui.item_3.type.selectedIndex = 3;
|
ui.item_3.type.selectedIndex = 3;
|
||||||
ui.item_3.btn_unlock.visible = true;
|
ui.item_3.btn_unlock.visible = true;
|
||||||
ui.item_3.btn_skip.SetClick(() =>
|
ui.item_3.btn_skip.SetClick(() =>
|
||||||
{
|
{
|
||||||
uiCtrlDispatcher.Dispatch(UICtrlMsg.VipClubViewUI_Open);
|
uiCtrlDispatcher.Dispatch(UICtrlMsg.VipClubViewUI_Open);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (vip_ImageLibrary.GoldCoins > 0)
|
if (vip_ImageLibrary.GoldCoins > 0)
|
||||||
{
|
{
|
||||||
ui.item_3.btn_unlock.pay_type.selectedIndex = 1;
|
ui.item_3.btn_unlock.pay_type.selectedIndex = 1;
|
||||||
ui.item_3.btn_unlock.title = vip_ImageLibrary.GoldCoins.ToString();
|
ui.item_3.btn_unlock.title = vip_ImageLibrary.GoldCoins.ToString();
|
||||||
ui.item_3.btn_unlock.SetClick(() =>
|
ui.item_3.btn_unlock.SetClick(() =>
|
||||||
{
|
{
|
||||||
if (DataMgr.Coin.Value >= vip_ImageLibrary.GoldCoins)
|
if (DataMgr.Coin.Value >= vip_ImageLibrary.GoldCoins)
|
||||||
{
|
{
|
||||||
GameHelper.AddGold(-vip_ImageLibrary.GoldCoins);
|
GameHelper.AddGold(-vip_ImageLibrary.GoldCoins);
|
||||||
SelectLevel(3, DataMgr.LevelUnlockVIP.Value);
|
SelectLevel(3, DataMgr.LevelUnlockVIP.Value);
|
||||||
Debug.Log("///////金币解锁");
|
Debug.Log("///////金币解锁");
|
||||||
TrackKit.SendEvent(ADEventTrack.Coinsbuy, ADEventTrack.Property.unlock_vip);
|
TrackKit.SendEvent(ADEventTrack.Coinsbuy, ADEventTrack.Property.unlock_vip);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
GameHelper.ShowTips("no_enough_gold", true);
|
GameHelper.ShowTips("no_enough_gold", true);
|
||||||
|
|
||||||
uiCtrlDispatcher.Dispatch(UICtrlMsg.BuygoldUI_Open);
|
uiCtrlDispatcher.Dispatch(UICtrlMsg.BuygoldUI_Open);
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ui.item_3.btn_unlock.visible = false;
|
ui.item_3.btn_unlock.visible = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SelectLevel(int type_, int id)
|
public void SelectLevel(int type_, int id)
|
||||||
{
|
{
|
||||||
|
|
||||||
DataMgr.LevelUnlockListNew.Value.Add(new Levelunlock()
|
DataMgr.LevelUnlockListNew.Value.Add(new Levelunlock()
|
||||||
{
|
{
|
||||||
level_ = GameHelper.GetLevel(),
|
level_ = GameHelper.GetLevel(),
|
||||||
type = type_,
|
type = type_,
|
||||||
config_index = id
|
config_index = id
|
||||||
});
|
});
|
||||||
DataMgr.LevelUnlockListNew.Save();
|
DataMgr.LevelUnlockListNew.Save();
|
||||||
DataMgr.LevelUnlockFree.Value = -1;
|
DataMgr.LevelUnlockFree.Value = -1;
|
||||||
DataMgr.LevelUnlockAD.Value = -1;
|
DataMgr.LevelUnlockAD.Value = -1;
|
||||||
DataMgr.LevelUnlockSpecial.Value = -1;
|
DataMgr.LevelUnlockSpecial.Value = -1;
|
||||||
DataMgr.LevelUnlockVIP.Value = -1;
|
DataMgr.LevelUnlockVIP.Value = -1;
|
||||||
|
|
||||||
PlayerPrefs.SetInt("Free_Alubum_0", -1);
|
PlayerPrefs.SetInt("Free_Alubum_0", -1);
|
||||||
PlayerPrefs.SetInt("Free_Alubum_1", -1);
|
PlayerPrefs.SetInt("Free_Alubum_1", -1);
|
||||||
PlayerPrefs.SetInt("AD_Alubum", -1);
|
PlayerPrefs.SetInt("AD_Alubum", -1);
|
||||||
PlayerPrefs.SetInt("Spec_Alubum", -1);
|
PlayerPrefs.SetInt("Spec_Alubum", -1);
|
||||||
PlayerPrefs.SetInt("Vip_Alubum", -1);
|
PlayerPrefs.SetInt("Vip_Alubum", -1);
|
||||||
|
|
||||||
PlayerPrefs.SetInt("unlock_refresh", 1);
|
PlayerPrefs.SetInt("unlock_refresh", 1);
|
||||||
GameDispatcher.Instance.Dispatch(GameMsg.UnlockLevelsuccess);
|
GameDispatcher.Instance.Dispatch(GameMsg.UnlockLevelsuccess);
|
||||||
CtrlCloseUI();
|
CtrlCloseUI();
|
||||||
PreDownloadManager.StartDownloadAlbumsPicture();
|
PreDownloadManager.StartDownloadAlbumsPicture();
|
||||||
|
|
||||||
if (isHallEnter)
|
if (isHallEnter)
|
||||||
{
|
{
|
||||||
GameHelper.gameType = 0;
|
GameHelper.gameType = 0;
|
||||||
GameDispatcher.Instance.Dispatch(GameMsg.OpenGame, false);
|
GameDispatcher.Instance.Dispatch(GameMsg.OpenGame, false);
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.OpenGameUI_Open, true);
|
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.OpenGameUI_Open, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public class Levelunlock
|
public class Levelunlock
|
||||||
{
|
{
|
||||||
public int level_;
|
public int level_;
|
||||||
public int type;
|
public int type;
|
||||||
public int config_index;
|
public int config_index;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,8 +59,8 @@ namespace RedHotRoast {
|
|||||||
|
|
||||||
TrackKit.TrackLoginFunnel(LoginFunnelEventType.LoadFinish); //加载完成打点
|
TrackKit.TrackLoginFunnel(LoginFunnelEventType.LoadFinish); //加载完成打点
|
||||||
|
|
||||||
TextureHelper.imgUrl = CdnURL + "/" + ConfigSystem.GetCommonConf().ResVersion + "/";
|
TextureHelper.imgUrl = CdnURL + "/" + (IsOrganic() ? GetCommonConf().ResVersion : GetCommonConf().ResVersion1) + "/";
|
||||||
LiveVideoManager.videoBaseUrl = CdnURL + "/" + ConfigSystem.GetCommonConf().ResVersion + "/";
|
LiveVideoManager.videoBaseUrl = CdnURL + "/" + (IsOrganic() ? GetCommonConf().ResVersion : GetCommonConf().ResVersion1) + "/";
|
||||||
|
|
||||||
// ParseGameConfig();
|
// ParseGameConfig();
|
||||||
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.NetLoadingUI_Close);
|
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.NetLoadingUI_Close);
|
||||||
@@ -116,6 +116,66 @@ namespace RedHotRoast {
|
|||||||
return ConfigLoader.Instance.GetConfig<List<T>>() ?? new List<T>();
|
return ConfigLoader.Instance.GetConfig<List<T>>() ?? new List<T>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static bool IsOrganic()
|
||||||
|
{
|
||||||
|
bool b = false;
|
||||||
|
|
||||||
|
if (GameHelper.IsGiftSwitch() && SuperApplication.Instance.attribution == "organic")
|
||||||
|
{
|
||||||
|
b = GetCommonConf().IsOrganic == 1;
|
||||||
|
}
|
||||||
|
return b;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static List<T> GetConfigWithOrganicFallback<T, TOrganic>() where T : class
|
||||||
|
{
|
||||||
|
if (IsOrganic())
|
||||||
|
{
|
||||||
|
var organicConfig = ConfigLoader.Instance.GetConfig<List<TOrganic>>();
|
||||||
|
if (organicConfig != null)
|
||||||
|
{
|
||||||
|
var json = Newtonsoft.Json.JsonConvert.SerializeObject(organicConfig);
|
||||||
|
return Newtonsoft.Json.JsonConvert.DeserializeObject<List<T>>(json);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return GetConfig<T>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<Live> GetLiveConfig()
|
||||||
|
{
|
||||||
|
return GetConfigWithOrganicFallback<Live, Live_A>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<SecretAlbums> GetSecretAlbumsConfig()
|
||||||
|
{
|
||||||
|
return GetConfigWithOrganicFallback<SecretAlbums, SecretAlbums_A>();
|
||||||
|
}
|
||||||
|
public static List<FreeImageLibrary> GetFreeImageConfig()
|
||||||
|
{
|
||||||
|
return GetConfigWithOrganicFallback<FreeImageLibrary, FreeImageLibrary_A>();
|
||||||
|
}
|
||||||
|
public static List<ADImageLibrary> GetADImageConfig()
|
||||||
|
{
|
||||||
|
return GetConfigWithOrganicFallback<ADImageLibrary, ADImageLibrary_A>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<SpecialImageLibrary> GetSpecialImageConfig()
|
||||||
|
{
|
||||||
|
return GetConfigWithOrganicFallback<SpecialImageLibrary, SpecialImageLibrary_A>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<VIPImageLibrary> GetVIPImageConfig()
|
||||||
|
{
|
||||||
|
return GetConfigWithOrganicFallback<VIPImageLibrary, VIPImageLibrary_A>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<LevelUnlock> GetLevelUnlockConfig()
|
||||||
|
{
|
||||||
|
return GetConfigWithOrganicFallback<LevelUnlock, LevelUnlock_A>();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public override void Dispose() {
|
public override void Dispose() {
|
||||||
base.Dispose();
|
base.Dispose();
|
||||||
RemoveListener();
|
RemoveListener();
|
||||||
|
|||||||
@@ -1,382 +1,382 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace RedHotRoast
|
namespace RedHotRoast
|
||||||
{
|
{
|
||||||
public static class PreDownloadManager
|
public static class PreDownloadManager
|
||||||
{
|
{
|
||||||
#region Live
|
#region Live
|
||||||
|
|
||||||
public static void InitializeLiveData()
|
public static void InitializeLiveData()
|
||||||
{
|
{
|
||||||
var liveConfigList = ConfigSystem.GetConfig<Live>();
|
var liveConfigList = ConfigSystem.GetLiveConfig();
|
||||||
|
|
||||||
Debug.Log($"[预下载视频 数据初始化]-0-----{DataMgr.LiveDataDic.Value.Count}");
|
Debug.Log($"[预下载视频 数据初始化]-0-----{DataMgr.LiveDataDic.Value.Count}");
|
||||||
|
|
||||||
var newData = new Dictionary<int, LiveData>();
|
var newData = new Dictionary<int, LiveData>();
|
||||||
|
|
||||||
for (var i = 0; i < liveConfigList.Count; i++)
|
for (var i = 0; i < liveConfigList.Count; i++)
|
||||||
{
|
{
|
||||||
var oldData = GetLiveDataByIndex(liveConfigList[i], i);
|
var oldData = GetLiveDataByIndex(liveConfigList[i], i);
|
||||||
|
|
||||||
if (oldData.progress > 0) newData[i] = oldData;
|
if (oldData.progress > 0) newData[i] = oldData;
|
||||||
}
|
}
|
||||||
|
|
||||||
Debug.Log($"[预下载视频 数据初始化]--1----- {newData.Count}");
|
Debug.Log($"[预下载视频 数据初始化]--1----- {newData.Count}");
|
||||||
DataMgr.LiveDataDic.Value = newData;
|
DataMgr.LiveDataDic.Value = newData;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static LiveData GetLiveDataByIndex(Live liveConfig, int i)
|
public static LiveData GetLiveDataByIndex(Live liveConfig, int i)
|
||||||
{
|
{
|
||||||
DataMgr.LiveDataDic.Value.TryGetValue(i, out var oldData);
|
DataMgr.LiveDataDic.Value.TryGetValue(i, out var oldData);
|
||||||
|
|
||||||
oldData ??= new LiveData
|
oldData ??= new LiveData
|
||||||
{
|
{
|
||||||
progress = liveConfig.Progress,
|
progress = liveConfig.Progress,
|
||||||
AD_num = 0,
|
AD_num = 0,
|
||||||
Singleprogress = (100 - liveConfig.Progress) / liveConfig.AD
|
Singleprogress = (100 - liveConfig.Progress) / liveConfig.AD
|
||||||
};
|
};
|
||||||
|
|
||||||
if (oldData.progress < liveConfig.Progress) oldData.progress = liveConfig.Progress;
|
if (oldData.progress < liveConfig.Progress) oldData.progress = liveConfig.Progress;
|
||||||
|
|
||||||
return oldData;
|
return oldData;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 最大同时下载数量
|
// 最大同时下载数量
|
||||||
private const int MaxConcurrentDownloads = 1;
|
private const int MaxConcurrentDownloads = 1;
|
||||||
|
|
||||||
public static void StartDownload()
|
public static void StartDownload()
|
||||||
{
|
{
|
||||||
CrazyAsyKit.StartCoroutine(DownloadVideosCoroutine());
|
CrazyAsyKit.StartCoroutine(DownloadVideosCoroutine());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IEnumerator DownloadVideosCoroutine()
|
private static IEnumerator DownloadVideosCoroutine()
|
||||||
{
|
{
|
||||||
var liveConfigList = ConfigSystem.GetConfig<Live>();
|
var liveConfigList = ConfigSystem.GetLiveConfig();
|
||||||
var liveDic = DataMgr.LiveDataDic.Value;
|
var liveDic = DataMgr.LiveDataDic.Value;
|
||||||
|
|
||||||
var downloadNameList = new List<string>();
|
var downloadNameList = new List<string>();
|
||||||
|
|
||||||
// 先加入已有进度的视频
|
// 先加入已有进度的视频
|
||||||
foreach (var kvp in liveDic)
|
foreach (var kvp in liveDic)
|
||||||
{
|
{
|
||||||
var index = kvp.Key;
|
var index = kvp.Key;
|
||||||
var data = kvp.Value;
|
var data = kvp.Value;
|
||||||
|
|
||||||
if (data.progress > 0 && index < liveConfigList.Count) downloadNameList.Add(liveConfigList[index].Name);
|
if (data.progress > 0 && index < liveConfigList.Count) downloadNameList.Add(liveConfigList[index].Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
Debug.Log($"[init down video]---1---nameList----------{JsonConvert.SerializeObject(downloadNameList)}");
|
Debug.Log($"[init down video]---1---nameList----------{JsonConvert.SerializeObject(downloadNameList)}");
|
||||||
|
|
||||||
// 添加不在downloadNameList中的项,最多添加6个
|
// 添加不在downloadNameList中的项,最多添加6个
|
||||||
var addedCount = 0;
|
var addedCount = 0;
|
||||||
for (var i = 0; i < liveConfigList.Count && addedCount < 6; i++)
|
for (var i = 0; i < liveConfigList.Count && addedCount < 6; i++)
|
||||||
if (!downloadNameList.Contains(liveConfigList[i].Name))
|
if (!downloadNameList.Contains(liveConfigList[i].Name))
|
||||||
{
|
{
|
||||||
downloadNameList.Add(liveConfigList[i].Name);
|
downloadNameList.Add(liveConfigList[i].Name);
|
||||||
addedCount++;
|
addedCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
Debug.Log($"[init down video]---2---nameList----------{JsonConvert.SerializeObject(downloadNameList)}");
|
Debug.Log($"[init down video]---2---nameList----------{JsonConvert.SerializeObject(downloadNameList)}");
|
||||||
|
|
||||||
// 当前正在下载的协程数量
|
// 当前正在下载的协程数量
|
||||||
var runningCount = 0;
|
var runningCount = 0;
|
||||||
var currentIndex = 0;
|
var currentIndex = 0;
|
||||||
|
|
||||||
if (downloadNameList.Count > 0)
|
if (downloadNameList.Count > 0)
|
||||||
{
|
{
|
||||||
var name = downloadNameList[currentIndex];
|
var name = downloadNameList[currentIndex];
|
||||||
|
|
||||||
var localPath = Path.Combine(TextureHelper.getResPath(), FolderNames.VideoName, name + ".enc");
|
var localPath = Path.Combine(TextureHelper.getResPath(), FolderNames.VideoName, name + ".enc");
|
||||||
Debug.Log($"[预下载 视频 路径]-------localPath===={localPath}");
|
Debug.Log($"[预下载 视频 路径]-------localPath===={localPath}");
|
||||||
|
|
||||||
if (!File.Exists(localPath))
|
if (!File.Exists(localPath))
|
||||||
{
|
{
|
||||||
Debug.Log("[开始预下载 视频 ]---------------");
|
Debug.Log("[开始预下载 视频 ]---------------");
|
||||||
runningCount++;
|
runningCount++;
|
||||||
CrazyAsyKit.StartCoroutine(DownloadSingleVideoCoroutine(name, () => { runningCount--; }));
|
CrazyAsyKit.StartCoroutine(DownloadSingleVideoCoroutine(name, () => { runningCount--; }));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 等待下一帧再检查
|
// 等待下一帧再检查
|
||||||
yield return null;
|
yield return null;
|
||||||
Debug.Log("[init down video]---All downloads finished---");
|
Debug.Log("[init down video]---All downloads finished---");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static IEnumerator DownloadSingleVideoCoroutine(string name, Action onComplete)
|
private static IEnumerator DownloadSingleVideoCoroutine(string name, Action onComplete)
|
||||||
{
|
{
|
||||||
var isDone = false;
|
var isDone = false;
|
||||||
|
|
||||||
LiveVideoManager.Instance.GetVideoLocalPath(name, tex =>
|
LiveVideoManager.Instance.GetVideoLocalPath(name, tex =>
|
||||||
{
|
{
|
||||||
Debug.Log($"[init down video]----------------{name}");
|
Debug.Log($"[init down video]----------------{name}");
|
||||||
isDone = true;
|
isDone = true;
|
||||||
}, false);
|
}, false);
|
||||||
|
|
||||||
// 等待下载完成
|
// 等待下载完成
|
||||||
while (!isDone) yield return null;
|
while (!isDone) yield return null;
|
||||||
|
|
||||||
onComplete?.Invoke();
|
onComplete?.Invoke();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
#region Picture
|
#region Picture
|
||||||
|
|
||||||
public static void StartDownloadSecretPicture()
|
public static void StartDownloadSecretPicture()
|
||||||
{
|
{
|
||||||
var liveConfigList = ConfigSystem.GetConfig<SecretAlbums>();
|
var liveConfigList = ConfigSystem.GetSecretAlbumsConfig();
|
||||||
var liveList = DataMgr.SecretUnlockList.Value;
|
var liveList = DataMgr.SecretUnlockList.Value;
|
||||||
|
|
||||||
var downloadNameList = new List<string>();
|
var downloadNameList = new List<string>();
|
||||||
|
|
||||||
// 先加入所有可用的图片
|
// 先加入所有可用的图片
|
||||||
for (var i = 0; i < liveList.Count; i++)
|
for (var i = 0; i < liveList.Count; i++)
|
||||||
if (liveConfigList[i] != null && !downloadNameList.Contains(liveConfigList[i].Name))
|
if (liveConfigList[i] != null && !downloadNameList.Contains(liveConfigList[i].Name))
|
||||||
downloadNameList.Add(liveConfigList[i].Name);
|
downloadNameList.Add(liveConfigList[i].Name);
|
||||||
|
|
||||||
Debug.Log(
|
Debug.Log(
|
||||||
$"[init down picture Secret]---1---nameList----------{JsonConvert.SerializeObject(downloadNameList)}");
|
$"[init down picture Secret]---1---nameList----------{JsonConvert.SerializeObject(downloadNameList)}");
|
||||||
|
|
||||||
// 添加不在downloadNameList中的项,最多添加6个
|
// 添加不在downloadNameList中的项,最多添加6个
|
||||||
var addedCount = 0;
|
var addedCount = 0;
|
||||||
for (var i = 0; i < liveConfigList.Count && addedCount < 6; i++)
|
for (var i = 0; i < liveConfigList.Count && addedCount < 6; i++)
|
||||||
if (!downloadNameList.Contains(liveConfigList[i].Name))
|
if (!downloadNameList.Contains(liveConfigList[i].Name))
|
||||||
{
|
{
|
||||||
downloadNameList.Add(liveConfigList[i].Name);
|
downloadNameList.Add(liveConfigList[i].Name);
|
||||||
addedCount++;
|
addedCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
Debug.Log(
|
Debug.Log(
|
||||||
$"[init down picture Secret]---2---nameList----------{JsonConvert.SerializeObject(downloadNameList)}");
|
$"[init down picture Secret]---2---nameList----------{JsonConvert.SerializeObject(downloadNameList)}");
|
||||||
|
|
||||||
foreach (var name in downloadNameList)
|
foreach (var name in downloadNameList)
|
||||||
{
|
{
|
||||||
var localPath = Path.Combine(TextureHelper.getResPath(), FolderNames.SecretName, name + ".jpg");
|
var localPath = Path.Combine(TextureHelper.getResPath(), FolderNames.SecretName, name + ".jpg");
|
||||||
Debug.Log($"[预下载 Secret 路径]-------localPath===={localPath}");
|
Debug.Log($"[预下载 Secret 路径]-------localPath===={localPath}");
|
||||||
if (!File.Exists(localPath))
|
if (!File.Exists(localPath))
|
||||||
{
|
{
|
||||||
Debug.Log("[开始预下载 Secret ]---------------");
|
Debug.Log("[开始预下载 Secret ]---------------");
|
||||||
TextureHelper.SetImgLoader(null, name,
|
TextureHelper.SetImgLoader(null, name,
|
||||||
s =>
|
s =>
|
||||||
{
|
{
|
||||||
Debug.Log($"[init down Secret picture]----------------{name}");
|
Debug.Log($"[init down Secret picture]----------------{name}");
|
||||||
}, "SecretAlbums/", FolderNames.SecretName, false);
|
}, "SecretAlbums/", FolderNames.SecretName, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void StartDownloadAlbumsPicture()
|
public static void StartDownloadAlbumsPicture()
|
||||||
{
|
{
|
||||||
int Free_Alubum_0 = PlayerPrefs.GetInt("Free_Alubum_0", -1);
|
int Free_Alubum_0 = PlayerPrefs.GetInt("Free_Alubum_0", -1);
|
||||||
int Free_Alubum_1 = PlayerPrefs.GetInt("Free_Alubum_1", -1);
|
int Free_Alubum_1 = PlayerPrefs.GetInt("Free_Alubum_1", -1);
|
||||||
int AD_Alubum = PlayerPrefs.GetInt("AD_Alubum", -1);
|
int AD_Alubum = PlayerPrefs.GetInt("AD_Alubum", -1);
|
||||||
int Spec_Alubum = PlayerPrefs.GetInt("Spec_Alubum", -1);
|
int Spec_Alubum = PlayerPrefs.GetInt("Spec_Alubum", -1);
|
||||||
int Vip_Alubum = PlayerPrefs.GetInt("Vip_Alubum", -1);
|
int Vip_Alubum = PlayerPrefs.GetInt("Vip_Alubum", -1);
|
||||||
|
|
||||||
if (Free_Alubum_0 >= 0) return;
|
if (Free_Alubum_0 >= 0) return;
|
||||||
|
|
||||||
var FreeImageLibrary_ = ConfigSystem.GetConfig<FreeImageLibrary>();
|
var FreeImageLibrary_ = ConfigSystem.GetFreeImageConfig();
|
||||||
var ADImageLibrary_ = ConfigSystem.GetConfig<ADImageLibrary>();
|
var ADImageLibrary_ = ConfigSystem.GetADImageConfig();
|
||||||
var SpecialImageLibrary_ = ConfigSystem.GetConfig<SpecialImageLibrary>();
|
var SpecialImageLibrary_ = ConfigSystem.GetSpecialImageConfig();
|
||||||
var VIPImageLibrary_ = ConfigSystem.GetConfig<VIPImageLibrary>();
|
var VIPImageLibrary_ = ConfigSystem.GetVIPImageConfig();
|
||||||
|
|
||||||
List<int> free_level_list = new List<int>();
|
List<int> free_level_list = new List<int>();
|
||||||
List<int> ad_level_list = new List<int>();
|
List<int> ad_level_list = new List<int>();
|
||||||
List<int> special_level_list = new List<int>();
|
List<int> special_level_list = new List<int>();
|
||||||
List<int> vip_level_list = new List<int>();
|
List<int> vip_level_list = new List<int>();
|
||||||
for (int i = 0; i < DataMgr.LevelUnlockListNew.Value.Count; i++)
|
for (int i = 0; i < DataMgr.LevelUnlockListNew.Value.Count; i++)
|
||||||
{
|
{
|
||||||
if (DataMgr.LevelUnlockListNew.Value[i].type == 0) free_level_list.Add(DataMgr.LevelUnlockListNew.Value[i].config_index);
|
if (DataMgr.LevelUnlockListNew.Value[i].type == 0) free_level_list.Add(DataMgr.LevelUnlockListNew.Value[i].config_index);
|
||||||
else if (DataMgr.LevelUnlockListNew.Value[i].type == 1) ad_level_list.Add(DataMgr.LevelUnlockListNew.Value[i].config_index);
|
else if (DataMgr.LevelUnlockListNew.Value[i].type == 1) ad_level_list.Add(DataMgr.LevelUnlockListNew.Value[i].config_index);
|
||||||
else if (DataMgr.LevelUnlockListNew.Value[i].type == 2) special_level_list.Add(DataMgr.LevelUnlockListNew.Value[i].config_index);
|
else if (DataMgr.LevelUnlockListNew.Value[i].type == 2) special_level_list.Add(DataMgr.LevelUnlockListNew.Value[i].config_index);
|
||||||
else if (DataMgr.LevelUnlockListNew.Value[i].type == 3) vip_level_list.Add(DataMgr.LevelUnlockListNew.Value[i].config_index);
|
else if (DataMgr.LevelUnlockListNew.Value[i].type == 3) vip_level_list.Add(DataMgr.LevelUnlockListNew.Value[i].config_index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (Free_Alubum_0 < 0)
|
if (Free_Alubum_0 < 0)
|
||||||
{
|
{
|
||||||
HashSet<int> levelIds = new HashSet<int>(free_level_list);
|
HashSet<int> levelIds = new HashSet<int>(free_level_list);
|
||||||
List<FreeImageLibrary> filtered = ConfigSystem.GetConfig<FreeImageLibrary>().Where(x => !levelIds.Contains(x.id)).ToList();
|
List<FreeImageLibrary> filtered = ConfigSystem.GetFreeImageConfig().Where(x => !levelIds.Contains(x.id)).ToList();
|
||||||
if (filtered.Count > 0)
|
if (filtered.Count > 0)
|
||||||
{
|
{
|
||||||
Free_Alubum_0 = filtered[UnityEngine.Random.Range(0, filtered.Count)].id;
|
Free_Alubum_0 = filtered[UnityEngine.Random.Range(0, filtered.Count)].id;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Free_Alubum_0 = ConfigSystem.GetConfig<FreeImageLibrary>()[UnityEngine.Random.Range(0, ConfigSystem.GetConfig<FreeImageLibrary>().Count)].id;
|
Free_Alubum_0 = ConfigSystem.GetFreeImageConfig()[UnityEngine.Random.Range(0, ConfigSystem.GetFreeImageConfig().Count)].id;
|
||||||
}
|
}
|
||||||
free_level_list.Add(Free_Alubum_0);
|
free_level_list.Add(Free_Alubum_0);
|
||||||
Debug.Log(JsonConvert.SerializeObject(filtered) + ",,,,,,,,,,,,,,,,,,,,");
|
Debug.Log(JsonConvert.SerializeObject(filtered) + ",,,,,,,,,,,,,,,,,,,,");
|
||||||
}
|
}
|
||||||
if (Free_Alubum_1 < 0)
|
if (Free_Alubum_1 < 0)
|
||||||
{
|
{
|
||||||
HashSet<int> levelIds = new HashSet<int>(free_level_list);
|
HashSet<int> levelIds = new HashSet<int>(free_level_list);
|
||||||
List<FreeImageLibrary> filtered = ConfigSystem.GetConfig<FreeImageLibrary>().Where(x => !levelIds.Contains(x.id)).ToList();
|
List<FreeImageLibrary> filtered = ConfigSystem.GetFreeImageConfig().Where(x => !levelIds.Contains(x.id)).ToList();
|
||||||
if (filtered.Count > 0)
|
if (filtered.Count > 0)
|
||||||
{
|
{
|
||||||
Free_Alubum_1 = filtered[UnityEngine.Random.Range(0, filtered.Count)].id;
|
Free_Alubum_1 = filtered[UnityEngine.Random.Range(0, filtered.Count)].id;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Free_Alubum_1 = ConfigSystem.GetConfig<FreeImageLibrary>()[UnityEngine.Random.Range(0, ConfigSystem.GetConfig<FreeImageLibrary>().Count)].id;
|
Free_Alubum_1 = ConfigSystem.GetFreeImageConfig()[UnityEngine.Random.Range(0, ConfigSystem.GetFreeImageConfig().Count)].id;
|
||||||
}
|
}
|
||||||
Debug.Log(JsonConvert.SerializeObject(filtered) + ",,,,,,,,,,,,,,,,,,,,");
|
Debug.Log(JsonConvert.SerializeObject(filtered) + ",,,,,,,,,,,,,,,,,,,,");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (AD_Alubum < 0)
|
if (AD_Alubum < 0)
|
||||||
{
|
{
|
||||||
HashSet<int> levelIds = new HashSet<int>(ad_level_list);
|
HashSet<int> levelIds = new HashSet<int>(ad_level_list);
|
||||||
List<ADImageLibrary> filtered = ConfigSystem.GetConfig<ADImageLibrary>().Where(x => !levelIds.Contains(x.id)).ToList();
|
List<ADImageLibrary> filtered = ConfigSystem.GetADImageConfig().Where(x => !levelIds.Contains(x.id)).ToList();
|
||||||
if (filtered.Count > 0)
|
if (filtered.Count > 0)
|
||||||
{
|
{
|
||||||
AD_Alubum = filtered[UnityEngine.Random.Range(0, filtered.Count)].id;
|
AD_Alubum = filtered[UnityEngine.Random.Range(0, filtered.Count)].id;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
AD_Alubum = ConfigSystem.GetConfig<ADImageLibrary>()[UnityEngine.Random.Range(0, ConfigSystem.GetConfig<ADImageLibrary>().Count)].id;
|
AD_Alubum = ConfigSystem.GetADImageConfig()[UnityEngine.Random.Range(0, ConfigSystem.GetADImageConfig().Count)].id;
|
||||||
}
|
}
|
||||||
Debug.Log(JsonConvert.SerializeObject(filtered) + ",,,,,,,,,,,,,,,,,,,,");
|
Debug.Log(JsonConvert.SerializeObject(filtered) + ",,,,,,,,,,,,,,,,,,,,");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Spec_Alubum < 0)
|
if (Spec_Alubum < 0)
|
||||||
{
|
{
|
||||||
HashSet<int> levelIds = new HashSet<int>(special_level_list);
|
HashSet<int> levelIds = new HashSet<int>(special_level_list);
|
||||||
List<SpecialImageLibrary> filtered = ConfigSystem.GetConfig<SpecialImageLibrary>().Where(x => !levelIds.Contains(x.id)).ToList();
|
List<SpecialImageLibrary> filtered = ConfigSystem.GetSpecialImageConfig().Where(x => !levelIds.Contains(x.id)).ToList();
|
||||||
if (filtered.Count > 0)
|
if (filtered.Count > 0)
|
||||||
{
|
{
|
||||||
Spec_Alubum = filtered[UnityEngine.Random.Range(0, filtered.Count)].id;
|
Spec_Alubum = filtered[UnityEngine.Random.Range(0, filtered.Count)].id;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Spec_Alubum = ConfigSystem.GetConfig<SpecialImageLibrary>()[UnityEngine.Random.Range(0, ConfigSystem.GetConfig<SpecialImageLibrary>().Count)].id;
|
Spec_Alubum = ConfigSystem.GetSpecialImageConfig()[UnityEngine.Random.Range(0, ConfigSystem.GetSpecialImageConfig().Count)].id;
|
||||||
}
|
}
|
||||||
Debug.Log(JsonConvert.SerializeObject(filtered) + ",,,,,,,,,,,,,,,,,,,,");
|
Debug.Log(JsonConvert.SerializeObject(filtered) + ",,,,,,,,,,,,,,,,,,,,");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Vip_Alubum < 0)
|
if (Vip_Alubum < 0)
|
||||||
{
|
{
|
||||||
HashSet<int> levelIds = new HashSet<int>(vip_level_list);
|
HashSet<int> levelIds = new HashSet<int>(vip_level_list);
|
||||||
List<VIPImageLibrary> filtered = ConfigSystem.GetConfig<VIPImageLibrary>().Where(x => !levelIds.Contains(x.id)).ToList();
|
List<VIPImageLibrary> filtered = ConfigSystem.GetVIPImageConfig().Where(x => !levelIds.Contains(x.id)).ToList();
|
||||||
if (filtered.Count > 0)
|
if (filtered.Count > 0)
|
||||||
{
|
{
|
||||||
Vip_Alubum = filtered[UnityEngine.Random.Range(0, filtered.Count)].id;
|
Vip_Alubum = filtered[UnityEngine.Random.Range(0, filtered.Count)].id;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Vip_Alubum = ConfigSystem.GetConfig<VIPImageLibrary>()[UnityEngine.Random.Range(0, ConfigSystem.GetConfig<VIPImageLibrary>().Count)].id;
|
Vip_Alubum = ConfigSystem.GetVIPImageConfig()[UnityEngine.Random.Range(0, ConfigSystem.GetVIPImageConfig().Count)].id;
|
||||||
}
|
}
|
||||||
Debug.Log(JsonConvert.SerializeObject(filtered) + ",,,,,,,,,,,,,,,,,,,,");
|
Debug.Log(JsonConvert.SerializeObject(filtered) + ",,,,,,,,,,,,,,,,,,,,");
|
||||||
}
|
}
|
||||||
PlayerPrefs.SetInt("Free_Alubum_0", Free_Alubum_0);
|
PlayerPrefs.SetInt("Free_Alubum_0", Free_Alubum_0);
|
||||||
PlayerPrefs.SetInt("Free_Alubum_1", Free_Alubum_1);
|
PlayerPrefs.SetInt("Free_Alubum_1", Free_Alubum_1);
|
||||||
PlayerPrefs.SetInt("AD_Alubum", AD_Alubum);
|
PlayerPrefs.SetInt("AD_Alubum", AD_Alubum);
|
||||||
PlayerPrefs.SetInt("Spec_Alubum", Spec_Alubum);
|
PlayerPrefs.SetInt("Spec_Alubum", Spec_Alubum);
|
||||||
PlayerPrefs.SetInt("Vip_Alubum", Vip_Alubum);
|
PlayerPrefs.SetInt("Vip_Alubum", Vip_Alubum);
|
||||||
|
|
||||||
var downloadNameList = new List<string>
|
var downloadNameList = new List<string>
|
||||||
{
|
{
|
||||||
FreeImageLibrary_[Free_Alubum_0].Name,
|
FreeImageLibrary_[Free_Alubum_0].Name,
|
||||||
FreeImageLibrary_[Free_Alubum_1].Name,
|
FreeImageLibrary_[Free_Alubum_1].Name,
|
||||||
ADImageLibrary_[AD_Alubum].Name,
|
ADImageLibrary_[AD_Alubum].Name,
|
||||||
SpecialImageLibrary_[Spec_Alubum].Name,
|
SpecialImageLibrary_[Spec_Alubum].Name,
|
||||||
VIPImageLibrary_[Vip_Alubum].Name
|
VIPImageLibrary_[Vip_Alubum].Name
|
||||||
};
|
};
|
||||||
|
|
||||||
Debug.Log(
|
Debug.Log(
|
||||||
$"[init down picture Album]---1---nameList----------{JsonConvert.SerializeObject(downloadNameList)}");
|
$"[init down picture Album]---1---nameList----------{JsonConvert.SerializeObject(downloadNameList)}");
|
||||||
|
|
||||||
// 添加不在downloadNameList中的项,最多添加12个
|
// 添加不在downloadNameList中的项,最多添加12个
|
||||||
// var addedCount = 0;
|
// var addedCount = 0;
|
||||||
// for (var i = 0; i < liveConfigList.Count && addedCount < 6; i++)
|
// for (var i = 0; i < liveConfigList.Count && addedCount < 6; i++)
|
||||||
// if (!downloadNameList.Contains(liveConfigList[i].Name))
|
// if (!downloadNameList.Contains(liveConfigList[i].Name))
|
||||||
// {
|
// {
|
||||||
// downloadNameList.Add(liveConfigList[i].Name);
|
// downloadNameList.Add(liveConfigList[i].Name);
|
||||||
// addedCount++;
|
// addedCount++;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
Debug.Log(
|
Debug.Log(
|
||||||
$"[init down picture Album]---2---nameList----------{JsonConvert.SerializeObject(downloadNameList)}");
|
$"[init down picture Album]---2---nameList----------{JsonConvert.SerializeObject(downloadNameList)}");
|
||||||
|
|
||||||
// int centerIndex = GameHelper.GetLevel();
|
// int centerIndex = GameHelper.GetLevel();
|
||||||
// int totalCount = downloadNameList.Count;
|
// int totalCount = downloadNameList.Count;
|
||||||
|
|
||||||
// // 计算起始索引和实际要取的数量
|
// // 计算起始索引和实际要取的数量
|
||||||
// int rangeStart = Math.Max(0, centerIndex - 5);
|
// int rangeStart = Math.Max(0, centerIndex - 5);
|
||||||
// int rangeEnd = Math.Min(totalCount, centerIndex + 5);
|
// int rangeEnd = Math.Min(totalCount, centerIndex + 5);
|
||||||
// int rangeCount = rangeEnd - rangeStart;
|
// int rangeCount = rangeEnd - rangeStart;
|
||||||
|
|
||||||
// // 获取范围内元素并反转
|
// // 获取范围内元素并反转
|
||||||
// var segment = downloadNameList.GetRange(rangeStart, rangeCount);
|
// var segment = downloadNameList.GetRange(rangeStart, rangeCount);
|
||||||
// segment.Reverse();
|
// segment.Reverse();
|
||||||
|
|
||||||
// // 移除原始位置的元素
|
// // 移除原始位置的元素
|
||||||
// downloadNameList.RemoveRange(rangeStart, rangeCount);
|
// downloadNameList.RemoveRange(rangeStart, rangeCount);
|
||||||
|
|
||||||
// // 插入反转后的元素到最前面
|
// // 插入反转后的元素到最前面
|
||||||
// downloadNameList.InsertRange(0, segment);
|
// downloadNameList.InsertRange(0, segment);
|
||||||
|
|
||||||
|
|
||||||
Debug.Log(
|
Debug.Log(
|
||||||
$"[init down picture Album]---3---nameList----------{JsonConvert.SerializeObject(downloadNameList)}");
|
$"[init down picture Album]---3---nameList----------{JsonConvert.SerializeObject(downloadNameList)}");
|
||||||
|
|
||||||
foreach (var name in downloadNameList)
|
foreach (var name in downloadNameList)
|
||||||
{
|
{
|
||||||
var localPath = Path.Combine(TextureHelper.getResPath(), FolderNames.AlbumName, name + ".jpg");
|
var localPath = Path.Combine(TextureHelper.getResPath(), FolderNames.AlbumName, name + ".jpg");
|
||||||
Debug.Log($"[预下载 Albums 路径]-------localPath===={localPath}");
|
Debug.Log($"[预下载 Albums 路径]-------localPath===={localPath}");
|
||||||
if (!File.Exists(localPath))
|
if (!File.Exists(localPath))
|
||||||
{
|
{
|
||||||
Debug.Log($"[开始预下载 Albums ]--------------name-{name}");
|
Debug.Log($"[开始预下载 Albums ]--------------name-{name}");
|
||||||
TextureHelper.SetImgLoader(null, name,
|
TextureHelper.SetImgLoader(null, name,
|
||||||
s =>
|
s =>
|
||||||
{
|
{
|
||||||
Debug.Log($"[init down Album picture]----------------{name}");
|
Debug.Log($"[init down Album picture]----------------{name}");
|
||||||
}, "LevelAlbums/", FolderNames.AlbumName, false);
|
}, "LevelAlbums/", FolderNames.AlbumName, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void StartDownloadLivePicture()
|
public static void StartDownloadLivePicture()
|
||||||
{
|
{
|
||||||
var liveConfigList = ConfigSystem.GetConfig<Live>();
|
var liveConfigList = ConfigSystem.GetLiveConfig();
|
||||||
var liveList = DataMgr.SecretUnlockList.Value;
|
var liveList = DataMgr.SecretUnlockList.Value;
|
||||||
|
|
||||||
var downloadNameList = new List<string>();
|
var downloadNameList = new List<string>();
|
||||||
|
|
||||||
// 先加入所有可用的图片
|
// 先加入所有可用的图片
|
||||||
for (var i = 0; i < liveConfigList.Count; i++)
|
for (var i = 0; i < liveConfigList.Count; i++)
|
||||||
if (liveConfigList[i] != null && !downloadNameList.Contains(liveConfigList[i].Name))
|
if (liveConfigList[i] != null && !downloadNameList.Contains(liveConfigList[i].Name))
|
||||||
downloadNameList.Add(liveConfigList[i].Name);
|
downloadNameList.Add(liveConfigList[i].Name);
|
||||||
|
|
||||||
Debug.Log(
|
Debug.Log(
|
||||||
$"[init down picture LiveCover]---1---nameList----------{JsonConvert.SerializeObject(downloadNameList)}");
|
$"[init down picture LiveCover]---1---nameList----------{JsonConvert.SerializeObject(downloadNameList)}");
|
||||||
|
|
||||||
// 添加不在downloadNameList中的项,最多添加6个
|
// 添加不在downloadNameList中的项,最多添加6个
|
||||||
|
|
||||||
foreach (var name in downloadNameList)
|
foreach (var name in downloadNameList)
|
||||||
{
|
{
|
||||||
var localPath = Path.Combine(TextureHelper.getResPath(), FolderNames.VideoCoversName, name + "_cover" + ".jpg");
|
var localPath = Path.Combine(TextureHelper.getResPath(), FolderNames.VideoCoversName, name + "_cover" + ".jpg");
|
||||||
Debug.Log($"[预下载 Secret 路径]-------localPath===={localPath}");
|
Debug.Log($"[预下载 Secret 路径]-------localPath===={localPath}");
|
||||||
if (!File.Exists(localPath))
|
if (!File.Exists(localPath))
|
||||||
{
|
{
|
||||||
Debug.Log("[开始预下载 Secret ]---------------");
|
Debug.Log("[开始预下载 Secret ]---------------");
|
||||||
TextureHelper.SetImgLoader(null, name + "_cover",
|
TextureHelper.SetImgLoader(null, name + "_cover",
|
||||||
s =>
|
s =>
|
||||||
{
|
{
|
||||||
Debug.Log($"[init down VideoCovers picture]----------------{name}");
|
Debug.Log($"[init down VideoCovers picture]----------------{name}");
|
||||||
}, "LiveAlbums/", FolderNames.VideoCoversName, false);
|
}, "LiveAlbums/", FolderNames.VideoCoversName, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user