106 lines
3.4 KiB
C#
106 lines
3.4 KiB
C#
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using GCGame.Table;
|
|||
|
using UnityEngine;
|
|||
|
using UnityEngine.UI;
|
|||
|
using System.Collections;
|
|||
|
using Games.Events;
|
|||
|
|
|||
|
public class VipInfo : MonoBehaviour
|
|||
|
{
|
|||
|
|
|||
|
public static VipInfo Instance;
|
|||
|
public Text RechargeTip;
|
|||
|
public RectTransform SliderBack;
|
|||
|
public RectTransform SliderFill;
|
|||
|
public GameObject OpenVipBtn;
|
|||
|
public GameObject OpenChargeBtn;
|
|||
|
|
|||
|
public GameObject _SliverVipBG;
|
|||
|
public GameObject _GlodenVipBG;
|
|||
|
public List<Sprite> _ViplevelSpriteList;
|
|||
|
public Image _VipLevelIcon;
|
|||
|
|
|||
|
void Awake()
|
|||
|
{
|
|||
|
Instance = this;
|
|||
|
Hashtable calbackMoveparam1 = new Hashtable();
|
|||
|
calbackMoveparam1["name"] = "VipInfo";
|
|||
|
MessageEventCallBack fun1 = ReFresh;
|
|||
|
calbackMoveparam1.Add("callFun", fun1);
|
|||
|
Games.Events.EventDispatcher.Instance.AddMessageEvent(Games.Events.EventId.VIPReWardState, calbackMoveparam1);
|
|||
|
}
|
|||
|
|
|||
|
void OnDestroy()
|
|||
|
{
|
|||
|
Instance = null;
|
|||
|
Games.Events.EventDispatcher.Instance.RemoveMessage(Games.Events.EventId.VIPReWardState, "VipInfo");
|
|||
|
}
|
|||
|
|
|||
|
public void ReFresh(Hashtable add, Hashtable send)
|
|||
|
{
|
|||
|
OnEnable();
|
|||
|
}
|
|||
|
|
|||
|
void OnEnable()
|
|||
|
{
|
|||
|
ChargeInfo(Singleton<ObjManager>.Instance.MainPlayer.VipCost);
|
|||
|
ShowYBPanel();
|
|||
|
}
|
|||
|
|
|||
|
public void ShowYBPanel()
|
|||
|
{
|
|||
|
Click_Charge();
|
|||
|
}
|
|||
|
|
|||
|
void ChargeInfo(int vipLevel)
|
|||
|
{
|
|||
|
_SliverVipBG.SetActive(vipLevel <= 8);
|
|||
|
_GlodenVipBG.SetActive(vipLevel > 8);
|
|||
|
_VipLevelIcon.overrideSprite = _ViplevelSpriteList[vipLevel];
|
|||
|
|
|||
|
var MaxLevel = TableManager.GetVipBook().Count - 1; //0开始
|
|||
|
|
|||
|
if(vipLevel >= MaxLevel)
|
|||
|
{
|
|||
|
SliderFill.sizeDelta = new Vector2(SliderBack.sizeDelta.x, SliderBack.sizeDelta.y);
|
|||
|
RechargeTip.text = StrDictionary.GetClientDictionaryString("#{40999}");
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
Tab_VipBook nextVipLevelBook = TableManager.GetVipBookByID(vipLevel + 1, 0);
|
|||
|
if (nextVipLevelBook == null)
|
|||
|
{
|
|||
|
SliderFill.sizeDelta = new Vector2(SliderBack.sizeDelta.x, SliderBack.sizeDelta.y);
|
|||
|
RechargeTip.text = StrDictionary.GetClientDictionaryString("#{40999}");
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
var len = Mathf.Clamp(GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.PayCount * 1.0f / (nextVipLevelBook.NeedPay * 1.0f), 0, 1);
|
|||
|
SliderFill.sizeDelta = new Vector2(SliderBack.sizeDelta.x * len, SliderBack.sizeDelta.y);
|
|||
|
RechargeTip.text = StrDictionary.GetClientDictionaryString("#{67000}",
|
|||
|
GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.PayCount,
|
|||
|
nextVipLevelBook.NeedPay - GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.PayCount, vipLevel + 1);
|
|||
|
}
|
|||
|
|
|||
|
public void Click_Charge()
|
|||
|
{
|
|||
|
_RechaegrBtn.SetActive(false);
|
|||
|
_PrivilegeBtn.SetActive(true);
|
|||
|
_PrivilegeVipPanel.SetActive(false);
|
|||
|
_RechargePanel.SetActive(true);
|
|||
|
//YuanBaoShopLogic.OpenChargePage();
|
|||
|
}
|
|||
|
|
|||
|
public GameObject _RechargePanel; //充值页面
|
|||
|
public GameObject _PrivilegeVipPanel; //VIP页面
|
|||
|
public GameObject _RechaegrBtn;
|
|||
|
public GameObject _PrivilegeBtn;
|
|||
|
public void Click_OpenVIPRoot()
|
|||
|
{
|
|||
|
_RechaegrBtn.SetActive(true);
|
|||
|
_PrivilegeBtn.SetActive(false);
|
|||
|
_PrivilegeVipPanel.SetActive(true);
|
|||
|
_RechargePanel.SetActive(false);
|
|||
|
}
|
|||
|
}
|