261 lines
7.5 KiB
C#
261 lines
7.5 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using Obvious.Soap;
|
|
using Steamworks;
|
|
using UnityEngine;
|
|
using UnityEngine.SceneManagement;
|
|
using UnityEngine.UI;
|
|
using _Data.Variabales.DayWeather;
|
|
|
|
public class FreeFishing : MonoBehaviour
|
|
{
|
|
public GameObject levelLockedGameObject;
|
|
|
|
public Text levelLockedText;
|
|
|
|
[SerializeField]
|
|
private Image isNewImage;
|
|
|
|
[SerializeField]
|
|
private Image isCommingSoonImage;
|
|
|
|
public GameObject licenceLockedGameObject;
|
|
|
|
public Text licenceLockedText;
|
|
|
|
private bool isBuyLicenceReq;
|
|
|
|
public Transform canvasTransform;
|
|
|
|
public Text mapNameText;
|
|
|
|
public Image screenImage;
|
|
|
|
public Text mapDescriptionText;
|
|
|
|
public Button goFishingBtn;
|
|
|
|
public Button goMultiplayerBtn;
|
|
|
|
public Hover[] locationSelectionIcons;
|
|
|
|
public IntVariable currentMapSelectionIndex;
|
|
|
|
public Transform weatherSettingsContent;
|
|
|
|
public Dropdown TimeOfDayDropDown;
|
|
|
|
public Dropdown WeatherDropDown;
|
|
|
|
public GameObject tutorialMapSelectIcon;
|
|
|
|
[SerializeField]
|
|
private ScriptableEnumWeatherType weather;
|
|
|
|
[SerializeField]
|
|
private ScriptableTimeDayVariable dayTime;
|
|
|
|
public static event Action OnGoToMultiplayer;
|
|
|
|
private void Start()
|
|
{
|
|
ShowMapSelection(0);
|
|
}
|
|
|
|
private void OnEnable()
|
|
{
|
|
SetupDropdownWeatherAndTimeDay();
|
|
if ((int)currentMapSelectionIndex == -1)
|
|
{
|
|
return;
|
|
}
|
|
if (Singleton<SaveDataManager>.Instance.GetCurrentPlayerData().GameMode == GameManager.PlayerData.CPlayer.GameMode.Realistic)
|
|
{
|
|
if ((int)currentMapSelectionIndex == 7)
|
|
{
|
|
ShowMapSelection(0);
|
|
}
|
|
tutorialMapSelectIcon.SetActive(value: false);
|
|
}
|
|
else
|
|
{
|
|
tutorialMapSelectIcon.SetActive(value: true);
|
|
}
|
|
ShowMapSelection(currentMapSelectionIndex);
|
|
}
|
|
|
|
private void SetSelectIcon(int indexMap)
|
|
{
|
|
for (int i = 0; i < locationSelectionIcons.Length; i++)
|
|
{
|
|
if (i == indexMap)
|
|
{
|
|
locationSelectionIcons[indexMap].isSelected = true;
|
|
}
|
|
else
|
|
{
|
|
locationSelectionIcons[i].isSelected = false;
|
|
}
|
|
}
|
|
}
|
|
|
|
public void ShowMapSelection(int indexMap)
|
|
{
|
|
SetSelectIcon(indexMap);
|
|
levelLockedGameObject.SetActive(value: false);
|
|
licenceLockedGameObject.SetActive(value: false);
|
|
screenImage.gameObject.SetActive(value: false);
|
|
Sprite screenMapImage = GameManager.Instance.gameLocations[indexMap].GetScreenMapImage(0);
|
|
screenImage.sprite = screenMapImage;
|
|
mapNameText.text = GameManager.Instance.gameLocations[indexMap].name.ToUpper();
|
|
mapDescriptionText.text = GameManager.Instance.gameLocations[indexMap].GetDescriptionLocationWithFish();
|
|
bool flag = false;
|
|
isBuyLicenceReq = false;
|
|
if (GameManager.Instance.gameLocations[indexMap].isNew)
|
|
{
|
|
isNewImage.enabled = true;
|
|
}
|
|
else
|
|
{
|
|
isNewImage.enabled = false;
|
|
}
|
|
if (GameManager.Instance.gameLocations[indexMap].isCommingSoon)
|
|
{
|
|
isCommingSoonImage.enabled = true;
|
|
}
|
|
else
|
|
{
|
|
isCommingSoonImage.enabled = false;
|
|
}
|
|
goFishingBtn.GetComponentInChildren<Text>().text = LanguageManager.Instance.GetText("GO_FISHING");
|
|
if (indexMap == 7 || indexMap == 8 || indexMap == 9)
|
|
{
|
|
weatherSettingsContent.gameObject.SetActive(value: false);
|
|
}
|
|
else
|
|
{
|
|
weatherSettingsContent.gameObject.SetActive(value: true);
|
|
}
|
|
if (!GameManager.Instance.isDevModeAllowed)
|
|
{
|
|
if (Singleton<SaveDataManager>.Instance.GetCurrentPlayerData().PlayerLevel < GameManager.Instance.gameLocations[indexMap].levelrequired)
|
|
{
|
|
flag = false;
|
|
levelLockedGameObject.SetActive(value: true);
|
|
string text = LanguageManager.Instance.GetText("MAP_LEVEL_REQUIRED").Replace("{LEVEL}", GameManager.Instance.gameLocations[indexMap].levelrequired.ToString());
|
|
levelLockedText.text = text;
|
|
}
|
|
else if (!GameManager.Instance._playerData.CheckLicences(indexMap) && GameManager.Instance.gameLocations[indexMap].licensePrize > 0)
|
|
{
|
|
flag = false;
|
|
licenceLockedGameObject.SetActive(value: true);
|
|
string text2 = LanguageManager.Instance.GetText("MAP_LICENCE_COST").Replace("{COST}", GameManager.Instance.gameLocations[indexMap].licensePrize.ToString());
|
|
licenceLockedText.text = text2;
|
|
isBuyLicenceReq = true;
|
|
goFishingBtn.GetComponentInChildren<Text>().text = LanguageManager.Instance.GetText("BUY_LICENCE");
|
|
}
|
|
else if (!GameManager.Instance.gameLocations[indexMap].isEnabled)
|
|
{
|
|
flag = false;
|
|
levelLockedText.text = "";
|
|
}
|
|
else
|
|
{
|
|
flag = true;
|
|
levelLockedGameObject.SetActive(value: false);
|
|
}
|
|
}
|
|
else if (GameManager.Instance.isDevModeAllowed)
|
|
{
|
|
flag = true;
|
|
levelLockedGameObject.SetActive(value: false);
|
|
}
|
|
if (!flag && !isBuyLicenceReq)
|
|
{
|
|
goFishingBtn.interactable = false;
|
|
}
|
|
else
|
|
{
|
|
goFishingBtn.interactable = true;
|
|
}
|
|
goMultiplayerBtn.gameObject.SetActive(indexMap != 7 && indexMap != 8 && indexMap != 9);
|
|
if (goMultiplayerBtn.gameObject.activeInHierarchy)
|
|
{
|
|
goMultiplayerBtn.interactable = flag && !isBuyLicenceReq;
|
|
Hover component = goMultiplayerBtn.GetComponent<Hover>();
|
|
if (component != null)
|
|
{
|
|
component.isSelected = false;
|
|
component.UnSelect();
|
|
}
|
|
}
|
|
currentMapSelectionIndex.Value = indexMap;
|
|
screenImage.gameObject.SetActive(value: true);
|
|
SetupDropdownWeatherAndTimeDay();
|
|
}
|
|
|
|
private void SetupDropdownWeatherAndTimeDay()
|
|
{
|
|
if ((int)currentMapSelectionIndex != 8)
|
|
{
|
|
TimeOfDayDropDown.ClearOptions();
|
|
WeatherDropDown.ClearOptions();
|
|
List<string> list = new List<string>();
|
|
List<string> list2 = new List<string>();
|
|
list.Add(LanguageManager.Instance.GetText("WEATHER_CLEAR"));
|
|
list.Add(LanguageManager.Instance.GetText("WEATHER_CLOUDY"));
|
|
list.Add(LanguageManager.Instance.GetText("WEATHER_OVERCAST"));
|
|
list.Add(LanguageManager.Instance.GetText("WEATHER_LIGHTRAIN"));
|
|
list.Add(LanguageManager.Instance.GetText("WEATHER_MEDIUMRAIN"));
|
|
list.Add(LanguageManager.Instance.GetText("WEATHER_STORM"));
|
|
list2.Add(LanguageManager.Instance.GetText("TIMEOFDAY_MORNING"));
|
|
list2.Add(LanguageManager.Instance.GetText("TIMEOFDAY_NOON"));
|
|
list2.Add(LanguageManager.Instance.GetText("TIMEOFDAY_EVENING"));
|
|
list2.Add(LanguageManager.Instance.GetText("TIMEOFDAY_NIGHT"));
|
|
WeatherDropDown.AddOptions(list);
|
|
TimeOfDayDropDown.AddOptions(list2);
|
|
WeatherDropDown.value = weather.GetWeatherId();
|
|
TimeOfDayDropDown.value = (int)dayTime.GetTimeOfDayFromHour();
|
|
}
|
|
}
|
|
|
|
public void OnChangeTimeDayAndWeather()
|
|
{
|
|
weather.SetWeather(TimeOfDayDropDown.value);
|
|
dayTime.SetDayTime((TimeOfDay)TimeOfDayDropDown.value);
|
|
}
|
|
|
|
public void OnMultiplayerClick()
|
|
{
|
|
FreeFishing.OnGoToMultiplayer?.Invoke();
|
|
}
|
|
|
|
public void LoadMap()
|
|
{
|
|
OnChangeTimeDayAndWeather();
|
|
if (!isBuyLicenceReq)
|
|
{
|
|
if ((int)currentMapSelectionIndex == 4 && !Singleton<SaveDataManager>.Instance.IsCurrentlySandbox() && SteamUserStats.GetAchievement("LETNISKO_UNLOCK_ACHIEVEMENT", out var pbAchieved) && !pbAchieved && SteamUserStats.SetAchievement("LETNISKO_UNLOCK_ACHIEVEMENT"))
|
|
{
|
|
SteamUserStats.StoreStats();
|
|
}
|
|
GameManager.Instance.currentSceneLoadedType = GameManager.SceneLoadedType.FreeFishing;
|
|
GameManager.Instance.LoadScene(GameManager.Instance.gameLocations[(int)currentMapSelectionIndex].sceneName);
|
|
}
|
|
else if (GameManager.Instance._playerData.BuyLicence(currentMapSelectionIndex))
|
|
{
|
|
ShowMapSelection(currentMapSelectionIndex);
|
|
}
|
|
else
|
|
{
|
|
GameManager.Instance.ShowMessagePopup(LanguageManager.Instance.GetText("BUY_LICENCE_CASH_NOT_ENOUGH"), UnityEngine.Object.FindObjectOfType<MainGameScene>().transform, deleteLast: true);
|
|
}
|
|
}
|
|
|
|
public void LoadMapByIndex(int indexMap)
|
|
{
|
|
GameManager.Instance.currentSceneLoadedType = GameManager.SceneLoadedType.FreeFishing;
|
|
SceneManager.LoadScene(indexMap);
|
|
}
|
|
}
|