811 lines
31 KiB
C#
811 lines
31 KiB
C#
using System;
|
|
using DG.Tweening;
|
|
using UnityEngine;
|
|
using Spine.Unity;
|
|
using FairyGUI;
|
|
using FGUI.ZM_Common_01;
|
|
using System.Linq;
|
|
using System.Collections.Generic;
|
|
using Random = UnityEngine.Random;
|
|
using IgnoreOPS;
|
|
using Unity.VisualScripting;
|
|
using Newtonsoft.Json;
|
|
using System.IO;
|
|
using FGUI.LG_Common;
|
|
using SGModule.Common.Extensions;
|
|
using SGModule.Common.Helper;
|
|
using SGModule.Net;
|
|
|
|
|
|
namespace BallKingdomCrush
|
|
{
|
|
public class HallUI : BaseUI
|
|
{
|
|
private HallUICtrl ctrl;
|
|
private HallModel model;
|
|
public FGUI.ZM_Lobby_03.com_hall ui;
|
|
|
|
public static bool isClosed = false;
|
|
|
|
private long userUid;
|
|
public int active_cd = 10;
|
|
private Tweener tweener;
|
|
|
|
private SkeletonAnimation anim_ad;
|
|
private SkeletonAnimation anim_banma = null;
|
|
|
|
private FGUI.ZM_Common_01.btn_noads btn_noads;
|
|
public HallUI(HallUICtrl ctrl) : base(ctrl)
|
|
{
|
|
uiName = UIConst.HallUI;
|
|
this.ctrl = ctrl;
|
|
}
|
|
private string jsonstr;
|
|
|
|
private List<GLoader> loader_list = new List<GLoader>();
|
|
|
|
protected override void SetUIInfo(UIInfo uiInfo)
|
|
{
|
|
uiInfo.packageName = "ZM_Lobby_03";
|
|
uiInfo.assetName = "com_hall";
|
|
uiInfo.layerType = UILayerType.Normal;
|
|
uiInfo.isNeedOpenAnim = false;
|
|
uiInfo.isNeedCloseAnim = false;
|
|
uiInfo.isNeedUIMask = false;
|
|
}
|
|
|
|
#region 生命周期
|
|
|
|
protected override void OnInit()
|
|
{
|
|
model = moduleManager.GetModel(ModelConst.HallModel) as HallModel;
|
|
InitData();
|
|
}
|
|
|
|
protected override void OnClose()
|
|
{
|
|
|
|
HallManager.Instance.UpdateSecondEvent -= UpBtnCoin;
|
|
isClosed = true;
|
|
//关闭时保存cd数据
|
|
PlayerPrefs.SetInt($"active_cd_num_{userUid}", active_cd);
|
|
// HallManager.Instance.countTimes = (int)Time.time;
|
|
|
|
CommonHelper.FadeOut(ui);
|
|
tweener?.Kill();
|
|
closeCallback?.Invoke();
|
|
|
|
foreach (var t in loader_list)
|
|
{
|
|
if (t != null && !t.isDisposed && t.texture != null)
|
|
{
|
|
t.texture = null;
|
|
}
|
|
}
|
|
loader_list.Clear();
|
|
}
|
|
|
|
protected override void OnBind()
|
|
{
|
|
ui = baseUI as FGUI.ZM_Lobby_03.com_hall;
|
|
}
|
|
|
|
protected override void OnOpenBefore(object args)
|
|
{
|
|
//测试代码
|
|
// ui.top_bg.visible = false;
|
|
// ui.bg.visible = false;
|
|
|
|
if (Screen.safeArea.y != 0)
|
|
{
|
|
ui.group_.y += 68;
|
|
}
|
|
// ui.com_panel.scrollPane.ScrollRight(12,false);
|
|
// if(GameHelper.IsGiftSwitch())
|
|
// {
|
|
// ui.com_panel.scrollPane.touchEffect = false;
|
|
// }
|
|
|
|
|
|
CreateGoldtimeList();
|
|
|
|
var isNew = DataMgr.NoviceGuide.Value;
|
|
|
|
if (!GameHelper.IsGiftSwitch() && !isNew)
|
|
{
|
|
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.GuideViewUI_Open);
|
|
}
|
|
GameHelper.IsShowFirstReward();
|
|
|
|
isClosed = false;
|
|
|
|
btn_noads = (btn_noads)ui.btn_noads;
|
|
var loginModel = GameHelper.GetLoginModel();
|
|
userUid = loginModel.Uid;
|
|
|
|
InitView();
|
|
UpBtnCoin();
|
|
|
|
HallManager.Instance.UpdateSecondEvent += UpBtnCoin;
|
|
ui.btn_album.SetClick(() =>
|
|
{
|
|
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.AlubumUI_Open);
|
|
});
|
|
int live = GameHelper.GetCommonModel().Live;
|
|
int secret = GameHelper.GetCommonModel().Secret;
|
|
int lv1 = GameHelper.GetCommonModel().LivePreview;
|
|
int lv2 = GameHelper.GetCommonModel().SecretPreview;
|
|
if (GameHelper.IsGiftSwitch() && (GameHelper.GetCommonModel().Live == 1) && (GameHelper.GetLevel() >= GameHelper.GetCommonModel().LivePreview))
|
|
{
|
|
ui.btn_live.visible = true;
|
|
}
|
|
if (GameHelper.IsGiftSwitch() && (GameHelper.GetCommonModel().Secret == 1) && (GameHelper.GetLevel() >= GameHelper.GetCommonModel().SecretPreview))
|
|
{
|
|
ui.btn_secret.visible = true;
|
|
}
|
|
|
|
SetIconTipsAnim();
|
|
|
|
int random_ = Random.Range(0, 100);
|
|
// GameHelper.GetCommonModel().roomGuideRate = 100;//zhushi
|
|
Debug.Log("-------------"+GameHelper.GetCommonModel().HomeGuideRate);
|
|
if (GameHelper.IsGiftSwitch() && random_ < GameHelper.GetCommonModel().HomeGuideRate)
|
|
{
|
|
List<int> unlocklist = new List<int>();
|
|
if ((GameHelper.GetCommonModel().Live == 1) && (GameHelper.GetLevel() >= GameHelper.GetCommonModel().LivePreview) && (GameHelper.GetLevel() < GameHelper.GetCommonModel().UnlockLive[1]))
|
|
{
|
|
if (DataMgr.IsUnlockLive.Value < 0 && GameHelper.GetVipLevel() < 0)//未解锁。
|
|
{
|
|
unlocklist.Add(0);
|
|
}
|
|
}
|
|
if ((GameHelper.GetCommonModel().Secret == 1) && (GameHelper.GetLevel() >= GameHelper.GetCommonModel().SecretPreview) && (GameHelper.GetLevel() < GameHelper.GetCommonModel().UnlockSecret[1]))
|
|
{
|
|
if (DataMgr.IsUnlockSecret.Value < 0 && GameHelper.GetVipLevel() < 0)//未解锁。
|
|
{
|
|
unlocklist.Add(1);
|
|
}
|
|
}
|
|
// if ((GameHelper.GetCommonModel().Assitant == 1) && (GameHelper.GetLevel() >= GameHelper.GetCommonModel().AssitantPreview))
|
|
// {
|
|
// if (DataMgr.IsUnlockChat.Value < 0 && GameHelper.GetVipLevel() < 0)//未解锁。
|
|
// {
|
|
// unlocklist.Add(2);
|
|
// }
|
|
// }
|
|
if (unlocklist.Count > 0)
|
|
{
|
|
int random_index = Random.Range(0, unlocklist.Count);
|
|
if (unlocklist[random_index] == 0)
|
|
{
|
|
uiCtrlDispatcher.Dispatch(UICtrlMsg.LiveUnlockUI_Open);
|
|
}
|
|
else if (unlocklist[random_index] == 1)
|
|
{
|
|
uiCtrlDispatcher.Dispatch(UICtrlMsg.ScAlbumLockUI_Open);
|
|
}
|
|
// else if (unlocklist[random_index] == 2)
|
|
// {
|
|
// // uiCtrlDispatcher.Dispatch(UICtrlMsg.ChatUnlockUI_Open);
|
|
// }
|
|
}
|
|
}
|
|
// ui.bg_loader;
|
|
Setbg();
|
|
// if (GameHelper.IsGiftSwitch() && GameHelper.GetCommonModel().Assitant == 1 && GameHelper.GetLevel() >= GameHelper.GetCommonModel().AssitantPreview)
|
|
// {
|
|
// ui.btn_chat.visible = true;
|
|
// SkeletonAnimation ske_pot = FXManager.Instance.SetFx<SkeletonAnimation>(ui.btn_chat.ani_parent, Fx_Type.fx_btnchat, ref closeCallback);
|
|
// ske_pot.state.SetAnimation(0, "animation", true);
|
|
// ui.btn_chat.SetClick(() =>
|
|
// {
|
|
//
|
|
// UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.ChatChooseUI_Open);
|
|
// Log.Info("Hall", $"{GameHelper.GetLevel()}/{GameHelper.GetCommonModel().UnlockSecret[1]}/{DataMgr.IsUnlockSecret.Value}");
|
|
// });
|
|
// }
|
|
}
|
|
|
|
|
|
void SetIconTipsAnim()
|
|
{
|
|
((btn_albums)ui.btn_album).t0.Play();
|
|
((btn_live)ui.btn_live).t0.Play();
|
|
}
|
|
|
|
void Setbg(object a = null)
|
|
{
|
|
if (!GameHelper.IsGiftSwitch())
|
|
{
|
|
return;
|
|
}
|
|
|
|
if (GameHelper.GetLevel() - 1 < GameHelper.GetCommonModel().MultiModal)
|
|
{
|
|
int level_ = GameHelper.GetLevel() - 2;
|
|
if (level_ <= 0) level_ = 0;
|
|
if (level_ >= ConfigSystem.GetConfig<LevelUnlock>().Count) level_ = ConfigSystem.GetConfig<LevelUnlock>().Count - 1;
|
|
TextureHelper.SetImgLoader(ui.bg_loader, ConfigSystem.GetConfig<LevelUnlock>()[level_].Name, null, "LevelAlbums/", FolderNames.AlbumName);
|
|
}
|
|
else
|
|
{
|
|
Levelunlock levelunlock_ = DataMgr.LevelUnlockListNew.Value.FirstOrDefault(x => x.level_ == GameHelper.GetLevel() - 1);
|
|
if (levelunlock_ != null)
|
|
{
|
|
if (levelunlock_.type == 0)
|
|
{
|
|
if (levelunlock_.config_index >= ConfigSystem.GetConfig<FreeImageLibrary>().Count) levelunlock_.config_index = ConfigSystem.GetConfig<FreeImageLibrary>().Count - 1;
|
|
FreeImageLibrary _leveldata = ConfigSystem.GetConfig<FreeImageLibrary>()[levelunlock_.config_index];
|
|
TextureHelper.SetImgLoader(ui.bg_loader, _leveldata.Name, null, "LevelAlbums/", FolderNames.AlbumName);
|
|
}
|
|
else if (levelunlock_.type == 1)
|
|
{
|
|
if (levelunlock_.config_index >= ConfigSystem.GetConfig<ADImageLibrary>().Count) levelunlock_.config_index = ConfigSystem.GetConfig<ADImageLibrary>().Count - 1;
|
|
ADImageLibrary _leveldata = ConfigSystem.GetConfig<ADImageLibrary>()[levelunlock_.config_index];
|
|
TextureHelper.SetImgLoader(ui.bg_loader, _leveldata.Name, null, "LevelAlbums/", FolderNames.AlbumName);
|
|
}
|
|
else if (levelunlock_.type == 2)
|
|
{
|
|
if (levelunlock_.config_index >= ConfigSystem.GetConfig<SpecialImageLibrary>().Count) levelunlock_.config_index = ConfigSystem.GetConfig<SpecialImageLibrary>().Count - 1;
|
|
SpecialImageLibrary _leveldata = ConfigSystem.GetConfig<SpecialImageLibrary>()[levelunlock_.config_index];
|
|
TextureHelper.SetImgLoader(ui.bg_loader, _leveldata.Name, null, "LevelAlbums/", FolderNames.AlbumName);
|
|
}
|
|
else if (levelunlock_.type == 3)
|
|
{
|
|
if (levelunlock_.config_index >= ConfigSystem.GetConfig<VIPImageLibrary>().Count) levelunlock_.config_index = ConfigSystem.GetConfig<VIPImageLibrary>().Count - 1;
|
|
VIPImageLibrary _leveldata = ConfigSystem.GetConfig<VIPImageLibrary>()[levelunlock_.config_index];
|
|
TextureHelper.SetImgLoader(ui.bg_loader, _leveldata.Name, null, "LevelAlbums/", FolderNames.AlbumName);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
int level_ = GameHelper.GetLevel() - 2;
|
|
if (level_ < 0) level_ = 0;
|
|
if (level_ >= ConfigSystem.GetConfig<LevelUnlock>().Count) level_ = ConfigSystem.GetConfig<LevelUnlock>().Count - 1;
|
|
TextureHelper.SetImgLoader(ui.bg_loader, ConfigSystem.GetConfig<LevelUnlock>()[level_].Name, null, "LevelAlbums/", FolderNames.AlbumName);
|
|
}
|
|
}
|
|
|
|
// int level_ = GameHelper.GetLevel() - 2;
|
|
// if (level_ < 0) level_ = 0;
|
|
// List<LevelUnlock> LevelData = ConfigSystem.GetConfig<LevelUnlock>();
|
|
|
|
// // 确保 level_ 不超过 LevelData 的最大索引
|
|
// if (level_ >= LevelData.Count)
|
|
// {
|
|
// level_ = LevelData.Count - 1;
|
|
// }
|
|
|
|
// for (int i = level_; i >= 0; i--)
|
|
// {
|
|
// // 添加对数组索引的有效性检查
|
|
// if (i >= LevelData.Count) continue;
|
|
|
|
// if (LevelData[i].LeveType != 0)
|
|
// {
|
|
// if (!DataMgr.LevelUnlockList.Value.Contains(i)) continue;
|
|
// else
|
|
// {
|
|
// Debug.Log($"[hall 背景图 加载1]-------LevelData[i].Name===={LevelData[i].Name}");
|
|
// TextureHelper.SetImgLoader(ui.bg_loader, LevelData[i].Name, null, "LevelAlbums/");
|
|
// break;
|
|
// }
|
|
|
|
// }
|
|
// else
|
|
// {
|
|
// Debug.Log($"[hall 背景图 加载2]-------LevelData[i].Name===={LevelData[i].Name}");
|
|
// TextureHelper.SetImgLoader(ui.bg_loader, LevelData[i].Name, null, "LevelAlbums/");
|
|
// break;
|
|
// }
|
|
// }
|
|
|
|
if (!loader_list.Contains(ui.bg_loader))
|
|
{
|
|
loader_list.Add(ui.bg_loader);
|
|
}
|
|
}
|
|
float showResurgence()
|
|
{
|
|
// string jsonFilePath = Path.Combine(Application.persistentDataPath, "RainData1.json");
|
|
// string jsonstr = "";
|
|
// if (File.Exists(jsonFilePath))
|
|
// {
|
|
// jsonstr = File.ReadAllText(jsonFilePath);
|
|
// //return JsonUtility.FromJson<MyData>(json);
|
|
// }
|
|
// List<List<Card_item>> card_item_list = JsonConvert.DeserializeObject<List<List<Card_item>>>(jsonstr);
|
|
|
|
// int surplus_item = 0;
|
|
// for (int i = 0; i < card_item_list.Count; i++)
|
|
// {
|
|
// for (int j = 0; j < card_item_list[i].Count; j++)
|
|
// {
|
|
// // if (card_item_list[i][j].sheep_card.IsDestroyed() || card_item_list[i][j].sheep_card == null) continue;
|
|
// surplus_item++;
|
|
// }
|
|
// }
|
|
|
|
var card_item_list = JsonConvert.DeserializeObject<List<List<Card_item>>>(jsonstr);
|
|
var surplus_item = 0;
|
|
for (var i = 0; i < card_item_list.Count; i++)
|
|
{
|
|
for (var j = 0; j < card_item_list[i].Count; j++)
|
|
{
|
|
surplus_item++;
|
|
}
|
|
}
|
|
return 1 - (float)surplus_item / (SaveData.GetSaveObject().all_card_numbers * 3);
|
|
|
|
}
|
|
|
|
private void getJsonData()
|
|
{
|
|
var json = DataMgr.LevelData.Value;
|
|
if (!string.IsNullOrEmpty(json))
|
|
{
|
|
jsonstr = json;
|
|
}
|
|
}
|
|
protected override void OnOpen(object args)
|
|
{
|
|
// CommonHelper.FadeIn(ui);
|
|
}
|
|
|
|
protected override void OnHide()
|
|
{
|
|
}
|
|
|
|
protected override void OnDisplay(object args)
|
|
{
|
|
}
|
|
|
|
public override void OnSwitchLanguage()
|
|
{
|
|
base.OnSwitchLanguage();
|
|
ui.btn_secret.title = "LV." + GameHelper.GetCommonModel().UnlockSecret[1];
|
|
ui.btn_play.text_lv.text = Language.GetContent("Level") + " " + GameHelper.GetLevel();
|
|
// InitView();
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 消息
|
|
|
|
protected override void AddListener()
|
|
{
|
|
|
|
|
|
PreferencesDispatcher<int>.Instance.AddListener(DataMsg.playerAvatarId, UpdataAvatar);
|
|
GameDispatcher.Instance.AddListener(GameMsg.RefreshRedDot, RefreshRed);
|
|
GameDispatcher.Instance.AddListener(GameMsg.Gold_refresh, Chang101);
|
|
GameDispatcher.Instance.AddListener(GameMsg.UpdateNoads, SetBtnAds);
|
|
UICtrlDispatcher.Instance.AddListener(UICtrlMsg.AlubumUI_Close, Setbg);
|
|
}
|
|
|
|
protected override void RemoveListener()
|
|
{
|
|
|
|
PreferencesDispatcher<int>.Instance.RemoveListener(DataMsg.playerAvatarId, UpdataAvatar);
|
|
GameDispatcher.Instance.RemoveListener(GameMsg.RefreshRedDot, RefreshRed);
|
|
GameDispatcher.Instance.RemoveListener(GameMsg.Gold_refresh, Chang101);
|
|
GameDispatcher.Instance.RemoveListener(GameMsg.UpdateNoads, SetBtnAds);
|
|
UICtrlDispatcher.Instance.RemoveListener(UICtrlMsg.AlubumUI_Close, Setbg);
|
|
}
|
|
#endregion
|
|
private List<Paidcoins> Paidcoins_list = ConfigSystem.GetConfig<Paidcoins>();
|
|
|
|
private int time_count = 11;
|
|
|
|
void CreateGoldtimeList()
|
|
{
|
|
// 获取保存对象
|
|
var saveObject = SaveData.GetSaveObject();
|
|
|
|
// 检查_goldtime是否为null或者长度与Paidcoins_list.Count不相等
|
|
if (saveObject._goldtime == null || saveObject._goldtime.Length != Paidcoins_list.Count)
|
|
{
|
|
// 重置_goldtime,并创建一个新的数组,长度为Paidcoins_list.Count
|
|
saveObject._goldtime = new int[Paidcoins_list.Count];
|
|
}
|
|
}
|
|
|
|
private void UpBtnCoin()
|
|
{
|
|
int free_index = 0;
|
|
for (int i = 0; i < Paidcoins_list.Count; i++)
|
|
{
|
|
if (!Paidcoins_list[i].is_paid)
|
|
{
|
|
free_index = i;
|
|
}
|
|
}
|
|
int time = SaveData.GetSaveObject()._goldtime[free_index];
|
|
com_gold btn_gold = ui.btn_gold as com_gold;
|
|
if (time + Paidcoins_list[free_index].receive_CD < GameHelper.GetNowTime())
|
|
{
|
|
btn_gold.state.selectedIndex = 2;
|
|
(ui.btn_shop as btn_shop).red.visible = true;
|
|
}
|
|
else
|
|
{
|
|
btn_gold.state.selectedIndex = 1;
|
|
(ui.btn_shop as btn_shop).red.visible = false;
|
|
}
|
|
checkThreeGift();
|
|
|
|
}
|
|
|
|
|
|
private void InitData()
|
|
{
|
|
model.showCoin = DataMgr.Coin.Value;
|
|
model.showDollar = DataMgr.Ticket.Value;
|
|
}
|
|
|
|
private Action closeCallback;
|
|
|
|
private void InitView()
|
|
{
|
|
|
|
Set101();
|
|
UpdataAvatar();
|
|
RefreshRed();
|
|
SetBtnAds();
|
|
|
|
// var btnShop = ui.btn_shop as btn_shop;
|
|
// var btnShopAnim = FXManager.Instance.SetFx<SkeletonAnimation>(btnShop.anim, Fx_Type.fx_btn_shop, ref closeCallback);
|
|
// btnShopAnim.state.SetAnimation(0, "animation", true);
|
|
var btnSecret = ui.btn_secret as btn_secret;
|
|
var btnSecretAnim = FXManager.Instance.SetFx<SkeletonAnimation>(btnSecret.anim, Fx_Type.fx_btn_secret, ref closeCallback);
|
|
btnSecretAnim.state.SetAnimation(0, "animation", true);
|
|
|
|
var btnVip = ui.btn_vip as btn_vip;
|
|
var btnVipAnim = FXManager.Instance.SetFx<SkeletonAnimation>(btnVip.anim, Fx_Type.fx_btn_vip, ref closeCallback);
|
|
btnVipAnim.state.SetAnimation(0, "animation", true);
|
|
btnVip.anim.SetScale(1.5f, 1.5f);
|
|
var btnAlbum = ui.btn_album as btn_albums;
|
|
var btnAlbumAnim = FXManager.Instance.SetFx<SkeletonAnimation>(btnAlbum.anim, Fx_Type.fx_btn_album, ref closeCallback);
|
|
btnAlbumAnim.state.SetAnimation(0, "animation", true);
|
|
// btnAlbum.anim.SetScale(0.8f, 0.8f);
|
|
|
|
var btnLive = ui.btn_live as btn_live;
|
|
var btnLiveAnim = FXManager.Instance.SetFx<SkeletonAnimation>(btnLive.anim, Fx_Type.fx_btn_live, ref closeCallback);
|
|
btnLiveAnim.state.SetAnimation(0, "animation", true);
|
|
btnLive.anim.SetScale(0.4f, 0.4f);
|
|
|
|
ui.btn_play.text_lv.text = Language.GetContent("Level") + " " + GameHelper.GetLevel();
|
|
ui.btn_play.SetClick(OnClickPlay);
|
|
|
|
ui.btn_setting.SetClick(OnClickSetting);
|
|
// ui.btn_secret.SetClick(OnClickSecretAlbums);
|
|
ui.btn_vip.SetClick(onClickVip);
|
|
|
|
btn_noads.SetClick(() =>
|
|
{
|
|
if (!SaveData.GetSaveObject().is_get_packreward && !SaveData.GetSaveObject().is_get_removead)
|
|
{
|
|
if (btn_noads.img_ad.visible)
|
|
{
|
|
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.LuckyPackUI_Open, true);
|
|
}
|
|
else
|
|
{
|
|
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.LuckyPackUI_Open);
|
|
}
|
|
|
|
}
|
|
else if (SaveData.GetSaveObject().is_get_packreward)
|
|
{
|
|
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.LuckyPackUI_Open, true);
|
|
}
|
|
else
|
|
{
|
|
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.LuckyPackUI_Open);
|
|
}
|
|
});
|
|
|
|
ui.btn_wv.SetClick(() =>
|
|
{
|
|
CtrlDispatcher.Instance.Dispatch(CtrlMsg.open_wb);
|
|
});
|
|
|
|
ui.btn_live.SetClick(() =>
|
|
{
|
|
|
|
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.LiveUI_Open);
|
|
|
|
});
|
|
ui.btn_secret.title = "LV." + GameHelper.GetCommonModel().UnlockSecret[1];
|
|
ui.btn_secret.SetClick(() =>
|
|
{
|
|
if (GameHelper.GetLevel() < GameHelper.GetCommonModel().UnlockSecret[1])
|
|
{
|
|
Log.Info("Hall", $"{GameHelper.GetLevel()}/{GameHelper.GetCommonModel().UnlockSecret[1]}/{DataMgr.IsUnlockSecret.Value}");
|
|
|
|
if (DataMgr.IsUnlockSecret.Value < 0 && GameHelper.GetVipLevel() < 0)//未解锁。
|
|
{
|
|
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.SecretUnlockUI_Open);
|
|
}
|
|
else
|
|
{
|
|
if (DataMgr.IsUnlockSecret.Value == 0 && GameHelper.GetCommonModel().Secret == 1 && GameHelper.GetCommonModel().Live == 1)
|
|
{
|
|
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.UnlockTipsUI_Open, 1);
|
|
}
|
|
else
|
|
{
|
|
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.SecretAlbumsUI_Open);
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.SecretAlbumsUI_Open);
|
|
}
|
|
|
|
});
|
|
|
|
ui.btn_task_level.SetClick(() => { OnClickTask(true); });
|
|
ui.btn_task_times.SetClick(() => { OnClickTask(false); });
|
|
ui.btn_task_pass.SetClick(() => { OnClickPass(); });
|
|
ui.btn_shop.SetClick(OnClickShop);
|
|
|
|
//ui.broadcast.visible = GameHelper.IsGiftSwitch();
|
|
|
|
// if (GameHelper.IsGiftSwitch() || (ConfigSystem.GetCommonConf().WVswitch == 1))
|
|
// {
|
|
// ui.btn_h5.visible = false;
|
|
// }
|
|
|
|
var btnCoin = ui.btn_gold as com_gold;
|
|
btnCoin.text_gold.text = $"{DataMgr.Coin.Value:N0}";
|
|
btnCoin.SetClick(OnClickShop);
|
|
|
|
ui.btn_head.SetClick(() => { UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.PersonViewUI_Open); });
|
|
UpdataAvatar();
|
|
|
|
if (HallManager.Instance.enterHallTimes == 1)
|
|
{
|
|
reCreatPur();
|
|
}
|
|
|
|
|
|
if (!GameHelper.IsGiftSwitch())
|
|
{
|
|
|
|
}
|
|
|
|
|
|
ui.state.selectedIndex = GameHelper.IsGiftSwitch() ? 1 : 0;
|
|
ui.btn_three_day.SetClick(() =>
|
|
{
|
|
uiCtrlDispatcher.Dispatch(UICtrlMsg.ThreeDaysGiftUI_Open);
|
|
});
|
|
|
|
// ui.btn_restore.SetClick(() =>
|
|
// {
|
|
// ApplePayManager.Instance.AppleRestore((success, message) =>
|
|
// {
|
|
// Debug.Log("[barry] restore success message: " + message);
|
|
// if (success)
|
|
// {
|
|
// Debug.Log("[barry] restore success: " + success);
|
|
// GameHelper.ShowTips("Restore Purchases Success!");
|
|
// SaveData.GetSaveObject().have_slot = success;
|
|
// DataMgr.VipLevel.Value = 3;
|
|
// DataMgr.VipExpirationTime.Value =
|
|
// ServerClock.GetCurrentServerTime() + 7 * 24 * 60 * 60;
|
|
// }
|
|
// else
|
|
// {
|
|
// GameHelper.ShowTips("There are no recoverable transactions");
|
|
// }
|
|
// });
|
|
// });
|
|
}
|
|
private void checkThreeGift(object obj = null)
|
|
{
|
|
// if (SaveData.GetSaveObject().is_get_ThreeDaysGift) {
|
|
var isToday = GameHelper.InToday(SaveData.GetSaveObject().last_got_three_gift_time, 0, true);
|
|
int three_gift_got_index = SaveData.GetSaveObject().three_gift_got_index;
|
|
if (three_gift_got_index > (int)rewardState.day3)
|
|
{
|
|
ui.btn_three_day.visible = false;
|
|
}
|
|
else if (!isToday)
|
|
{
|
|
ui.btn_three_day.GetChild("red").visible = true;
|
|
}
|
|
else
|
|
{
|
|
ui.btn_three_day.GetChild("red").visible = false;
|
|
}
|
|
// }
|
|
}
|
|
void reCreatPur(object a = null)
|
|
{
|
|
}
|
|
|
|
void SetBtnAds(object a = null)
|
|
{
|
|
if (!SaveData.GetSaveObject().is_get_removead && !SaveData.GetSaveObject().is_get_packreward)
|
|
{
|
|
btn_noads.t0.Play(-1, 0, null);
|
|
}
|
|
else if (SaveData.GetSaveObject().is_get_removead && SaveData.GetSaveObject().is_get_packreward)
|
|
{
|
|
btn_noads.t0.Stop();
|
|
// btn_noads.visible = false;
|
|
btn_noads.img_pack.visible = false;
|
|
btn_noads.img_ad.visible = true;
|
|
}
|
|
|
|
else if (SaveData.GetSaveObject().is_get_packreward)
|
|
{
|
|
btn_noads.t0.Stop();
|
|
btn_noads.t1.Play();
|
|
btn_noads.img_pack.visible = false;
|
|
btn_noads.img_ad.visible = true;
|
|
|
|
}
|
|
else if (SaveData.GetSaveObject().is_get_removead)
|
|
{
|
|
btn_noads.t0.Stop();
|
|
btn_noads.t1.Play();
|
|
btn_noads.img_pack.visible = true;
|
|
btn_noads.img_ad.visible = false;
|
|
}
|
|
|
|
}
|
|
|
|
private void RefreshRed(object isShow = null)
|
|
{
|
|
(ui.btn_task_pass as btn_task_pass).red.visible = SaveData.battlepassred();
|
|
(ui.btn_task_times as btn_task_times).red.visible = SaveData.timetaskred();
|
|
(ui.btn_task_level as btn_task).red.visible = SaveData.passtaskred();
|
|
// ui.btn_task.GetChild("red").visible = SaveData.timetaskred() || SaveData.passtaskred() || SaveData.AdTaskred();
|
|
(ui.btn_chat as btn_chat).red.visible = ChatHelper.GetChatRed();
|
|
}
|
|
|
|
private bool SignRed()
|
|
{
|
|
// sk.SetActive(false);
|
|
for (int i = 0; i < 7; i++)
|
|
{
|
|
var signDays = DataMgr.SignState.Value.Count;
|
|
var isToday = true;
|
|
if (signDays > 0)
|
|
isToday = GameHelper.InToday(DataMgr.SignState.Value[signDays - 1], 0, true);
|
|
|
|
else if (i == signDays)
|
|
{
|
|
if (signDays > 0 && isToday)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
private void OnClickLuckySpin()
|
|
{
|
|
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.WheelUI_Open);
|
|
}
|
|
|
|
private void OnClickTask(bool isLevel)
|
|
{
|
|
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.NewTaskUI_Open, isLevel);
|
|
}
|
|
private void OnClickPass()
|
|
{
|
|
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.PassViewUI_Open);
|
|
}
|
|
private void OnClickSign()
|
|
{
|
|
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.SignInUI_Open);
|
|
}
|
|
private void OnClickShop()
|
|
{
|
|
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.BuygoldUI_Open, true);
|
|
}
|
|
private void OnClickSetting()
|
|
{
|
|
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.MenuUI_Open, 1);
|
|
}
|
|
|
|
private void onClickVip()
|
|
{
|
|
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.VipClubViewUI_Open);
|
|
}
|
|
|
|
private void OnClickPlay()
|
|
{
|
|
// if (GameHelper.IsGiftSwitch() && !SaveData.GetSaveObject().have_slot && (DateTime.Now.Day != PlayerPrefs.GetInt("off_new", 0)))
|
|
// {
|
|
// Debug.Log("OnClickPlay--3");
|
|
// UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.AddviewnewUI_Open);
|
|
// PlayerPrefs.SetInt("off_new", DateTime.Now.Day);
|
|
// }
|
|
// else if (GameHelper.IsGiftSwitch() && !SaveData.GetSaveObject().have_slot && Random.Range(0, 100) < ConfigSystem.GetCommonConf().BonusInside)
|
|
// {
|
|
// Debug.Log("OnClickPlay--4");
|
|
// uiCtrlDispatcher.Dispatch(UICtrlMsg.AddviewnewUI_Open);
|
|
// }
|
|
// else
|
|
// {
|
|
|
|
if (GameHelper.GetLevel() < GameHelper.GetCommonModel().MultiModal)
|
|
{
|
|
GameHelper.gameType = 0;
|
|
GameDispatcher.Instance.Dispatch(GameMsg.OpenGame);
|
|
}
|
|
else
|
|
{
|
|
if (!DataMgr.LevelUnlockListNew.Value.Any(x => x.level_ == GameHelper.GetLevel()))
|
|
{
|
|
uiCtrlDispatcher.Dispatch(UICtrlMsg.UnlockLevelNewUI_Open);
|
|
}
|
|
else
|
|
{
|
|
GameHelper.gameType = 0;
|
|
GameDispatcher.Instance.Dispatch(GameMsg.OpenGame);
|
|
}
|
|
}
|
|
|
|
|
|
// }
|
|
}
|
|
|
|
public void OnUpdate101(object obj = null)
|
|
{
|
|
if (obj != null)
|
|
{
|
|
var changeValue = (decimal)obj;
|
|
model.showCoin += changeValue;
|
|
Set101(model.showCoin);
|
|
}
|
|
}
|
|
|
|
public void OnUpdate102(object obj = null)
|
|
{
|
|
if (obj != null)
|
|
{
|
|
var changeValue = (decimal)obj;
|
|
model.showDollar += changeValue;
|
|
}
|
|
}
|
|
private void UpdataAvatar(object obj = null)
|
|
{
|
|
var headId = DataMgr.PlayerAvatarId.Value;
|
|
if (obj != null)
|
|
{
|
|
headId = obj.As<ChangeValue<int>>().newValue;
|
|
}
|
|
var head = ui.btn_head as btn_head;
|
|
GameHelper.SetSelfAvatar(head.head.load_avatar, headId);
|
|
}
|
|
|
|
public void Set101(decimal coin = -1)
|
|
{
|
|
if (coin < 0)
|
|
{
|
|
coin = DataMgr.Coin.Value;
|
|
}
|
|
|
|
var btnCoin = ui.btn_gold as com_gold;
|
|
btnCoin.text_gold.text = $"{coin:N0}";
|
|
}
|
|
public void Chang101(object a = null)
|
|
{
|
|
|
|
int coin = DataMgr.Coin.Value;
|
|
|
|
|
|
var btnCoin = ui.btn_gold as com_gold;
|
|
btnCoin.text_gold.text = $"{coin:N0}";
|
|
}
|
|
}
|
|
} |