106 lines
2.3 KiB
C#
106 lines
2.3 KiB
C#
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class MapController : MonoBehaviour
|
|
{
|
|
private static MapController instance;
|
|
|
|
public GameObject mapParent;
|
|
|
|
public GameObject mapParentNormal;
|
|
|
|
public GameObject mapParentIce;
|
|
|
|
public List<Text> infoTexts = new List<Text>();
|
|
|
|
public List<MapButton> mapButtons = new List<MapButton>();
|
|
|
|
[HideInInspector]
|
|
public bool initialized;
|
|
|
|
public static MapController Instance
|
|
{
|
|
get
|
|
{
|
|
return instance;
|
|
}
|
|
}
|
|
|
|
private MapController()
|
|
{
|
|
}
|
|
|
|
private void Awake()
|
|
{
|
|
if (instance == null)
|
|
{
|
|
instance = this;
|
|
}
|
|
}
|
|
|
|
public void Initialize()
|
|
{
|
|
if (mapParent == null)
|
|
{
|
|
mapParent = ((!GameController.Instance.iceLevel) ? mapParentNormal : mapParentIce);
|
|
mapParentNormal.SetActive(!GameController.Instance.iceLevel);
|
|
mapParentIce.SetActive(GameController.Instance.iceLevel);
|
|
}
|
|
mapButtons = mapParent.transform.GetComponentsInChildren<MapButton>(true).ToDynList();
|
|
for (int i = 0; i < mapButtons.Count; i++)
|
|
{
|
|
mapButtons[i].mapController = this;
|
|
mapButtons[i].button = mapButtons[i].GetComponent<Button>();
|
|
}
|
|
ShowMap(false);
|
|
initialized = true;
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
if (!GlobalSettings.Instance && Input.GetKeyDown(KeyCode.M))
|
|
{
|
|
ShowMap(!mapParent.activeSelf);
|
|
}
|
|
}
|
|
|
|
public void ShowMapFromButton(bool show)
|
|
{
|
|
ShowMap(show, true);
|
|
}
|
|
|
|
public void ShowMap(bool show, bool invokeMenuMethod = false)
|
|
{
|
|
if (mapParent == null || mapParent.activeSelf == show)
|
|
{
|
|
return;
|
|
}
|
|
mapParent.SetActive(show);
|
|
if ((bool)MenuManager.Instance && !show && invokeMenuMethod)
|
|
{
|
|
MenuManager.Instance.ShowMap(false);
|
|
}
|
|
if (show)
|
|
{
|
|
FishingPlayer fishingPlayer = GameController.Instance.fishingPlayer;
|
|
bool flag = (fishingPlayer.currentState == FishingPlayer.PlayerState.FISHING || fishingPlayer.currentState == FishingPlayer.PlayerState.NORMAL) && (!fishingPlayer.currentHands.baitWasThrown || GameController.Instance.iceLevel) && !fishingPlayer.boatSimulator;
|
|
for (int i = 0; i < infoTexts.Count; i++)
|
|
{
|
|
infoTexts[i].gameObject.SetActive(!flag);
|
|
}
|
|
for (int j = 0; j < mapButtons.Count; j++)
|
|
{
|
|
mapButtons[j].button.interactable = flag;
|
|
}
|
|
}
|
|
}
|
|
|
|
public void Travel(Transform travelPosition)
|
|
{
|
|
StartCoroutine(GameController.Instance.QuickJumpMap(travelPosition));
|
|
ShowMap(false);
|
|
HUDManager.Instance.Resume();
|
|
}
|
|
}
|