75 lines
2.4 KiB
C#
75 lines
2.4 KiB
C#
|
using UnityEngine;
|
|||
|
using UnityEngine.UI;
|
|||
|
using UnityEngine.EventSystems;
|
|||
|
using System.Collections;
|
|||
|
using System.Collections.Generic;
|
|||
|
using GCGame.Table;
|
|||
|
using Games.Events;
|
|||
|
|
|||
|
public class SceneItemUseChild : MonoBehaviour, IPointerClickHandler
|
|||
|
{
|
|||
|
|
|||
|
public Image Quility;
|
|||
|
public Image Icon;
|
|||
|
public Text Num;
|
|||
|
|
|||
|
private Games.Item.GameItem m_sceneItem;
|
|||
|
public bool Show(Games.Item.GameItem sceneItem)
|
|||
|
{
|
|||
|
if (sceneItem == null || sceneItem.IsValid() == false)
|
|||
|
{
|
|||
|
gameObject.SetActive(false);
|
|||
|
return false;
|
|||
|
}
|
|||
|
m_sceneItem = sceneItem;
|
|||
|
Tab_CommonItem commonItem = TableManager.GetCommonItemByID(m_sceneItem.DataID, 0);
|
|||
|
if (commonItem == null)
|
|||
|
{
|
|||
|
gameObject.SetActive(false);
|
|||
|
return false;
|
|||
|
}
|
|||
|
gameObject.SetActive(true);
|
|||
|
LoadAssetBundle.Instance.SetImageSprite(Quility, GCGame.Utils.GetItemQualityFrame(commonItem.Quality));
|
|||
|
LoadAssetBundle.Instance.SetImageSprite(Icon, commonItem.Icon);
|
|||
|
Num.text = GameManager.gameManager.PlayerDataPool.BackPack.GetItemCountByDataId(commonItem.Id).ToString();
|
|||
|
return true;
|
|||
|
}
|
|||
|
|
|||
|
public virtual void OnPointerClick(PointerEventData eventData)
|
|||
|
{
|
|||
|
if (m_sceneItem == null || m_sceneItem.IsValid() == false)
|
|||
|
return;
|
|||
|
Tab_UsableItem tab_UsableItem = TableManager.GetUsableItemByID(m_sceneItem.DataID, 0);
|
|||
|
if (tab_UsableItem == null)
|
|||
|
return;
|
|||
|
if (tab_UsableItem.UseParamA == 1 || tab_UsableItem.UseParamA == 2)
|
|||
|
{
|
|||
|
if(WorldBossData.Instance.AliveBossCount()>=WorldBossData.Instance.SceneBossCount())
|
|||
|
{
|
|||
|
GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("{#49156}"));
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
if (tab_UsableItem.UseParamC == 2 && WorldBossData.Instance.AliveBossCount() > 0)
|
|||
|
{
|
|||
|
MessageBoxLogic.OpenOKCancelBox(StrDictionary.GetClientDictionaryString("#{49157}"), "", delegate () {
|
|||
|
BossScene();
|
|||
|
});
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
BossScene();
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
private void BossScene()
|
|||
|
{
|
|||
|
var useitem = (CG_USE_ITEM)PacketDistributed.CreatePacket(MessageID.PACKET_CG_USE_ITEM);
|
|||
|
useitem.SetItemguid(m_sceneItem.Guid);
|
|||
|
useitem.SetUsecount(1);
|
|||
|
useitem.SendPacket();
|
|||
|
}
|
|||
|
}
|