Files
JJBB/Assets/Project/Script/GUI/Community/CommunityPresentLogic.cs

85 lines
2.0 KiB
C#
Raw Normal View History

2024-08-23 15:49:34 +08:00
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
using Games.Item;
using System.Collections.Generic;
using GCGame.Table;
using Games.GlobeDefine;
public class CommunityPresentLogic : UIControllerBase<CommunityPresentLogic>
{
void OnEnable ()
{
SetInstance(this);
InitPresent();
}
void OnDisable()
{
SetInstance(null);
}
public void ShowWindow()
{
gameObject.SetActive(true);
}
public void CloseWindow()
{
gameObject.SetActive(false);
}
#region
public int PresentPrice = 2000;
public UINumBoardInput _PresentCnt;
public UICurrencyItem _TotalPrice;
public UICurrencyItem _OwnPrice;
public void InitPresent()
{
var weiBoTable = TableManager.GetWeiboByID(0, 0);
PresentPrice = weiBoTable.GiftConsumeNum;
_PresentCnt.Init(1, 1, 999);
OnPresentCntChange();
}
public void OnPresentCntChange()
{
int presentCnt = _PresentCnt.Value;
if (GameManager.gameManager.PlayerDataPool.GetLongPropty((int)CONSUM_TYPE.MONEY, (int)MONEYTYPE.MONEYTYPE_COIN_BIND) == 0)
{
_TotalPrice.ShowCurrency(MONEYTYPE.MONEYTYPE_COIN, presentCnt * PresentPrice);
_OwnPrice.ShowOwnCurrency(MONEYTYPE.MONEYTYPE_COIN);
}
else
{
_TotalPrice.ShowCurrency(MONEYTYPE.MONEYTYPE_COIN_BIND, presentCnt * PresentPrice);
_OwnPrice.ShowOwnCurrency(MONEYTYPE.MONEYTYPE_COIN_BIND);
}
}
public void OnSetPresent()
{
var weiBoTable = TableManager.GetWeiboByID(0, 0);
if (!JudgeMoneyLogic.IsMoneyEnough((MONEYTYPE)weiBoTable.GiftConsumeSubType, weiBoTable.GiftConsumeNum))
{
return;
}
CG_REQ_MENGDAO_SET_GIFT packet = (CG_REQ_MENGDAO_SET_GIFT)PacketDistributed.CreatePacket(MessageID.PACKET_CG_REQ_MENGDAO_SET_GIFT);
packet.Giftcount = _PresentCnt.Value;
packet.SendPacket();
CloseWindow();
}
#endregion
}