103 lines
2.8 KiB
C#
103 lines
2.8 KiB
C#
|
using System.Collections;
|
|||
|
using System.Collections.Generic;
|
|||
|
using UnityEngine;
|
|||
|
using GCGame.Table;
|
|||
|
using UnityEngine.UI;
|
|||
|
using Module.Log;
|
|||
|
|
|||
|
public class ExerciseLessItemPanel : MonoBehaviour {
|
|||
|
public static ExerciseLessItemPanel Instance;
|
|||
|
private void Awake()
|
|||
|
{
|
|||
|
Instance = this;
|
|||
|
}
|
|||
|
|
|||
|
private void OnDestroy()
|
|||
|
{
|
|||
|
Instance = null;
|
|||
|
}
|
|||
|
|
|||
|
private void OnEnable()
|
|||
|
{
|
|||
|
InitInfo();
|
|||
|
}
|
|||
|
|
|||
|
public Image _ItemQuality;
|
|||
|
public Image _ItemIcon;
|
|||
|
public Text _Desc;
|
|||
|
private int _ItemDataId = -1;
|
|||
|
public GameObject _GetBtn;
|
|||
|
void InitInfo()
|
|||
|
{
|
|||
|
if(_ItemDataId ==- 1)
|
|||
|
_ItemDataId = TableManager.GetExerciseRoomSetUpByID(0, 0).ItemId;
|
|||
|
|
|||
|
_Desc.text = StrDictionary.GetClientDictionaryString("#{8137}");
|
|||
|
var commonItem = TableManager.GetCommonItemByID(_ItemDataId, 0);
|
|||
|
if (commonItem == null)
|
|||
|
{
|
|||
|
LogModule.ErrorLog("CommonItem is null, item id : " + _ItemDataId);
|
|||
|
return;
|
|||
|
}
|
|||
|
LoadAssetBundle.Instance.SetImageSprite(_ItemQuality, GCGame.Utils.GetItemQualityFrame(commonItem.Quality));
|
|||
|
|
|||
|
LoadAssetBundle.Instance.SetImageSprite(_ItemIcon, commonItem.Icon);
|
|||
|
if (commonItem.QualityEffect > 0)
|
|||
|
{
|
|||
|
CommonItemContainerItem.ShowQualityEffect(true, commonItem.QualityEffect, _ItemIcon.transform);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
CommonItemContainerItem.ShowQualityEffect(false, commonItem.QualityEffect, _ItemIcon.transform);
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
var backPack = GameManager.gameManager.PlayerDataPool.BackPack;
|
|||
|
var itemCount = backPack.GetItemCountByDataId(_ItemDataId);
|
|||
|
_GetBtn.SetActive(itemCount <= 0);
|
|||
|
}
|
|||
|
|
|||
|
public void OnConfirmBtn()
|
|||
|
{
|
|||
|
var itemCount = GameManager.gameManager.PlayerDataPool.BackPack.GetItemCountByDataId(_ItemDataId);
|
|||
|
if(itemCount <= 0)
|
|||
|
{
|
|||
|
GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{1016}"));
|
|||
|
ClosePanel();
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
UseItem();
|
|||
|
ClosePanel();
|
|||
|
}
|
|||
|
|
|||
|
void UseItem()
|
|||
|
{
|
|||
|
var item = GameManager.gameManager.PlayerDataPool.BackPack.GetItemByDataID(_ItemDataId);
|
|||
|
if (Singleton<ObjManager>.Instance.MainPlayer)
|
|||
|
Singleton<ObjManager>.Instance.MainPlayer.UseItem(item);
|
|||
|
}
|
|||
|
|
|||
|
public void OnItemIcon()
|
|||
|
{
|
|||
|
ItemTooltipsLogic.ShowItemTooltip(_ItemDataId, ItemTooltipsLogic.ShowType.Info, _ItemIcon.gameObject.transform.position);
|
|||
|
}
|
|||
|
|
|||
|
public void OnGetBtn()
|
|||
|
{
|
|||
|
ItemTooltipsLogic.ShowItemTooltip(_ItemDataId, ItemTooltipsLogic.ShowType.GetPath, _ItemIcon.gameObject.transform.position, delegate() {
|
|||
|
ClosePanel();
|
|||
|
});
|
|||
|
}
|
|||
|
|
|||
|
public void OnBackClick()
|
|||
|
{
|
|||
|
ClosePanel();
|
|||
|
}
|
|||
|
|
|||
|
void ClosePanel()
|
|||
|
{
|
|||
|
UIManager.CloseUI(UIInfo.ExerciseLessItemPanel);
|
|||
|
}
|
|||
|
}
|