备份CatanBuilding瘦身独立工程
This commit is contained in:
131
Assets/Scripts/UI/Setting/SignupDayItem.cs
Normal file
131
Assets/Scripts/UI/Setting/SignupDayItem.cs
Normal file
@@ -0,0 +1,131 @@
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using GameCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class SignupDayItem : MonoBehaviour
|
||||
{
|
||||
GameObject received;
|
||||
GameObject bg;
|
||||
GameObject claim_notice;
|
||||
GameObject bg_today;
|
||||
Button claim_btn;
|
||||
Animation ani;
|
||||
[NonSerialized]
|
||||
public Animation icon_done;
|
||||
RewardItemNew[] rewardItems;
|
||||
int index;
|
||||
SigninData signupData;
|
||||
Tables tables;
|
||||
List<ItemData> itemDatas;
|
||||
int ID;
|
||||
int DropID;
|
||||
private void Awake()
|
||||
{
|
||||
received = transform.Find("received").gameObject;
|
||||
bg = transform.Find("bg").gameObject;
|
||||
claim_notice = transform.Find("claim_notice").gameObject;
|
||||
bg_today = transform.Find("bg_today").gameObject;
|
||||
claim_btn = GetComponent<Button>();
|
||||
ani = GetComponent<Animation>();
|
||||
icon_done = transform.Find("received/icon_done").GetComponent<Animation>();
|
||||
rewardItems = transform.GetComponentsInChildren<RewardItemNew>();
|
||||
signupData = GContext.container.Resolve<SigninData>();
|
||||
tables = GContext.container.Resolve<Tables>();
|
||||
}
|
||||
private void Start()
|
||||
{
|
||||
claim_btn.onClick.AddListener(OnClaimBtnClick);
|
||||
}
|
||||
public void ShowData(int index, int DropID, int ID, int Multiplier = 1)
|
||||
{
|
||||
this.index = index;
|
||||
this.ID = ID;
|
||||
this.DropID = DropID;
|
||||
DailySignEvent dailySignEvent;
|
||||
itemDatas = GContext.container.Resolve<PlayerItemData>().GetItemDataByDropId(DropID);
|
||||
if (ID > 0)
|
||||
{
|
||||
dailySignEvent = signupData.newSignEvent;
|
||||
if (index == 6 && Multiplier > 1)
|
||||
{
|
||||
for (int i = 0; i < itemDatas.Count; i++)
|
||||
{
|
||||
itemDatas[i].count *= Multiplier;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dailySignEvent = signupData.dailySignEvent;
|
||||
}
|
||||
received.SetActive(index < dailySignEvent.index);
|
||||
int count = Math.Min(itemDatas.Count, rewardItems.Length);
|
||||
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
rewardItems[i].SetData(itemDatas[i]);
|
||||
}
|
||||
for (int i = 0; i < rewardItems.Length; i++)
|
||||
{
|
||||
rewardItems[i].gameObject.SetActive(i < count);
|
||||
rewardItems[i].SetReceived(index < dailySignEvent.index);
|
||||
}
|
||||
if (dailySignEvent.lastID != ZZTimeHelper.UtcNow().UtcNowOffset().DayOfYear)
|
||||
{
|
||||
bg.SetActive(dailySignEvent.index != index);
|
||||
bg_today.SetActive(dailySignEvent.index == index);
|
||||
if (dailySignEvent.index == index)
|
||||
ani.Play();
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
bg.SetActive(dailySignEvent.index - 1 != index);
|
||||
bg_today.SetActive(dailySignEvent.index - 1 == index);
|
||||
}
|
||||
claim_notice.SetActive(dailySignEvent.index == index && dailySignEvent.lastID != ZZTimeHelper.UtcNow().UtcNowOffset().DayOfYear);
|
||||
}
|
||||
public void SetMultiplier(int Multiplier)
|
||||
{
|
||||
itemDatas = GContext.container.Resolve<PlayerItemData>().GetItemDataByDropId(DropID);
|
||||
for (int i = 0; i < itemDatas.Count; i++)
|
||||
{
|
||||
itemDatas[i].count *= Multiplier;
|
||||
}
|
||||
int count = Math.Min(itemDatas.Count, rewardItems.Length);
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
rewardItems[i].SetData(itemDatas[i]);
|
||||
}
|
||||
}
|
||||
public void OnClaimBtnClick()
|
||||
{
|
||||
claim_btn.enabled = false;
|
||||
bool isSign;
|
||||
if (ID > 0)
|
||||
{
|
||||
isSign = signupData.OnSpecialSign(ID, index, DropID);
|
||||
}
|
||||
else
|
||||
{
|
||||
isSign = signupData.OnDailySign(index, DropID);
|
||||
}
|
||||
if (isSign)
|
||||
{
|
||||
received.SetActive(true);
|
||||
icon_done.Play();
|
||||
ani.Stop();
|
||||
claim_notice.SetActive(false);
|
||||
for (int i = 0; i < rewardItems.Length; i++)
|
||||
{
|
||||
rewardItems[i].SetReceived(true);
|
||||
rewardItems[i].ParticleAttractor();
|
||||
}
|
||||
}
|
||||
claim_btn.enabled = true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user