152 lines
4.5 KiB
C#
152 lines
4.5 KiB
C#
|
using UnityEngine;
|
|||
|
using UnityEngine.UI;
|
|||
|
using System.Collections;
|
|||
|
using System.Collections.Generic;
|
|||
|
using Games.GlobeDefine;
|
|||
|
using GCGame.Table;
|
|||
|
using GCGame;
|
|||
|
using Games.Item;
|
|||
|
|
|||
|
public class GetGiftRoot : MonoBehaviour
|
|||
|
{
|
|||
|
|
|||
|
public Text m_tip;
|
|||
|
public Text m_time;
|
|||
|
public Image m_Quility;
|
|||
|
public Image m_itemIcon;
|
|||
|
public Text m_itemCout;
|
|||
|
|
|||
|
private ulong _MailGUID = 0;
|
|||
|
private int _ItemDataID = 0;
|
|||
|
private int _ItemNum = 0;
|
|||
|
private float _Time = -100;
|
|||
|
private ulong _SenderGuid = 0;
|
|||
|
private string Name = "";
|
|||
|
void Awake()
|
|||
|
{
|
|||
|
Hashtable add = new Hashtable();
|
|||
|
add["name"] = "GetGift";
|
|||
|
Games.Events.MessageEventCallBack call = OnOpen;
|
|||
|
add["callFun"] = call;
|
|||
|
Games.Events.EventDispatcher.Instance.AddMessageEvent(Games.Events.EventId.OpenGetGiftItemWnd, add);
|
|||
|
}
|
|||
|
|
|||
|
private void Start()
|
|||
|
{
|
|||
|
InvokeRepeating("UpdateTime", 1, 1);
|
|||
|
}
|
|||
|
|
|||
|
public void OnOpen(Hashtable addparam, Hashtable sendparam)
|
|||
|
{
|
|||
|
if (sendparam == null)
|
|||
|
return;
|
|||
|
if (sendparam.ContainsKey("mail"))
|
|||
|
{
|
|||
|
_MailGUID = (ulong)sendparam["mail"];
|
|||
|
}
|
|||
|
if (sendparam.ContainsKey("itemId"))
|
|||
|
{
|
|||
|
_ItemDataID = (int)sendparam["itemId"];
|
|||
|
}
|
|||
|
if (sendparam.ContainsKey("itemCount"))
|
|||
|
{
|
|||
|
_ItemNum = (int)sendparam["itemCount"];
|
|||
|
}
|
|||
|
if (sendparam.ContainsKey("time"))
|
|||
|
{
|
|||
|
_Time = (int)sendparam["time"];
|
|||
|
_Time = _Time - GlobalData.ServerAnsiTime;
|
|||
|
if (_Time > 24 * 3600)
|
|||
|
_Time = 24 * 3600;
|
|||
|
_Time = _Time + Time.realtimeSinceStartup;
|
|||
|
}
|
|||
|
if (sendparam.ContainsKey("sendId"))
|
|||
|
{
|
|||
|
_SenderGuid = (ulong)sendparam["sendId"];
|
|||
|
}
|
|||
|
if(sendparam.ContainsKey("name"))
|
|||
|
{
|
|||
|
Name =(string) sendparam["name"];
|
|||
|
}
|
|||
|
m_tip.gameObject.SetActive(true);
|
|||
|
m_tip.text = StrDictionary.GetClientDictionaryString("#{5216}", Name);
|
|||
|
Tab_CommonItem item = TableManager.GetCommonItemByID(_ItemDataID, 0);
|
|||
|
if(item!=null)
|
|||
|
{
|
|||
|
LoadAssetBundle.Instance.SetImageSprite(m_itemIcon, item.Icon);
|
|||
|
LoadAssetBundle.Instance.SetImageSprite(m_Quility, Utils.GetItemQualityFrame(item));
|
|||
|
if (item.QualityEffect > 0)
|
|||
|
{
|
|||
|
CommonItemContainerItem.ShowQualityEffect(true, item.QualityEffect, m_itemIcon.transform);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
CommonItemContainerItem.ShowQualityEffect(false, item.QualityEffect, m_itemIcon.transform);
|
|||
|
}
|
|||
|
|
|||
|
m_itemCout.text = _ItemNum.ToString();
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
m_itemCout.gameObject.SetActive(false);
|
|||
|
m_itemIcon.gameObject.SetActive(false);
|
|||
|
m_Quility.gameObject.SetActive(false);
|
|||
|
}
|
|||
|
UpdateTime();
|
|||
|
}
|
|||
|
|
|||
|
void UpdateTime()
|
|||
|
{
|
|||
|
if (_Time == -100)
|
|||
|
return;
|
|||
|
float leaveTime = _Time - Time.realtimeSinceStartup;
|
|||
|
if (leaveTime <= 0)
|
|||
|
{
|
|||
|
UIManager.CloseUI(UIInfo.GetGiftRoot);
|
|||
|
return;
|
|||
|
}
|
|||
|
int hour = (int)leaveTime / 3600;
|
|||
|
int minute = (int)(leaveTime - hour * 3600) / 60;
|
|||
|
int second = (int)leaveTime - hour * 3600 - minute * 60;
|
|||
|
m_time.text = StrDictionary.GetClientDictionaryString("#{5217}", hour, minute, second);
|
|||
|
}
|
|||
|
|
|||
|
private void OnDisable()
|
|||
|
{
|
|||
|
_Time = -100;
|
|||
|
}
|
|||
|
|
|||
|
void OnDestroy()
|
|||
|
{
|
|||
|
Games.Events.EventDispatcher.Instance.RemoveMessage(Games.Events.EventId.OpenGetGiftItemWnd, "GetGift");
|
|||
|
}
|
|||
|
|
|||
|
public void Get_Click()
|
|||
|
{
|
|||
|
MessageBoxLogic.OpenOKCancelBox(StrDictionary.GetClientDictionaryString("#{5218}"), "", OkClick, CancelClick);
|
|||
|
}
|
|||
|
|
|||
|
public void OkClick()
|
|||
|
{
|
|||
|
CG_GIVE_BACK_GIFT_TO_TEAMMATE send = (CG_GIVE_BACK_GIFT_TO_TEAMMATE)PacketDistributed.CreatePacket(MessageID.PACKET_CG_GIVE_BACK_GIFT_TO_TEAMMATE);
|
|||
|
send.SetMailGuid(_MailGUID);
|
|||
|
send.SetIsTrue(1);
|
|||
|
send.SendPacket();
|
|||
|
UIManager.CloseUI(UIInfo.GetGiftRoot);
|
|||
|
}
|
|||
|
|
|||
|
public void CancelClick()
|
|||
|
{
|
|||
|
CG_GIVE_BACK_GIFT_TO_TEAMMATE send = (CG_GIVE_BACK_GIFT_TO_TEAMMATE)PacketDistributed.CreatePacket(MessageID.PACKET_CG_GIVE_BACK_GIFT_TO_TEAMMATE);
|
|||
|
send.SetMailGuid(_MailGUID);
|
|||
|
send.SetIsTrue(0);
|
|||
|
send.SendPacket();
|
|||
|
UIManager.CloseUI(UIInfo.GetGiftRoot);
|
|||
|
}
|
|||
|
|
|||
|
public void Close_Click()
|
|||
|
{
|
|||
|
UIManager.CloseUI(UIInfo.GetGiftRoot);
|
|||
|
}
|
|||
|
|
|||
|
}
|