117 lines
2.8 KiB
C#
117 lines
2.8 KiB
C#
using System.Collections.Generic;
|
|
using BitStrap;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class EquipmentSetsGUI : MonoBehaviour
|
|
{
|
|
public EquipmentManager equipmentManager;
|
|
|
|
public EquipmentGUI equipmentGUI;
|
|
|
|
public List<Toggle> equipmentSetToggles = new List<Toggle>();
|
|
|
|
[Space(10f)]
|
|
public Button useThisSetBtn;
|
|
|
|
public Text currentSetText;
|
|
|
|
[ReadOnly]
|
|
public int prevSetId;
|
|
|
|
private void Start()
|
|
{
|
|
equipmentManager = GlobalSettings.Instance.equipmentManager;
|
|
Initialize();
|
|
}
|
|
|
|
private void OnEnable()
|
|
{
|
|
if ((bool)equipmentManager && (bool)equipmentGUI.equipmentManager)
|
|
{
|
|
Initialize();
|
|
}
|
|
}
|
|
|
|
private void OnDisable()
|
|
{
|
|
if ((bool)equipmentManager && prevSetId != equipmentManager.currentEquipmentSetId)
|
|
{
|
|
equipmentManager.ChangeCurrentEquipmentSet(prevSetId);
|
|
}
|
|
}
|
|
|
|
public void Initialize()
|
|
{
|
|
prevSetId = equipmentManager.currentEquipmentSetId;
|
|
TurnOnToggle(prevSetId);
|
|
UpdateInfo(false);
|
|
}
|
|
|
|
public void ChangeSet(int setId)
|
|
{
|
|
if (setId != equipmentManager.currentEquipmentSetId)
|
|
{
|
|
if ((bool)GameController.Instance)
|
|
{
|
|
}
|
|
equipmentManager.ChangeCurrentEquipmentSet(setId);
|
|
equipmentGUI.UpdateCanEquipmentBeChanged();
|
|
equipmentGUI.RefreshCurrent();
|
|
equipmentGUI.RefreshMessage();
|
|
equipmentGUI.RefreshTileViews();
|
|
UpdateInfo(prevSetId != equipmentManager.currentEquipmentSetId);
|
|
Debug.Log("ChangeSet: " + setId);
|
|
}
|
|
}
|
|
|
|
public void UpdateInfo(bool showButton)
|
|
{
|
|
if ((bool)GameController.Instance && GameController.Instance.fishingPlayer.IsCurrentSetOnStand())
|
|
{
|
|
currentSetText.text = Utilities.GetTranslation("EQUIPMENT/SET_ON_ROD_POD");
|
|
showButton = false;
|
|
}
|
|
else if ((bool)GameController.Instance && !equipmentGUI.canSetBeChanged)
|
|
{
|
|
currentSetText.text = Utilities.GetTranslation("EQUIPMENT/SET_FISHING");
|
|
showButton = false;
|
|
}
|
|
else
|
|
{
|
|
currentSetText.text = Utilities.GetTranslation("EQUIPMENT/SET_CURRENT");
|
|
}
|
|
useThisSetBtn.gameObject.SetActive(showButton);
|
|
currentSetText.gameObject.SetActive(!showButton);
|
|
}
|
|
|
|
public void SetCurrentSet()
|
|
{
|
|
prevSetId = equipmentManager.currentEquipmentSetId;
|
|
UpdateInfo(false);
|
|
if ((bool)GameController.Instance)
|
|
{
|
|
if (GameController.Instance.iceLevel)
|
|
{
|
|
GameController.Instance.fishingPlayer.currentHands.equipmentSetId = equipmentManager.currentEquipmentSetId;
|
|
}
|
|
else
|
|
{
|
|
GameController.Instance.fishingPlayer.ChangeHands(equipmentManager.currentEquipmentSetId);
|
|
GameController.Instance.fishingPlayer.currentHands.equipmentSetId = equipmentManager.currentEquipmentSetId;
|
|
GameController.Instance.fishingPlayer.ResetFishing();
|
|
}
|
|
}
|
|
equipmentManager.EquipmentChanged(EquipmentObject.EquipmentType.COUNT);
|
|
}
|
|
|
|
public void TurnOnToggle(int id)
|
|
{
|
|
for (int i = 0; i < equipmentSetToggles.Count; i++)
|
|
{
|
|
equipmentSetToggles[i].isOn = false;
|
|
}
|
|
equipmentSetToggles[id].isOn = true;
|
|
}
|
|
}
|