685 lines
24 KiB
C#
685 lines
24 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;
|
||
|
|
namespace ZooMatch
|
||
|
|
{
|
||
|
|
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 ad_numbers = 0;
|
||
|
|
public int ad_times = 0;
|
||
|
|
public int active_cd = 10;
|
||
|
|
private Tweener tweener;
|
||
|
|
|
||
|
|
private SkeletonAnimation anim_ad;
|
||
|
|
private SkeletonAnimation anim_banma = null;
|
||
|
|
|
||
|
|
private int limitTimes = 0;
|
||
|
|
private int OnlineLimit = 0;
|
||
|
|
private string formattedDate = "";
|
||
|
|
private FGUI.ZM_Common_01.btn_noads btn_noads;
|
||
|
|
public HallUI(HallUICtrl ctrl) : base(ctrl)
|
||
|
|
{
|
||
|
|
uiName = UIConst.HallUI;
|
||
|
|
this.ctrl = ctrl;
|
||
|
|
}
|
||
|
|
|
||
|
|
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;
|
||
|
|
HallManager.Instance.UpdateEvent -= UpdateEvent;
|
||
|
|
isClosed = true;
|
||
|
|
//关闭时保存cd数据
|
||
|
|
PlayerPrefs.SetInt($"active_cd_num_{userUid}", active_cd);
|
||
|
|
// HallManager.Instance.countTimes = (int)Time.time;
|
||
|
|
|
||
|
|
CommonHelper.FadeOut(ui);
|
||
|
|
tweener?.Kill();
|
||
|
|
closeCallback?.Invoke();
|
||
|
|
}
|
||
|
|
|
||
|
|
protected override void OnBind()
|
||
|
|
{
|
||
|
|
ui = baseUI as FGUI.ZM_Lobby_03.com_hall;
|
||
|
|
}
|
||
|
|
|
||
|
|
protected override void OnOpenBefore(object args)
|
||
|
|
{
|
||
|
|
|
||
|
|
if (Screen.safeArea.y != 0)
|
||
|
|
{
|
||
|
|
ui.btn_gold.y += Screen.safeArea.y - 15;
|
||
|
|
ui.com_money.y += Screen.safeArea.y - 15;
|
||
|
|
// ui.broadcast.y += Screen.safeArea.y - 40;
|
||
|
|
ui.btn_h5.y += Screen.safeArea.y - 40;
|
||
|
|
}
|
||
|
|
HallManager.Instance.UpdateEvent += UpdateEvent;
|
||
|
|
// ui.com_panel.scrollPane.ScrollRight(12,false);
|
||
|
|
// if(GameHelper.IsGiftSwitch())
|
||
|
|
// {
|
||
|
|
// ui.com_panel.scrollPane.touchEffect = false;
|
||
|
|
// }
|
||
|
|
|
||
|
|
|
||
|
|
CreateGoldtimeList();
|
||
|
|
|
||
|
|
int num = PlayerPrefs.GetInt("new_one", 0);
|
||
|
|
|
||
|
|
if (!GameHelper.IsGiftSwitch() && num == 0)
|
||
|
|
{
|
||
|
|
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.GuideViewUI_Open);
|
||
|
|
}
|
||
|
|
limitTimes = ConfigSystem.GetConfig<OnlineRewardsModel>().dataList[0].OnlineCountTime;
|
||
|
|
OnlineLimit = ConfigSystem.GetConfig<OnlineRewardsModel>().dataList[0].OnlineLimitNum;
|
||
|
|
|
||
|
|
btn_noads = ui.btn_noads as FGUI.ZM_Common_01.btn_noads;
|
||
|
|
|
||
|
|
System.DateTime dataTime = System.DateTime.Now;
|
||
|
|
formattedDate = dataTime.ToString("yyyy_MM_dd");
|
||
|
|
|
||
|
|
// int hall_cd = PlayerPrefs.GetInt($"coin_cd_times_{formattedDate}", 0);
|
||
|
|
// if (HallManager.Instance.countTimes != 0)
|
||
|
|
// {
|
||
|
|
// int cds = (int)Time.time - HallManager.Instance.countTimes;
|
||
|
|
// cds = hall_cd - cds;
|
||
|
|
// PlayerPrefs.SetInt($"coin_cd_times_{formattedDate}", cds <= 0 ? 0 : cds);
|
||
|
|
// HallManager.Instance.countTimes = 0;
|
||
|
|
// }
|
||
|
|
|
||
|
|
|
||
|
|
var reqData = new RespLoginFunnelData
|
||
|
|
{
|
||
|
|
type = "enterHall",
|
||
|
|
payload = ""
|
||
|
|
};
|
||
|
|
NetworkKit.PostFunnelLogin(reqData);
|
||
|
|
|
||
|
|
|
||
|
|
isClosed = false;
|
||
|
|
|
||
|
|
var loginModel = GameHelper.GetLoginModel();
|
||
|
|
userUid = loginModel.uid;
|
||
|
|
|
||
|
|
InitView();
|
||
|
|
UpBtnCoin();
|
||
|
|
setBtntask();
|
||
|
|
|
||
|
|
HallManager.Instance.UpdateSecondEvent += UpBtnCoin;
|
||
|
|
|
||
|
|
anim_ad = FXManager.Instance.SetFx<SkeletonAnimation>(ui.GetChild("bg_parent") as GGraph, Fx_Type.fx_ad, ref closeCallback);
|
||
|
|
anim_ad.state.SetAnimation(0, "animation", true);
|
||
|
|
|
||
|
|
|
||
|
|
anim_banma = FXManager.Instance.SetFx<SkeletonAnimation>(ui.btn_banma.GetChild("banma_bg") as GGraph, Fx_Type.fx_banma, ref closeCallback);
|
||
|
|
anim_banma.state.SetAnimation(0, "animation", true);
|
||
|
|
ui.btn_banma.SetScale(0.65f, 0.65f);
|
||
|
|
ui.btn_failpack.SetClick(() =>
|
||
|
|
{
|
||
|
|
float progress = showResurgence();
|
||
|
|
|
||
|
|
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.ResurgenceUI_Open, progress);
|
||
|
|
});
|
||
|
|
if (ConfigSystem.GetConfig<CommonModel>().PiggyBankSwitch == 0 || !GameHelper.IsGiftSwitch())
|
||
|
|
{
|
||
|
|
ui.btn_saveingpot.visible = false;
|
||
|
|
}
|
||
|
|
ui.btn_saveingpot.SetClick(() => { uiCtrlDispatcher.Dispatch(UICtrlMsg.SaveingPotUI_Open); });
|
||
|
|
|
||
|
|
var ske_pot = FXManager.Instance.SetFx<SkeletonAnimation>((ui.btn_saveingpot as btn_saveingpot).ani_parent, Fx_Type.fx_savepot_icon, ref closeCallback);
|
||
|
|
ske_pot.state.SetAnimation(0, "animation", true);
|
||
|
|
if (ConfigSystem.GetConfig<CommonModel>().PiggyBankSwitch == 1 && GameHelper.IsGiftSwitch())
|
||
|
|
{
|
||
|
|
if (GameHelper.GetLoginModel().new_player)
|
||
|
|
{
|
||
|
|
uiCtrlDispatcher.Dispatch(UICtrlMsg.SaveingPotUI_Open);
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
if (DateTime.Now.Day != PlayerPrefs.GetInt("pot_day", 0))
|
||
|
|
{
|
||
|
|
uiCtrlDispatcher.Dispatch(UICtrlMsg.SaveingPotUI_Open);
|
||
|
|
PlayerPrefs.SetInt("pot_day", DateTime.Now.Day);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
string jsonFilePath = Path.Combine(Application.persistentDataPath, "RainData1.json");
|
||
|
|
if (!File.Exists(jsonFilePath))
|
||
|
|
{
|
||
|
|
ui.btn_failpack.visible = false;
|
||
|
|
}
|
||
|
|
|
||
|
|
GameHelper.IsShowFirstReward();
|
||
|
|
|
||
|
|
GameHelper.IsShowPettyReward();
|
||
|
|
}
|
||
|
|
void UpdateEvent()
|
||
|
|
{
|
||
|
|
long t = SaveData.GetSaveobject().failed_pack_time;
|
||
|
|
|
||
|
|
if (SaveData.GetSaveobject().failed_pack_time > GameHelper.GetNowTime())
|
||
|
|
{
|
||
|
|
ui.btn_failpack.visible = true;
|
||
|
|
long time_ = t * 1000 - GameHelper.getNowTimeByMillisecond();
|
||
|
|
DateTime oldDate = new DateTime(1970, 1, 1);
|
||
|
|
oldDate = oldDate.AddMilliseconds(time_);
|
||
|
|
ui.btn_failpack.GetChild("lab_time").text = DateTimeManager.Instance.DateTimeToFFFString(oldDate);
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
ui.btn_failpack.visible = false;
|
||
|
|
HallManager.Instance.UpdateEvent -= UpdateEvent;
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
private void RefreshSaveingPot(object isShow = null)
|
||
|
|
{
|
||
|
|
(ui.btn_saveingpot as btn_saveingpot).text_nowcash.text = SaveingPotHelper.getCashString(SaveData.GetSaveobject().saveingpot_cash);
|
||
|
|
}
|
||
|
|
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++;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
return 1 - (float)surplus_item / (SaveData.GetSaveobject().all_card_numbers * 3);
|
||
|
|
|
||
|
|
}
|
||
|
|
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();
|
||
|
|
InitView();
|
||
|
|
}
|
||
|
|
|
||
|
|
#endregion
|
||
|
|
|
||
|
|
#region 消息
|
||
|
|
|
||
|
|
protected override void AddListener()
|
||
|
|
{
|
||
|
|
HallManager.Instance.AddChangeGiftSwitch(InitView);
|
||
|
|
GameDispatcher.Instance.AddListener(GameMsg.RefreshMakeupData, OnRefreshMakeupData);
|
||
|
|
|
||
|
|
PreferencesDispatcher<int>.Instance.AddListener(PreferencesMsg.playerAvatarId, UpdataAvatar);
|
||
|
|
PreferencesDispatcher<string>.Instance.AddListener(PreferencesMsg.playerName, OnChangeName);
|
||
|
|
GameDispatcher.Instance.AddListener(GameMsg.RefreshRedDot, RefreshRed);
|
||
|
|
GameDispatcher.Instance.AddListener(GameMsg.UpdateNoads, SetBtnAds);
|
||
|
|
GameDispatcher.Instance.AddListener(GameMsg.RefreshSaveingPot, RefreshSaveingPot);
|
||
|
|
}
|
||
|
|
|
||
|
|
protected override void RemoveListener()
|
||
|
|
{
|
||
|
|
HallManager.Instance.RemoveChangeGiftSwitch(InitView);
|
||
|
|
PreferencesDispatcher<int>.Instance.RemoveListener(PreferencesMsg.playerAvatarId, UpdataAvatar);
|
||
|
|
PreferencesDispatcher<string>.Instance.RemoveListener(PreferencesMsg.playerName, OnChangeName);
|
||
|
|
GameDispatcher.Instance.RemoveListener(GameMsg.RefreshRedDot, RefreshRed);
|
||
|
|
GameDispatcher.Instance.RemoveListener(GameMsg.RefreshMakeupData, OnRefreshMakeupData);
|
||
|
|
GameDispatcher.Instance.RemoveListener(GameMsg.UpdateNoads, SetBtnAds);
|
||
|
|
GameDispatcher.Instance.RemoveListener(GameMsg.RefreshSaveingPot, RefreshSaveingPot);
|
||
|
|
}
|
||
|
|
#endregion
|
||
|
|
private List<Paidcoins> Paidcoins_list = ConfigSystem.GetConfig<PaidcoinsModel>().dataList;
|
||
|
|
|
||
|
|
private int time_count = 11;
|
||
|
|
private FGUI.ZM_Common_01.com_broadcast_text1 text_ui;
|
||
|
|
|
||
|
|
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];
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
void setBtntask()
|
||
|
|
{
|
||
|
|
ui.btn_pass.number_text.text = "Lv." + GameHelper.GetBattleLv();
|
||
|
|
if (GameHelper.GetBattleLv() >= ConfigSystem.GetConfig<PassportrewardsModel>().dataList.Count)
|
||
|
|
{
|
||
|
|
ui.btn_pass.pass_pro.value = 100;
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
ui.btn_pass.pass_pro.value =
|
||
|
|
((float)GameHelper.GetGameExp() / ConfigSystem.GetConfig<PassportrewardsModel>().dataList[GameHelper.GetBattleLv()].Eliminating_quantity) * 100;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
private void UpBtnCoin()
|
||
|
|
{
|
||
|
|
int time = SaveData.GetSaveobject()._goldtime[0];
|
||
|
|
com_gold btn_gold = ui.btn_gold as com_gold;
|
||
|
|
if (time + Paidcoins_list[0].receive_CD < GameHelper.GetNowTime())
|
||
|
|
{
|
||
|
|
btn_gold.state.selectedIndex = 2;
|
||
|
|
}
|
||
|
|
else btn_gold.state.selectedIndex = 1;
|
||
|
|
checkThreeGift();
|
||
|
|
if (!GameHelper.IsGiftSwitch()) return;
|
||
|
|
|
||
|
|
// time_count++;
|
||
|
|
// if (time_count > 10)
|
||
|
|
// {
|
||
|
|
// ui.broadcast.visible = false;
|
||
|
|
// }
|
||
|
|
// if (time_count > 30)
|
||
|
|
// {
|
||
|
|
// time_count = 0;
|
||
|
|
// var name_index = Random.Range(0, ConfigSystem.GetConfig<exBrPoolModel>().config_name_list.Count);
|
||
|
|
// var money_index = Random.Range(0, ConfigSystem.GetConfig<exBrPoolModel>().config_money_list.Count);
|
||
|
|
|
||
|
|
// ui.broadcast.visible = true;
|
||
|
|
|
||
|
|
// if (text_ui == null) text_ui = ui.broadcast.GetChild("broad_cast_text") as com_broadcast_text1;
|
||
|
|
// text_ui.cast_text.text = String.Format(text_ui.show_text.text, ConfigSystem.GetConfig<exBrPoolModel>().config_name_list[name_index],
|
||
|
|
// ConfigSystem.GetConfig<exBrPoolModel>().config_money_list[money_index], DateTimeManager.Instance.GetCurrDateTime());
|
||
|
|
// text_ui.t0.Play(() => { ui.broadcast.visible = false; });
|
||
|
|
// }
|
||
|
|
RefreshSaveingPot();
|
||
|
|
}
|
||
|
|
|
||
|
|
private void getCoinReward(int reward)
|
||
|
|
{
|
||
|
|
var rewardData = new RewardData();
|
||
|
|
var start_pos = GameHelper.GetUICenterPosition(ui.btn_banma);
|
||
|
|
var end = GameHelper.GetUICenterPosition(ui.btn_gold.GetChild("icon"));
|
||
|
|
|
||
|
|
var rewardSingleData = new RewardSingleData(101, reward, RewardOrigin.AdTask)
|
||
|
|
{
|
||
|
|
startPosition = start_pos,
|
||
|
|
endPosition = new Vector2(end.x - 150, end.y - 136)
|
||
|
|
};
|
||
|
|
|
||
|
|
rewardData.AddReward(rewardSingleData);
|
||
|
|
rewardData.displayType = RewardDisplayType.RewardFly | RewardDisplayType.Dialog | RewardDisplayType.ValueChange;
|
||
|
|
rewardData.AddCompleted(success =>
|
||
|
|
{
|
||
|
|
if (success)
|
||
|
|
{
|
||
|
|
PlayerPrefs.SetInt($"coin_cd_times_{formattedDate}", limitTimes);
|
||
|
|
|
||
|
|
// var startNum = PreferencesMgr.Instance.Currency101 - reward;
|
||
|
|
|
||
|
|
// DOVirtual.Float((float)startNum, (float)GameHelper.GetGoldNumber(), 1f,
|
||
|
|
// value => { ui.btn_gold.GetChild("text_gold").text = ((int)value).ToString(); });
|
||
|
|
}
|
||
|
|
});
|
||
|
|
GameDispatcher.Instance.Dispatch(GameMsg.GetReward, rewardData);
|
||
|
|
}
|
||
|
|
|
||
|
|
void OnRefreshMakeupData(object obj)
|
||
|
|
{
|
||
|
|
SetMakeup();
|
||
|
|
}
|
||
|
|
|
||
|
|
private void InitData()
|
||
|
|
{
|
||
|
|
model.showCoin = PreferencesMgr.Instance.Currency101;
|
||
|
|
model.showDollar = PreferencesMgr.Instance.Currency102;
|
||
|
|
}
|
||
|
|
|
||
|
|
private Action closeCallback;
|
||
|
|
|
||
|
|
private void InitView()
|
||
|
|
{
|
||
|
|
|
||
|
|
Set101();
|
||
|
|
|
||
|
|
UpdataAvatar();
|
||
|
|
|
||
|
|
SetMakeup();
|
||
|
|
|
||
|
|
SetName(ui.text_name);
|
||
|
|
|
||
|
|
RefreshRed();
|
||
|
|
|
||
|
|
SetBtnAds();
|
||
|
|
|
||
|
|
ui.btn_play.SetClick(OnClickPlay);
|
||
|
|
|
||
|
|
ui.btn_wheel.SetClick(() => { OnClickLuckySpin(); });
|
||
|
|
ui.btn_sign.SetClick(() => { OnClickSign(); });
|
||
|
|
ui.btn_setting.SetClick(() => { OnClickSetting(); });
|
||
|
|
ui.btn_shop.SetClick(() => { OnClickShop(); });
|
||
|
|
ui.btn_banma.SetClick(() => { OnClickBanma(); });
|
||
|
|
ui.btn_banma.isCloseClickAnim = true;
|
||
|
|
|
||
|
|
// ui.btn_task_times.SetClick(() => { OnClickTask(false); });
|
||
|
|
|
||
|
|
//ui.broadcast.visible = GameHelper.IsGiftSwitch();
|
||
|
|
|
||
|
|
ui.btn_pass.SetClick(() => { OnClickPass(); });
|
||
|
|
if (GameHelper.IsGiftSwitch() || (ConfigSystem.GetConfig<CommonModel>().WVswitch == 1))
|
||
|
|
{
|
||
|
|
ui.btn_h5.visible = true;
|
||
|
|
}
|
||
|
|
ui.btn_h5.SetClick(() =>
|
||
|
|
{
|
||
|
|
uiCtrlDispatcher.Dispatch(UICtrlMsg.H5UI_Open);
|
||
|
|
});
|
||
|
|
|
||
|
|
WebviewManager.Instance.SetDarkThough(true);
|
||
|
|
|
||
|
|
btn_noads.SetClick(() =>
|
||
|
|
{
|
||
|
|
if (!SaveData.GetSaveobject().is_get_packreward && !SaveData.GetSaveobject().is_get_removead)
|
||
|
|
{
|
||
|
|
if (btn_noads.img_ad.visible)
|
||
|
|
{
|
||
|
|
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.PackrewardUI_Open, true);
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.PackrewardUI_Open);
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
else if (SaveData.GetSaveobject().is_get_packreward)
|
||
|
|
{
|
||
|
|
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.PackrewardUI_Open, true);
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.PackrewardUI_Open);
|
||
|
|
}
|
||
|
|
});
|
||
|
|
|
||
|
|
var btnCoin = ui.btn_gold as com_gold;
|
||
|
|
btnCoin.text_gold.text = $"{PreferencesMgr.Instance.Currency101:N0}";
|
||
|
|
btnCoin.SetClick(OnClickShop);
|
||
|
|
|
||
|
|
ui.btn_head.SetClick(() => { UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.PersonViewUI_Open); });
|
||
|
|
UpdataAvatar();
|
||
|
|
|
||
|
|
ad_times = PlayerPrefs.GetInt("main_ad_times", 0);
|
||
|
|
ad_numbers = PlayerPrefs.GetInt("main_ad_numbers", 1);
|
||
|
|
|
||
|
|
if (HallManager.Instance.enterHallTimes == 1)
|
||
|
|
{
|
||
|
|
reCreatPur();
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
if (!GameHelper.IsGiftSwitch())
|
||
|
|
{
|
||
|
|
WebviewManager.Instance.SetDarkThough(false);
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
ui.state.selectedIndex = GameHelper.IsGiftSwitch() ? 1 : 0;
|
||
|
|
ui.btn_three_day.SetClick(() =>
|
||
|
|
{
|
||
|
|
uiCtrlDispatcher.Dispatch(UICtrlMsg.ThreeDaysGiftUI_Open);
|
||
|
|
});
|
||
|
|
|
||
|
|
ui.btn_petty.visible = GameHelper.IsGiftSwitch();
|
||
|
|
ui.btn_petty.SetClick((() =>
|
||
|
|
{
|
||
|
|
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.PettyAwardUI_Open);
|
||
|
|
}));
|
||
|
|
|
||
|
|
}
|
||
|
|
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;
|
||
|
|
}
|
||
|
|
else if (SaveData.GetSaveobject().is_get_packreward)
|
||
|
|
{
|
||
|
|
btn_noads.t0.Stop();
|
||
|
|
btn_noads.t1.Play();
|
||
|
|
//btn_noads.state.selectedIndex = 0;
|
||
|
|
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;
|
||
|
|
//btn_noads.state.selectedIndex = 1;
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
void SetMakeup(object a = null)
|
||
|
|
{
|
||
|
|
var money = ui.com_money as com_money;
|
||
|
|
money.number_text.text = GameHelper.Get102Str();
|
||
|
|
|
||
|
|
DOVirtual.Float(0, (float)PreferencesMgr.Instance.Currency102, 1,
|
||
|
|
value => { money.number_text.text = $"{GameHelper.Get102Str((decimal)value)}"; });
|
||
|
|
|
||
|
|
if (GameHelper.IsGiftSwitch())
|
||
|
|
{
|
||
|
|
if (PreferencesMgr.Instance.MakeupTaskHistory.Count == 0)
|
||
|
|
{
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
var makeupTaskData = PreferencesMgr.Instance.MakeupTaskHistory.Last();
|
||
|
|
var vo = ConfigSystem.GetConfig<MakeupModel>().dataList
|
||
|
|
.FirstOrDefault(redeem => redeem.id == makeupTaskData.tableId);
|
||
|
|
if (vo == null)
|
||
|
|
{
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
money.btn_cash.SetClick(() =>
|
||
|
|
{
|
||
|
|
uiCtrlDispatcher.Dispatch(UICtrlMsg.MakeupConfirmUI_Open, makeupTaskData);
|
||
|
|
});
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
private void OnClickBanma()
|
||
|
|
{
|
||
|
|
if (anim_banma != null)
|
||
|
|
{
|
||
|
|
if (AudioManager.Instance.IsOpenEffect)
|
||
|
|
{
|
||
|
|
AudioManager.Instance.PlayDynamicEffect(AudioConst.banma);
|
||
|
|
}
|
||
|
|
|
||
|
|
anim_banma.state.SetAnimation(0, "animation2", false);
|
||
|
|
anim_banma.state.Complete += (a) =>
|
||
|
|
{
|
||
|
|
anim_banma.state.SetAnimation(0, "animation", true);
|
||
|
|
};
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
private void RefreshRed(object isShow = null)
|
||
|
|
{
|
||
|
|
ui.btn_pass.red.visible = SaveData.battlepassred();
|
||
|
|
// ui.btn_task_times.red.visible = SaveData.timetaskred() || SaveData.passtaskred() || SaveData.AdTaskred();
|
||
|
|
|
||
|
|
}
|
||
|
|
private void OnClickLuckySpin()
|
||
|
|
{
|
||
|
|
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.WheelUI_Open);
|
||
|
|
}
|
||
|
|
|
||
|
|
private void OnClickTask(bool isLevel)
|
||
|
|
{
|
||
|
|
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.NewTaskUI_Open, isLevel);
|
||
|
|
}
|
||
|
|
private void OnClickSign()
|
||
|
|
{
|
||
|
|
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.SignInUI_Open);
|
||
|
|
}
|
||
|
|
private void OnClickShop()
|
||
|
|
{
|
||
|
|
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.BuygoldUI_Open, false);
|
||
|
|
}
|
||
|
|
private void OnClickSetting()
|
||
|
|
{
|
||
|
|
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.MenuUI_Open);
|
||
|
|
}
|
||
|
|
private void OnClickPass()
|
||
|
|
{
|
||
|
|
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.PassViewUI_Open);
|
||
|
|
}
|
||
|
|
|
||
|
|
private void OnClickPlay()
|
||
|
|
{
|
||
|
|
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;
|
||
|
|
Set102(model.showDollar);
|
||
|
|
|
||
|
|
}
|
||
|
|
}
|
||
|
|
private void UpdataAvatar(object obj = null)
|
||
|
|
{
|
||
|
|
var head = ui.btn_head as btn_head;
|
||
|
|
GameHelper.SetSelfAvatar(head.load_avatar);
|
||
|
|
}
|
||
|
|
|
||
|
|
public void Set101(decimal coin = -1)
|
||
|
|
{
|
||
|
|
if (coin < 0)
|
||
|
|
{
|
||
|
|
coin = PreferencesMgr.Instance.Currency101;
|
||
|
|
}
|
||
|
|
|
||
|
|
var btnCoin = ui.btn_gold as com_gold;
|
||
|
|
btnCoin.text_gold.text = $"{coin:N0}";
|
||
|
|
}
|
||
|
|
|
||
|
|
public void Set102(decimal money = -1)
|
||
|
|
{
|
||
|
|
if (money < 0)
|
||
|
|
{
|
||
|
|
money = PreferencesMgr.Instance.Currency102;
|
||
|
|
}
|
||
|
|
|
||
|
|
var btnCoin = ui.com_money as com_money;
|
||
|
|
btnCoin.number_text.text = $"{money:N}";
|
||
|
|
}
|
||
|
|
private void OnChangeName(ChangeValue<string> obj)
|
||
|
|
{
|
||
|
|
GameHelper.SetName(ui.text_name);
|
||
|
|
}
|
||
|
|
|
||
|
|
private void SetName(GTextField gTextField)
|
||
|
|
{
|
||
|
|
GameHelper.SetName(gTextField);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|