Files
JJBB/Assets/Project/Script/GUI/BackPack/PlayerEquipInfo.cs
2024-08-23 15:49:34 +08:00

100 lines
3.3 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using UnityEngine;
using UnityEngine.UI;
using System.Collections;
using Games.Item;
using GCGame.Table;
public class PlayerEquipInfo : MonoBehaviour
{
public UICameraTexture _UICameraTexture;
public Text _NameText;
public UIImgText _CombatText;
public CommonItemEquipItem[] _EquipItems;
public int[] _EquipSlot;
void Awake()
{
Games.Events.EventDispatcher.Instance.Add(Games.Events.EventId.MainPlayerModelChange, OnModelChange);
_UICameraTexture.isPreview = true;
}
private void OnEnable()
{
UpdateShowModel();
}
void OnDestroy()
{
Games.Events.EventDispatcher.Instance.Remove(Games.Events.EventId.MainPlayerModelChange, OnModelChange);
}
public void OnModelChange(object param)
{
UpdateShowModel();
}
public void UpdateInfo()
{
_NameText.text = GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.RoleName;
_CombatText.text = GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.EquipTotalCombatValue.ToString();
//CombatValue.CalculateEquipTotal().ToString();
GameItemContainer EquipPack = GameManager.gameManager.PlayerDataPool.EquipPack;
for (int index = 0; index < EquipPack.ContainerSize; ++index)
{
GameItem equip = EquipPack.GetItem(GetEquipSlotByIndex(index));
_EquipItems[index].InitItem(equip);
_EquipItems[index].SetStrength(GameManager.gameManager.PlayerDataPool.EquipSlotStrength[GetEquipSlotByIndex(index)].lv);
_EquipItems[index]._ClickEvent = OnEquipClick;
}
}
void OnEquipClick(object equipObj)
{
GameItem equipItem = equipObj as GameItem;
EquipTooltipsLogic.ShowEquipTooltip(equipItem, ItemTooltipsLogic.ShowType.Equiped, transform.position);
}
public void UpdateShowModel()
{
var mainPlayer = Singleton<ObjManager>.GetInstance().MainPlayer;
if (mainPlayer != null)
{
_UICameraTexture.InitPlayerModel(mainPlayer);
}
}
// 已经失效的接口并且UICameraTexture.InitShowGO(GameObject showObj)也早以不能使用
// private void LoadModelFinish(string modelName, GameObject resObj, object param1, object param2, object param3 = null)
// {
// if (resObj == null)
// return;
//
// _UICameraTexture.InitShowGO(resObj);
// }
public void ShowEnHanceWin()
{
EquipQianghuaSuitTips.Show(GameManager.gameManager.PlayerDataPool.EquipSuitID, GameManager.gameManager.PlayerDataPool.NextSuitEquipCnt);
}
int GetEquipSlotByIndex(int index)
{
//switch (index)
//{
// case 0: return (int)EquipPackSlot.Slot_WEAPON;
// case 1: return (int)EquipPackSlot.Slot_HEAD;
// case 2: return (int)EquipPackSlot.Slot_RING;
// case 3: return (int)EquipPackSlot.Slot_ARMOR;
// case 4: return (int)EquipPackSlot.Slot_NECK;
// case 5: return (int)EquipPackSlot.Slot_CUFF;
// case 6: return (int)EquipPackSlot.Slot_AMULET;
// case 7: return (int)EquipPackSlot.Slot_LEG_GUARD;
// case 8: return (int)EquipPackSlot.Slot_BELT;
// case 9: return (int)EquipPackSlot.Slot_SHOES;
// default:
// break;
//}
return _EquipSlot[index];
}
}