194 lines
4.7 KiB
C#
194 lines
4.7 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using GCGame.Table;
|
|
using UnityEngine.UI;
|
|
using Module.Log;
|
|
using System;
|
|
using GCGame;
|
|
|
|
public class BuyDailyCopyTimePanelCtr : MonoBehaviour {
|
|
|
|
private static BuyDailyCopyTimePanelCtr instance;
|
|
public static BuyDailyCopyTimePanelCtr Instance
|
|
{
|
|
get
|
|
{
|
|
return instance;
|
|
}
|
|
}
|
|
|
|
public UIBackRayBehind bgMask;
|
|
public Text title;
|
|
public Button comfirmBtn;
|
|
public Button cancelBtn;
|
|
public Text remainBuyTime;
|
|
public UIImgText vipNum;
|
|
public Image bg;
|
|
|
|
private int copyID;
|
|
public int CopyID
|
|
{
|
|
get
|
|
{
|
|
return copyID;
|
|
}
|
|
set
|
|
{
|
|
copyID = value;
|
|
}
|
|
}
|
|
|
|
private int hasBuyTime;
|
|
private List<Tab_DailyCopyBuy> buyTabs = new List<Tab_DailyCopyBuy>();
|
|
|
|
public static void Show(int copyID, int hasBuyTime)
|
|
{
|
|
Hashtable param = new Hashtable();
|
|
param["copyID"] = copyID;
|
|
param["hasBuyTime"] = hasBuyTime;
|
|
|
|
UIManager.ShowUI(UIInfo.BuyDailyCopyPanel,
|
|
(bool isSuccess, object p) =>
|
|
{
|
|
Hashtable tempHash = p as Hashtable;
|
|
int tempCopyID = (int)tempHash["copyID"];
|
|
int tempHasBuyTime = (int)tempHash["hasBuyTime"];
|
|
if (isSuccess && BuyDailyCopyTimePanelCtr.Instance != null)
|
|
{
|
|
BuyDailyCopyTimePanelCtr.Instance.ShowByID(tempCopyID, tempHasBuyTime);
|
|
}
|
|
else
|
|
{
|
|
LogModule.ErrorLog("Can't show BuyDailyCopyPanel");
|
|
}
|
|
}, param);
|
|
}
|
|
|
|
private void Awake()
|
|
{
|
|
if (instance == null)
|
|
{
|
|
instance = this;
|
|
}
|
|
|
|
comfirmBtn.onClick.AddListener(OnConfirmBtnClick);
|
|
bgMask._BackClick.AddListener(OnCancelBtnClick);
|
|
cancelBtn.onClick.AddListener(OnCancelBtnClick);
|
|
}
|
|
|
|
private void OnDestroy()
|
|
{
|
|
if (instance != null)
|
|
{
|
|
instance = null;
|
|
}
|
|
}
|
|
|
|
public void ShowByID(int copyID, int hasBuyTime)
|
|
{
|
|
this.copyID = copyID;
|
|
this.hasBuyTime = hasBuyTime;
|
|
|
|
// 特权枚举
|
|
int privilegeID = -1;
|
|
// 需要金钱
|
|
|
|
GetByTimeTabs();
|
|
|
|
if (buyTabs.Count > 0)
|
|
{
|
|
privilegeID = buyTabs[0].PrivilegeVipTypeEnum;
|
|
}
|
|
else
|
|
{
|
|
LogModule.ErrorLog("Cant't get privilegeID in Tab_DailyCopyBuy");
|
|
return;
|
|
}
|
|
|
|
var privilegeFuncTabs = TableManager.GetPrivilegeFunction();
|
|
Tab_PrivilegeFunction timeTab = null;
|
|
foreach (var item in privilegeFuncTabs)
|
|
{
|
|
if (item.Value.PrivilegeId == privilegeID)
|
|
{
|
|
timeTab = item.Value;
|
|
break;
|
|
}
|
|
}
|
|
|
|
Tab_DailyCopyBuy buyTab = null;
|
|
for(int i = 0; i < buyTabs.Count; ++i)
|
|
{
|
|
if (buyTabs[i].BuyTime >= (hasBuyTime + 1))
|
|
{
|
|
buyTab = buyTabs[i];
|
|
break;
|
|
}
|
|
}
|
|
|
|
int remainCanBuy = 0;
|
|
if (timeTab != null)
|
|
{
|
|
remainCanBuy = Convert.ToInt32(timeTab.GetVipbyIndex(GameManager.gameManager.PlayerDataPool.VipCost)) - hasBuyTime;
|
|
}
|
|
|
|
remainBuyTime.text = StrDictionary.GetClientDictionaryString("#{51902}", remainCanBuy.ToString());
|
|
|
|
string moneyDesc = buyTab.MoneyNum.ToString() + Utils.GetMoneyName(buyTab.MoneyType);
|
|
|
|
title.text = StrDictionary.GetClientDictionaryString("#{51900}", moneyDesc);
|
|
vipNum.text = GameManager.gameManager.PlayerDataPool.VipCost.ToString();
|
|
}
|
|
|
|
public void UpdateBuyTime(int id, int hasBuyTime)
|
|
{
|
|
if (id == copyID)
|
|
{
|
|
ShowByID(id, hasBuyTime);
|
|
}
|
|
}
|
|
|
|
public void OnCancelBtnClick()
|
|
{
|
|
UIManager.CloseUI(UIInfo.BuyDailyCopyPanel);
|
|
}
|
|
|
|
public void OnConfirmBtnClick()
|
|
{
|
|
ReqBuyCopyTime req = new ReqBuyCopyTime();
|
|
req.copyid = copyID;
|
|
|
|
req.SendMsg();
|
|
}
|
|
|
|
private void GetByTimeTabs()
|
|
{
|
|
var allTabs = TableManager.GetDailyCopyBuy();
|
|
foreach (var item in allTabs)
|
|
{
|
|
if (item.Value.CopyId == copyID)
|
|
{
|
|
buyTabs.Add(item.Value);
|
|
}
|
|
}
|
|
|
|
buyTabs.Sort(
|
|
(Tab_DailyCopyBuy l, Tab_DailyCopyBuy r) =>
|
|
{
|
|
if (l.Id < r.Id)
|
|
{
|
|
return -1;
|
|
}
|
|
else if (l.Id > r.Id)
|
|
{
|
|
return 1;
|
|
}
|
|
else
|
|
{
|
|
return 0;
|
|
}
|
|
});
|
|
}
|
|
}
|