2024-12-13 20:38:15 +08:00

125 lines
4.0 KiB
C#

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
/// <summary>
/// 装备菜单栏管理
/// </summary>
public class PlayerBar : MonoBehaviour
{
public int Index => index;
[SerializeField] private int index;
[SerializeField] private BattlePanel _panel;
[SerializeField] private GameObject playerParent;
[SerializeField] private PlayerBarItem weaponBar;
[SerializeField] private PlayerBarItem weaponBar2;
[SerializeField] private PlayerBarItem armorBar;
[SerializeField] private PlayerBarItem audioUniversalBar;
[SerializeField] private PlayerBarItem audioWeaponBar;
[SerializeField] private PlayerBarItem audioWeaponBar2;
[SerializeField] private GameObject unLockWeaponBar;
[SerializeField] private GameObject unLockSoldier;
[SerializeField] private Image back;
[SerializeField] private Button _button;
[SerializeField] private Sprite seclet;
[SerializeField] private Sprite unSecet;
private void Awake()
{
back = GetComponent<Image>();
_button = GetComponent<Button>();
}
private void OnEnable()
{
_button.onClick.AddListener(SetIndex);
}
private void OnDisable()
{
_button.onClick.RemoveListener(SetIndex);
}
// Start is called before the first frame update
public void RestData(BattlePanel panel)
{
if (index!=0&& !BattleManager.ins.OpenVideoSoldier)
{
unLockSoldier.SetActive(false);
unLockWeaponBar.SetActive(false);
weaponBar.gameObject.SetActive(false);
weaponBar2.gameObject.SetActive(false);
armorBar.gameObject.SetActive(false);
audioUniversalBar.gameObject.SetActive(false);
audioWeaponBar.gameObject.SetActive(false);
audioWeaponBar2.gameObject.SetActive(false);
playerParent.SetActive(false);
}
else if (!BattleManager.ins.OpenVideoWeaponry)
{
unLockSoldier.SetActive(false);
unLockWeaponBar.SetActive(true);
weaponBar.gameObject.SetActive(true);
weaponBar2.gameObject.SetActive(true);
armorBar.gameObject.SetActive(true);
audioUniversalBar.gameObject.SetActive(false);
audioWeaponBar.gameObject.SetActive(false);
audioWeaponBar2.gameObject.SetActive(false);
playerParent.SetActive(true);
}
else
{
unLockSoldier.SetActive(false);
unLockWeaponBar.SetActive(false);
weaponBar.gameObject.SetActive(true);
weaponBar2.gameObject.SetActive(true);
armorBar.gameObject.SetActive(true);
audioUniversalBar.gameObject.SetActive(true);
audioWeaponBar.gameObject.SetActive(true);
audioWeaponBar2.gameObject.SetActive(true);
playerParent.SetActive(true);
}
var indexData=BattleManager.ins.BattleEquipments[index];
weaponBar.ResetIcon(indexData.weaponID,this,BattleBarType.weaponBar);
weaponBar2.ResetIcon(indexData.weapon2ID,this,BattleBarType.weaponBar2);
armorBar.ResetIcon(indexData.armorID,this,BattleBarType.armorBar);
audioUniversalBar.ResetIcon(indexData.audioUniversalID,this,BattleBarType.audioUniversalBar);
audioWeaponBar.ResetIcon(indexData.audioWeaponID,this,BattleBarType.audioWeaponBar);
audioWeaponBar2.ResetIcon(indexData.audioWeapon2ID,this,BattleBarType.audioWeaponBar2);
ResetBack();
}
public void ResetBack()
{
back.sprite = BattleManager.ins.EquipmentIndex == index ? seclet : unSecet;
if (index==0 || BattleManager.ins.OpenVideoSoldier)
{
back.enabled = true;
}
else
{
back.enabled = false;
}
}
public void SetIndex()
{
if (index==0 || BattleManager.ins.OpenVideoSoldier)
{
BattleManager.ins.SetIndex(index);
}
}
}