200 lines
5.2 KiB
C#
200 lines
5.2 KiB
C#
|
|
|||
|
using UnityEngine;
|
|||
|
using UnityEngine.UI;
|
|||
|
using System.Collections;
|
|||
|
using System.Collections.Generic;
|
|||
|
using Games.GlobeDefine;
|
|||
|
using GCGame.Table;
|
|||
|
using GCGame;
|
|||
|
using Module.Log;
|
|||
|
|
|||
|
public class RedPacketSendRoot : UIControllerBase<RedPacketSendRoot>
|
|||
|
{
|
|||
|
void OnEnable()
|
|||
|
{
|
|||
|
SetInstance(this);
|
|||
|
}
|
|||
|
|
|||
|
void OnDisable()
|
|||
|
{
|
|||
|
SetInstance(null);
|
|||
|
}
|
|||
|
|
|||
|
public void CloseWindow()
|
|||
|
{
|
|||
|
UIManager.CloseUI(UIInfo.RedPacketSendRoot);
|
|||
|
}
|
|||
|
|
|||
|
#region static
|
|||
|
|
|||
|
public static void ShowRedPacketSend(bool isWorldPacket)
|
|||
|
{
|
|||
|
Hashtable hash = new Hashtable();
|
|||
|
hash.Add("IsWorldPacket", isWorldPacket);
|
|||
|
UIManager.ShowUI(UIInfo.RedPacketSendRoot, OnRedPacketSendShow, hash);
|
|||
|
}
|
|||
|
|
|||
|
static void OnRedPacketSendShow(bool bSuccess, object param)
|
|||
|
{
|
|||
|
Hashtable hash = param as Hashtable;
|
|||
|
if (!bSuccess)
|
|||
|
{
|
|||
|
return;
|
|||
|
}
|
|||
|
if (hash == null)
|
|||
|
{
|
|||
|
return;
|
|||
|
}
|
|||
|
if (RedPacketSendRoot.Instance() != null)
|
|||
|
{
|
|||
|
RedPacketSendRoot.Instance().Show((bool)hash["IsWorldPacket"]);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region
|
|||
|
|
|||
|
public const int _SEND_MONEY_RATE = 5700;
|
|||
|
|
|||
|
public Text _Title;
|
|||
|
public Text _Tips;
|
|||
|
public UINumBoardInput _CostMoney;
|
|||
|
public UICurrencyItem _SendMoney;
|
|||
|
public UINumBoardInput _SendPacketCnt;
|
|||
|
public InputField _InputMsg;
|
|||
|
public UICurrencyItem _OwnMoney;
|
|||
|
public Vector2 _WorldPacketNum = new Vector2(50, 50);
|
|||
|
public Vector2 _GuidePacketNum = new Vector2(20, 20);
|
|||
|
|
|||
|
public GameObject _GuideSetBtn;
|
|||
|
public GameObject _GuideSetPanel;
|
|||
|
public Toggle[] _GuildSets;
|
|||
|
|
|||
|
private bool _IsWorldPacket = true;
|
|||
|
|
|||
|
public void Show(bool isWorldPacket)
|
|||
|
{
|
|||
|
_IsWorldPacket = isWorldPacket;
|
|||
|
if (isWorldPacket)
|
|||
|
{
|
|||
|
_CostMoney.Init(100, 100, 100000);
|
|||
|
_SendPacketCnt.Init((int)_WorldPacketNum.x, (int)_WorldPacketNum.x, (int)_WorldPacketNum.y);
|
|||
|
_GuideSetBtn.SetActive(false);
|
|||
|
_Title.text = StrDictionary.GetClientDictionaryString("#{40100}");
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
_CostMoney.Init(100, 100, 10000);
|
|||
|
_SendPacketCnt.Init((int)_GuidePacketNum.x, (int)_GuidePacketNum.x, (int)_GuidePacketNum.y);
|
|||
|
//_GuideSetBtn.SetActive(true);
|
|||
|
_GuideSetBtn.SetActive(false);
|
|||
|
_Title.text = StrDictionary.GetClientDictionaryString("#{40101}");
|
|||
|
}
|
|||
|
ShowSendMoney();
|
|||
|
_GuideSetPanel.SetActive(false);
|
|||
|
_OwnMoney.ShowOwnCurrency(MONEYTYPE.MONEYTYPE_YUANBAO);
|
|||
|
_Tips.text = StrDictionary.GetClientDictionaryString("#{40102}");
|
|||
|
_InputMsg.text = "";
|
|||
|
}
|
|||
|
|
|||
|
public void ShowSendMoney()
|
|||
|
{
|
|||
|
_SendMoney.ShowCurrency(MONEYTYPE.MONEYTYPE_COIN, _CostMoney.Value * _SEND_MONEY_RATE);
|
|||
|
}
|
|||
|
|
|||
|
public void OnBtnSend()
|
|||
|
{
|
|||
|
int costValue = _CostMoney.Value;
|
|||
|
int packetCnt = _SendPacketCnt.Value;
|
|||
|
string msg = Utils.StrFilter_Chat(_InputMsg.text);
|
|||
|
if (msg != _InputMsg.text)
|
|||
|
{
|
|||
|
GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{40119}"));
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
if (string.IsNullOrEmpty(msg))
|
|||
|
{
|
|||
|
MessageBoxLogic.OpenOKBox(40112);
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
if (!JudgeMoneyLogic.IsMoneyEnough(MONEYTYPE.MONEYTYPE_YUANBAO, costValue))
|
|||
|
{
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
MessageBoxLogic.OpenOKCancelBox(StrDictionary.GetClientDictionaryString("#{40116}", costValue), null, () => { OnBtnSendOK(costValue, packetCnt, msg); });
|
|||
|
}
|
|||
|
|
|||
|
private void OnBtnSendOK(int costValue, int packetCnt, string msg)
|
|||
|
{
|
|||
|
|
|||
|
|
|||
|
if (_IsWorldPacket)
|
|||
|
{
|
|||
|
CG_GIVE_WORLD_RED_PACKET packet = (CG_GIVE_WORLD_RED_PACKET)PacketDistributed.CreatePacket(MessageID.PACKET_CG_GIVE_WORLD_RED_PACKET);
|
|||
|
packet.JadeNum = costValue;
|
|||
|
packet.PacketNum = packetCnt;
|
|||
|
packet.PacketInfo = msg;
|
|||
|
|
|||
|
packet.SendPacket();
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
int guidSet = 1;
|
|||
|
for (int i = 0; i < _GuildSets.Length; ++i)
|
|||
|
{
|
|||
|
if (_GuildSets[i].isOn)
|
|||
|
{
|
|||
|
guidSet = i + 1;
|
|||
|
}
|
|||
|
}
|
|||
|
CG_GIVE_GUIDLD_RED_PACKET packet = (CG_GIVE_GUIDLD_RED_PACKET)PacketDistributed.CreatePacket(MessageID.PACKET_CG_GIVE_GUIDLD_RED_PACKET);
|
|||
|
packet.JadeNum = costValue;
|
|||
|
packet.PacketNum = packetCnt;
|
|||
|
packet.PacketInfo = msg;
|
|||
|
packet.PacketType = guidSet;
|
|||
|
packet.SendPacket();
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
LogModule.DebugLog("Send packet:" + costValue + "," + packetCnt + "," + msg);
|
|||
|
|
|||
|
CloseWindow();
|
|||
|
}
|
|||
|
|
|||
|
public void OnBtnHelp()
|
|||
|
{
|
|||
|
if (!_IsWorldPacket)
|
|||
|
{
|
|||
|
MessageHelpLogic.ShowHelpMessage(6);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
MessageHelpLogic.ShowHelpMessage(5);
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
public void OnBtnSetHelp()
|
|||
|
{
|
|||
|
MessageHelpLogic.ShowHelpMessage(7);
|
|||
|
}
|
|||
|
|
|||
|
public void OnShowGuildSet()
|
|||
|
{
|
|||
|
_GuideSetPanel.SetActive(true);
|
|||
|
}
|
|||
|
|
|||
|
public void OnHideGuildSet()
|
|||
|
{
|
|||
|
_GuideSetPanel.SetActive(false);
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
}
|