备份CatanBuilding瘦身独立工程
This commit is contained in:
123
Assets/Scripts/UI/Setting/EventSignupPopupPanel.cs
Normal file
123
Assets/Scripts/UI/Setting/EventSignupPopupPanel.cs
Normal file
@@ -0,0 +1,123 @@
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using GameCore;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UniRx;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class EventSignupPopupPanel : BasePanel
|
||||
{
|
||||
List<SignupDayItem> signupDayItems = new List<SignupDayItem>();
|
||||
TMP_Text text_num;
|
||||
SigninData signupData;
|
||||
Button btn_close;
|
||||
TMP_Text text_time;
|
||||
Tables tables;
|
||||
int Multiplier;
|
||||
List<int> signDayList;
|
||||
private TimeSpan remaining;
|
||||
|
||||
GameObject rewardPanel;
|
||||
Button reward_button;
|
||||
private void Awake()
|
||||
{
|
||||
tables = GContext.container.Resolve<Tables>();
|
||||
signupData = GContext.container.Resolve<SigninData>();
|
||||
for (int i = 1; i < 8; i++)
|
||||
{
|
||||
signupDayItems.Add(transform.Find("root/day" + i).GetComponent<SignupDayItem>());
|
||||
}
|
||||
text_num = transform.Find("root/day7/text_num_new").GetComponent<TMP_Text>();
|
||||
btn_close = transform.Find("btn_close").GetComponent<Button>();
|
||||
text_time = transform.Find("root/text_time").GetComponent<TMP_Text>();
|
||||
|
||||
rewardPanel = transform.Find("reward").gameObject;
|
||||
reward_button = transform.Find("reward/btn_play/btn_green").GetComponent<Button>();
|
||||
}
|
||||
protected override void Start()
|
||||
{
|
||||
Multiplier = 1;
|
||||
oldPanelName = panelName;
|
||||
base.Start();
|
||||
btn_close.onClick.AddListener(OnClose);
|
||||
ShowRewardPanel();
|
||||
var dailySignEvent = signupData.newSignEvent;
|
||||
SignInit signInit = tables.TbSignInit.GetOrDefault(dailySignEvent.ID);
|
||||
signDayList = signInit.SignDayList;
|
||||
for (int i = 0; i < signDayList.Count; i++)
|
||||
{
|
||||
SignReward dailySign = tables.TbSignReward.GetOrDefault(signDayList[i]);
|
||||
if (i < dailySignEvent.index && i < signDayList.Count - 1)
|
||||
{
|
||||
Multiplier += dailySign.Multiplier;
|
||||
}
|
||||
if (dailySign != null)
|
||||
{
|
||||
int DropID = dailySign.DropID;
|
||||
signupDayItems[i].ShowData(i, DropID, dailySignEvent.ID, Multiplier);
|
||||
}
|
||||
}
|
||||
text_num.text = $"x{Multiplier}";
|
||||
GContext.OnEvent<OnSignEvent>().Subscribe(OnSignEvent).AddTo(disposables);
|
||||
DateTime now = ZZTimeHelper.UtcNow().UtcNowOffset();
|
||||
DateTime tomorrow = GlobalUtils.TryParseDateTime(signupData.newSignEvent.time, now);
|
||||
remaining = tomorrow - now;
|
||||
text_time.text = ConvertTools.ConvertTime2(remaining.Days, remaining.Hours, remaining.Minutes, remaining.Seconds);
|
||||
StartCoroutine(Countdown());
|
||||
reward_button.onClick.AddListener(OnClickReward);
|
||||
}
|
||||
IEnumerator Countdown()
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
yield return new WaitForSeconds(1);
|
||||
remaining = remaining.Subtract(TimeSpan.FromSeconds(1));
|
||||
text_time.text = ConvertTools.ConvertTime2(remaining.Days, remaining.Hours, remaining.Minutes, remaining.Seconds);
|
||||
if (remaining.TotalSeconds <= 0)
|
||||
{
|
||||
OnClose();
|
||||
yield break;
|
||||
}
|
||||
}
|
||||
}
|
||||
void OnSignEvent(OnSignEvent onSignEvent)
|
||||
{
|
||||
Multiplier = 1;
|
||||
var dailySignEvent = signupData.newSignEvent;
|
||||
for (int i = 0; i < dailySignEvent.index; i++)
|
||||
{
|
||||
SignReward dailySign = tables.TbSignReward.GetOrDefault(signDayList[i]);
|
||||
if (i < signDayList.Count - 1)
|
||||
{
|
||||
Multiplier += dailySign.Multiplier;
|
||||
}
|
||||
}
|
||||
text_num.text = $"x{Multiplier}";
|
||||
ShowRewardPanel();
|
||||
signupDayItems[6].SetMultiplier(Multiplier);
|
||||
}
|
||||
void ShowRewardPanel()
|
||||
{
|
||||
var dailySignEvent = signupData.newSignEvent;
|
||||
rewardPanel.SetActive(dailySignEvent.lastID != ZZTimeHelper.UtcNow().UtcNowOffset().DayOfYear && dailySignEvent.index < 7);
|
||||
}
|
||||
void OnClickReward()
|
||||
{
|
||||
if (signupData.newSignEvent.index < signupDayItems.Count)
|
||||
{
|
||||
signupDayItems[signupData.newSignEvent.index].OnClaimBtnClick();
|
||||
}
|
||||
}
|
||||
void OnClose()
|
||||
{
|
||||
UIManager.Instance.DestroyUI(UITypes.EventSignupPopupPanel);
|
||||
}
|
||||
//private void OnDisable()
|
||||
//{
|
||||
// //GContext.container.Resolve<IFaceUIService>().ShowFaceUI();
|
||||
//}
|
||||
}
|
||||
Reference in New Issue
Block a user