116 lines
3.2 KiB
C#
116 lines
3.2 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using GCGame.Table;
|
|
|
|
public class BanQuetCandyPanel : MonoBehaviour {
|
|
|
|
public List<Text> _CnadyItemNameList;
|
|
public List<Text> _CandyItemCostList;
|
|
|
|
public UINumBoardInput _NumInput;
|
|
public Image _CostMoneyIcon;
|
|
public Text _CostValText;
|
|
public List<GameObject> _ItemMarkIconList;
|
|
|
|
private void OnEnable()
|
|
{
|
|
UIManager.ShowUI(UIInfo.MoneyInfoPanel);
|
|
Init();
|
|
}
|
|
|
|
private void OnDisable()
|
|
{
|
|
UIManager.CloseUI(UIInfo.MoneyInfoPanel);
|
|
}
|
|
|
|
void Init()
|
|
{
|
|
var tabA = TableManager.GetWeddingCandyByID(1, 0);
|
|
_CandyItemCostList[0].text = tabA.CostVal + GCGame.Utils.GetMoneyName(tabA.CostSubClassType);
|
|
|
|
var tabB = TableManager.GetWeddingCandyByID(2, 0);
|
|
_CandyItemCostList[1].text = tabB.CostVal + GCGame.Utils.GetMoneyName(tabB.CostSubClassType);
|
|
|
|
OnCnadyItem(0);
|
|
}
|
|
|
|
private int _CurSelectCandyIndex = 0;
|
|
private int _CurSelectMoneyType = (int)MONEYTYPE.MONEYTYPE_COIN;
|
|
private int _SingleCostVal = 0;
|
|
public void OnCnadyItem(int index)
|
|
{
|
|
_CurSelectCandyIndex = index;
|
|
|
|
if (_CurSelectCandyIndex == 0)
|
|
{
|
|
_CurSelectMoneyType = TableManager.GetWeddingCandyByID(1, 0).CostSubClassType;
|
|
_SingleCostVal = TableManager.GetWeddingCandyByID(1, 0).CostVal;
|
|
}
|
|
else
|
|
{
|
|
_CurSelectMoneyType = TableManager.GetWeddingCandyByID(2, 0).CostSubClassType;
|
|
_SingleCostVal = TableManager.GetWeddingCandyByID(2, 0).CostVal;
|
|
}
|
|
|
|
_NumInput.Init(10, 10, 99);
|
|
ShowMarkIcon(index);
|
|
InitMMoneyIcon();
|
|
}
|
|
|
|
public void InitMMoneyIcon()
|
|
{
|
|
LoadAssetBundle.Instance.SetImageSprite(_CostMoneyIcon, UICurrencyItem.GetCurrencySprite((MONEYTYPE)_CurSelectMoneyType));
|
|
OnNumChange();
|
|
}
|
|
|
|
private int _taotalCostVal = 0;
|
|
private int _CurSelectSendVal = 0;
|
|
public void OnNumChange()
|
|
{
|
|
_CurSelectSendVal = _NumInput.Value;
|
|
_taotalCostVal = _CurSelectSendVal * _SingleCostVal;
|
|
_CostValText.text = _taotalCostVal + "";
|
|
}
|
|
|
|
public void ShowMarkIcon(int _Index)
|
|
{
|
|
for(int index= 0; index < _ItemMarkIconList.Count; index++)
|
|
{
|
|
_ItemMarkIconList[index].SetActive(index == _Index);
|
|
}
|
|
}
|
|
|
|
public void OnSendBtn()
|
|
{
|
|
if(JudgeMoneyLogic.IsMoneyEnough((MONEYTYPE)_CurSelectMoneyType, _taotalCostVal))
|
|
{
|
|
if(!GameManager.gameManager.PlayerDataPool.IsInWeddingCar)
|
|
{
|
|
ReqSendCandy req = new ReqSendCandy();
|
|
req.nCandyType = _CurSelectCandyIndex + 1;
|
|
req.nCandyNum = _CurSelectSendVal;
|
|
req.SendMsg();
|
|
|
|
Debug.LogError("Banquet Candy");
|
|
}else
|
|
{
|
|
ReqSendCarCandy req = new ReqSendCarCandy();
|
|
req.nCandyType = _CurSelectCandyIndex + 1;
|
|
req.nCandyNum = _CurSelectSendVal;
|
|
req.SendMsg();
|
|
|
|
Debug.LogError("Car Candy");
|
|
}
|
|
|
|
OnCloseBtn();
|
|
}
|
|
}
|
|
|
|
public void OnCloseBtn()
|
|
{
|
|
this.gameObject.SetActive(false);
|
|
}
|
|
}
|