168 lines
5.0 KiB
C#
168 lines
5.0 KiB
C#
using System.Collections;
|
||
using System.Collections.Generic;
|
||
using UnityEngine;
|
||
using UnityEngine.UI;
|
||
using System;
|
||
using GCGame.Table;
|
||
|
||
// 充值返利/消费返利
|
||
public class RechargeOrConsumeRebateCS : OpenServiceAccumulateRechargeCS {
|
||
|
||
public UIBackRayBehind behindMask;
|
||
public Button closeBtn;
|
||
public Image bg;
|
||
public Image title;
|
||
public int beforeActId; // root和页面结合在一个页面显示
|
||
|
||
public string bgName = "";
|
||
public string bannerName = "";
|
||
public string titleName = "";
|
||
|
||
public Text remainTime; // 剩余时间
|
||
|
||
private int remainS; // 剩余秒
|
||
private int remainM; // 剩余分
|
||
private int remainH; // 剩余时
|
||
private int remainD; // 剩余天
|
||
|
||
private void Awake()
|
||
{
|
||
if(behindMask != null)
|
||
{
|
||
behindMask._BackClick.AddListener(Close);
|
||
}
|
||
|
||
if(closeBtn != null)
|
||
{
|
||
closeBtn.onClick.AddListener(Close);
|
||
}
|
||
}
|
||
|
||
protected override void OnEnable()
|
||
{
|
||
AskForMenuID();
|
||
}
|
||
|
||
public void Close()
|
||
{
|
||
this.gameObject.SetActive(false);
|
||
}
|
||
|
||
private void OnDisable()
|
||
{
|
||
if (MarketingActsRoot.Instance() != null)
|
||
{
|
||
MarketingActsRoot.Instance().ClearShowingWin(_ActID);
|
||
MarketingActsRoot.Instance().ClearShowingWin(beforeActId);
|
||
}
|
||
}
|
||
|
||
// 增加控制Title,BGs的控制
|
||
protected override void InitBG()
|
||
{
|
||
if(bg != null && string.IsNullOrEmpty(bgName))
|
||
{
|
||
LoadAssetBundle.Instance.SetImageSprite(bg, bgName);
|
||
}
|
||
|
||
if (banner != null && string.IsNullOrEmpty(bannerName))
|
||
{
|
||
LoadAssetBundle.Instance.SetImageSprite(banner, bannerName);
|
||
}
|
||
|
||
if (title != null && string.IsNullOrEmpty(titleName))
|
||
{
|
||
LoadAssetBundle.Instance.SetImageSprite(title, titleName);
|
||
}
|
||
}
|
||
|
||
// 显示奖品
|
||
protected override void InitAwardItem(List<MarketingActAwardTag> datas)
|
||
{
|
||
if(awardContainer != null)
|
||
{
|
||
UIContainerSelect container = awardContainer as UIContainerSelect;
|
||
if(container != null)
|
||
{
|
||
//List<MarketingActAwardTag> selecteds = new List<MarketingActAwardTag>();
|
||
//selecteds.Add(datas[0]);
|
||
container.InitSelectContent(datas, null);
|
||
}
|
||
}
|
||
}
|
||
|
||
#region 请求与接收
|
||
|
||
// 菜单请求
|
||
private void AskForMenuID()
|
||
{
|
||
MarketingActsReq req = new MarketingActsReq();
|
||
req.actType = this._ActID;
|
||
|
||
req.SendMsg();
|
||
}
|
||
|
||
// root菜单接收
|
||
protected override void MarketingActRetInner(MarketingActsRet marketActsRet)
|
||
{
|
||
if(marketActsRet != null && marketActsRet.actIDState.Count > 0)
|
||
{
|
||
beforeActId = this._ActID;
|
||
MarketingActState tempActState = new MarketingActState();
|
||
tempActState.actID = marketActsRet.actIDState[0].actID;
|
||
Hashtable param = new Hashtable();
|
||
param.Add("ActState", tempActState);
|
||
|
||
if(MarketingActsRoot.Instance() != null)
|
||
{
|
||
MarketingActsRoot.Instance().LoadUICallBack(true, param, gameObject);
|
||
}
|
||
|
||
AskForInfo();
|
||
}
|
||
}
|
||
|
||
// 页面信息请求
|
||
protected override void AskForInfo()
|
||
{
|
||
MarketingActAwardPageReq req = new MarketingActAwardPageReq();
|
||
req.actID = this._ActID;
|
||
req.updateOrInit = 1;
|
||
|
||
req.SendMsg();
|
||
}
|
||
|
||
//// 页面信息接收
|
||
//public override void MarketingActAwardPageRet(MarketingActAwardPageRet packet)
|
||
//{
|
||
// LogModule.DebugLog(this.gameObject.name + " : Recieve message.");
|
||
// InitDesc(packet.descList);
|
||
// InitAwardItem(packet.awardTags);
|
||
//}
|
||
|
||
#endregion
|
||
|
||
// 倒计时
|
||
private IEnumerator ShowTime()
|
||
{
|
||
TimeSpan startRemain = new TimeSpan(remainD, remainH, remainM, remainS);
|
||
TimeSpan reaminSpan = startRemain;
|
||
float startTime = Time.realtimeSinceStartup;
|
||
while (true)
|
||
{
|
||
remainTime.text =
|
||
reaminSpan.Days.ToString().PadLeft(2, '0') + StrDictionary.GetClientDictionaryString("#{9906}") +
|
||
reaminSpan.Hours.ToString().PadLeft(2, '0') + StrDictionary.GetClientDictionaryString("#{9903}") +
|
||
reaminSpan.Minutes.ToString().PadLeft(2, '0') + StrDictionary.GetClientDictionaryString("#{9904}") +
|
||
reaminSpan.Seconds.ToString().PadLeft(2, '0') + StrDictionary.GetClientDictionaryString("#{9905}");
|
||
|
||
for (float t = 0.0f; t < 1.0f; t += Time.deltaTime)
|
||
{
|
||
yield return null;
|
||
}
|
||
|
||
reaminSpan = startRemain - new TimeSpan((long)(Time.realtimeSinceStartup - startTime) * TimeSpan.TicksPerSecond);
|
||
}
|
||
}
|
||
}
|