437 lines
13 KiB
C#
437 lines
13 KiB
C#
using System;
|
|
using Steamworks;
|
|
using UFS2.Gameplay;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class FishCatchPanel : MonoBehaviour
|
|
{
|
|
private class FishEmit
|
|
{
|
|
public string fishName;
|
|
|
|
public string fishSpecies;
|
|
|
|
public string fishWeight;
|
|
}
|
|
|
|
public enum CounterStage
|
|
{
|
|
Cash = 0,
|
|
BoostCash = 1,
|
|
Exp = 2,
|
|
BoostExp = 3,
|
|
Done = 4
|
|
}
|
|
|
|
public Text fishNameText;
|
|
|
|
public Text fishWeightText;
|
|
|
|
public Text fishLengthText;
|
|
|
|
public Text fishPriceText;
|
|
|
|
public Text fishExpText;
|
|
|
|
public Text fightTimeText;
|
|
|
|
public Text newRecordText;
|
|
|
|
public Text incomeExpKeepText;
|
|
|
|
public Text incomeExpText;
|
|
|
|
public float counterSpeed = 10f;
|
|
|
|
[HideInInspector]
|
|
public FPlayer playerMain;
|
|
|
|
private AudioSource audioSource;
|
|
|
|
public Texture2D rotateCamFishCursor;
|
|
|
|
private float fishObjectRot;
|
|
|
|
public int fishID = -1;
|
|
|
|
public float fishWeight;
|
|
|
|
public float fishFightTime;
|
|
|
|
public GameObject[] SoundsFishBtn;
|
|
|
|
public GameObject personalRecordImage;
|
|
|
|
public Text boostCashText;
|
|
|
|
public Text boostExpText;
|
|
|
|
private float boostCashTime;
|
|
|
|
private float boostExpTime;
|
|
|
|
public CounterStage counterStage;
|
|
|
|
private float dstCashValue;
|
|
|
|
private float currentCashValue;
|
|
|
|
private float dstExpValue;
|
|
|
|
private float currentExpValue;
|
|
|
|
public Button keepBtn;
|
|
|
|
public Button releaseBtn;
|
|
|
|
public FishNetStars netStars;
|
|
|
|
private HalloweenQuestManager halloweenQuest;
|
|
|
|
private ChristmasEventManager christmasQuest;
|
|
|
|
public Image fishNetProgressBar;
|
|
|
|
public Text fishnetProgressText;
|
|
|
|
public Text fishnetLevelText;
|
|
|
|
public Text fishnetNextLevelText;
|
|
|
|
public static event Action OnFishKeepGlobal;
|
|
|
|
public static event Action OnFishReleaseGlobal;
|
|
|
|
public void Initialize()
|
|
{
|
|
GameManager.Instance.fishCatchPanel = this;
|
|
playerMain.firstPersonController.m_Input = Vector2.zero;
|
|
if ((bool)FScriptsHandler.Instance.m_chatManager)
|
|
{
|
|
FScriptsHandler.Instance.m_chatManager.gameObject.SetActive(value: false);
|
|
}
|
|
halloweenQuest = UnityEngine.Object.FindObjectOfType<HalloweenQuestManager>();
|
|
audioSource = GetComponent<AudioSource>();
|
|
boostCashText.gameObject.SetActive(value: false);
|
|
boostExpText.gameObject.SetActive(value: false);
|
|
boostCashTime = Singleton<SaveDataManager>.Instance.GetCurrentPlayerData().TimeBoostCash;
|
|
boostExpTime = Singleton<SaveDataManager>.Instance.GetCurrentPlayerData().TimeBoostExp;
|
|
FScriptsHandler.Instance.m_PlayerMain.m_Camera.transform.localEulerAngles = Vector3.zero;
|
|
int iD = FishEntity.CurrentFishInFight.Data.ID;
|
|
GameManager.FishSpecies species = FishEntity.CurrentFishInFight.Data.Species;
|
|
float weight = FishEntity.CurrentFishInFight.Weight;
|
|
float fightTime = FishEntity.CurrentFishInFight.FightTime;
|
|
dstCashValue = GameManager.Instance.GetFishPrice(iD, weight);
|
|
dstExpValue = GameManager.Instance.GetFishExp(iD, weight);
|
|
if (dstExpValue < 1f)
|
|
{
|
|
dstExpValue = 1f;
|
|
}
|
|
fishNameText.text = GameManager.Instance.gameFish[iD].GetFishName();
|
|
fishWeightText.text = GameManager.Instance.ConvertWeight(weight).ToString();
|
|
fishLengthText.text = GameManager.Instance.ConvertWeightFishToLengthWithUnit(species, weight);
|
|
netStars.SetStarsByFishWeight((GameManager.FishSpecies)iD, weight);
|
|
fishPriceText.text = "$ 0";
|
|
incomeExpKeepText.text = "0 EXP";
|
|
fishExpText.text = "0 EXP";
|
|
incomeExpText.text = "0 XP";
|
|
newRecordText.text = "";
|
|
fightTimeText.text = GameManager.Instance.FormatTimeSeconds(fightTime);
|
|
GameManager.Instance._playerData.AddFishAmount();
|
|
Singleton<SaveDataManager>.Instance.GetCurrentPlayerData().TotalFishWeight += weight;
|
|
SetAchivmentZombieFish();
|
|
fishNetProgressBar.fillAmount = (float)Singleton<SaveDataManager>.Instance.GetCurrentPlayerData().PlayerFishNetExp / (float)GameManager.Instance._playerData.fishNetMaxExp[Singleton<SaveDataManager>.Instance.GetCurrentPlayerData().PlayerFishNetLevel - 1];
|
|
fishnetProgressText.text = Singleton<SaveDataManager>.Instance.GetCurrentPlayerData().PlayerFishNetExp + "/" + GameManager.Instance._playerData.fishNetMaxExp[Singleton<SaveDataManager>.Instance.GetCurrentPlayerData().PlayerFishNetLevel - 1];
|
|
fishnetLevelText.text = GameManager.Instance._playerData.GetFishNetCapacity() + "kg";
|
|
fishnetNextLevelText.text = GameManager.Instance._playerData.GetFishNetNextCapacity() + "kg";
|
|
GameManager.Instance._playerData.AddFishNetExp(weight);
|
|
Invoke("AddFishTournament", 0.5f);
|
|
if (GameManager.Instance.CheckFishReccord(iD, weight))
|
|
{
|
|
newRecordText.text = LanguageManager.Instance.GetText("NEW_PERSONAL_RECORD");
|
|
personalRecordImage.SetActive(value: true);
|
|
}
|
|
if (playerMain.currentRod.currentFloat != null && !Singleton<SaveDataManager>.Instance.IsCurrentlySandbox() && SteamUserStats.GetAchievement("FLOAT_CATCH_ACHIEVEMENT", out var pbAchieved) && !pbAchieved && SteamUserStats.SetAchievement("FLOAT_CATCH_ACHIEVEMENT"))
|
|
{
|
|
SteamUserStats.StoreStats();
|
|
}
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
if ((bool)TutorialManager.Instance)
|
|
{
|
|
if (!TutorialManager.Instance.tutUpdateBool && TutorialManager.Instance.acctualLessonIndex == 8)
|
|
{
|
|
keepBtn.interactable = false;
|
|
}
|
|
if (!TutorialManager.Instance.tutUpdateBool && TutorialManager.Instance.acctualLessonIndex == 11)
|
|
{
|
|
releaseBtn.interactable = false;
|
|
}
|
|
if (GameManager.Instance.player.GetButtonDown("LB"))
|
|
{
|
|
if (TutorialManager.Instance.acctualLessonIndex == 8)
|
|
{
|
|
return;
|
|
}
|
|
KeepButton();
|
|
}
|
|
if (GameManager.Instance.player.GetButtonDown("RB") && TutorialManager.Instance.acctualLessonIndex != 11)
|
|
{
|
|
ReleaseButton();
|
|
}
|
|
return;
|
|
}
|
|
if (GameManager.Instance.player.GetButtonDown("LB"))
|
|
{
|
|
KeepButton();
|
|
}
|
|
if (GameManager.Instance.player.GetButtonDown("RB"))
|
|
{
|
|
ReleaseButton();
|
|
}
|
|
CounterValues(counterStage);
|
|
if ((bool)TutorialManager.Instance)
|
|
{
|
|
if (!TutorialManager.Instance.tutUpdateBool && TutorialManager.Instance.acctualLessonIndex == 8)
|
|
{
|
|
keepBtn.interactable = false;
|
|
}
|
|
if (!TutorialManager.Instance.tutUpdateBool && TutorialManager.Instance.acctualLessonIndex == 11)
|
|
{
|
|
releaseBtn.interactable = false;
|
|
}
|
|
}
|
|
}
|
|
|
|
private void AddFishTournament()
|
|
{
|
|
if (GameManager.Instance.currentSceneLoadedType == GameManager.SceneLoadedType.Tournament && (bool)TournamentManager.Instance)
|
|
{
|
|
int iD = FishEntity.CurrentFishInFight.Data.ID;
|
|
float weight = FishEntity.CurrentFishInFight.Weight;
|
|
TournamentManager.Instance.AddFishTournament((GameManager.FishSpecies)iD, weight, FScriptsHandler.Instance.m_PlayerMain, FScriptsHandler.Instance.m_SceneSettings.sceneID);
|
|
}
|
|
}
|
|
|
|
private void CounterValues(CounterStage stage)
|
|
{
|
|
int iD = FishEntity.CurrentFishInFight.Data.ID;
|
|
float weight = FishEntity.CurrentFishInFight.Weight;
|
|
if (audioSource == null)
|
|
{
|
|
audioSource = GetComponent<AudioSource>();
|
|
}
|
|
switch (stage)
|
|
{
|
|
case CounterStage.Cash:
|
|
currentCashValue = Mathf.Clamp(GameManager.Instance.GetFishPrice(iD, weight), 1f, GameManager.Instance.GetFishPrice(iD, weight));
|
|
if (!audioSource.isPlaying)
|
|
{
|
|
audioSource.Play();
|
|
}
|
|
if (boostCashTime > Time.time)
|
|
{
|
|
counterStage = CounterStage.BoostCash;
|
|
}
|
|
else
|
|
{
|
|
counterStage = CounterStage.Exp;
|
|
}
|
|
break;
|
|
case CounterStage.BoostCash:
|
|
if (!boostCashText.gameObject.activeSelf)
|
|
{
|
|
dstCashValue = currentCashValue + currentCashValue * 0.25f;
|
|
boostCashText.gameObject.SetActive(value: true);
|
|
boostCashText.text = "+ " + (currentCashValue * 0.25f).ToString("F2");
|
|
}
|
|
currentCashValue = GameManager.Instance.GetFishPrice(iD, weight);
|
|
if (!audioSource.isPlaying)
|
|
{
|
|
audioSource.Play();
|
|
}
|
|
counterStage = CounterStage.Exp;
|
|
break;
|
|
case CounterStage.Exp:
|
|
if (dstExpValue < 1f)
|
|
{
|
|
dstExpValue = 1f;
|
|
}
|
|
currentExpValue = dstExpValue;
|
|
if (!audioSource.isPlaying)
|
|
{
|
|
audioSource.Play();
|
|
}
|
|
if (boostExpTime > Time.time || GameManager.Instance.GetFishExpFromEquipment(iD, weight) > 0f)
|
|
{
|
|
counterStage = CounterStage.BoostExp;
|
|
}
|
|
else
|
|
{
|
|
counterStage = CounterStage.Done;
|
|
}
|
|
break;
|
|
case CounterStage.BoostExp:
|
|
if (!boostExpText.gameObject.activeSelf)
|
|
{
|
|
float num = 0f;
|
|
if (boostExpTime > Time.time)
|
|
{
|
|
num = currentExpValue * 0.25f;
|
|
}
|
|
num += GameManager.Instance.GetFishExpFromEquipment(iD, weight);
|
|
num = Mathf.Ceil(num);
|
|
dstExpValue = currentExpValue + num;
|
|
boostExpText.gameObject.SetActive(value: true);
|
|
boostExpText.text = "+ " + num.ToString("F0");
|
|
}
|
|
currentExpValue = dstExpValue;
|
|
if (!audioSource.isPlaying)
|
|
{
|
|
audioSource.Play();
|
|
}
|
|
counterStage = CounterStage.Done;
|
|
break;
|
|
case CounterStage.Done:
|
|
if (audioSource.isPlaying)
|
|
{
|
|
audioSource.Stop();
|
|
}
|
|
return;
|
|
}
|
|
if (long.Parse(currentCashValue.ToString("F0")) > 1000)
|
|
{
|
|
fishPriceText.text = "$ " + GameManager.Instance.formatNumber(long.Parse(currentCashValue.ToString("F0")));
|
|
}
|
|
else
|
|
{
|
|
fishPriceText.text = "$ " + currentCashValue.ToString("F2");
|
|
}
|
|
fishExpText.text = currentExpValue.ToString("F2") + " EXP";
|
|
if (currentExpValue > 1000f)
|
|
{
|
|
incomeExpKeepText.text = GameManager.Instance.formatNumber(long.Parse(currentExpValue.ToString("F0"))) + " EXP";
|
|
incomeExpText.text = GameManager.Instance.formatNumber(long.Parse(Mathf.Ceil(currentExpValue * 1.5f).ToString("F0"))) + " XP";
|
|
}
|
|
else
|
|
{
|
|
incomeExpKeepText.text = currentExpValue.ToString("F2") + " EXP";
|
|
incomeExpText.text = Mathf.Ceil(currentExpValue * 1.5f).ToString("F2") + " XP";
|
|
}
|
|
}
|
|
|
|
public void PlaySoundBtn(int index)
|
|
{
|
|
UnityEngine.Object.Instantiate(SoundsFishBtn[index]);
|
|
}
|
|
|
|
public void KeepButton()
|
|
{
|
|
if ((bool)FishEntity.CurrentFishInFight)
|
|
{
|
|
int iD = FishEntity.CurrentFishInFight.Data.ID;
|
|
float weight = FishEntity.CurrentFishInFight.Weight;
|
|
float fishPrice = GameManager.Instance.GetFishPrice(iD, weight);
|
|
if (!GameManager.Instance._playerData.AddFishToFishNet((GameManager.FishSpecies)iD, weight, fishPrice))
|
|
{
|
|
GameManager.Instance.CreateMessageBox("FISHNET_ISFULL", base.transform.parent, 8);
|
|
return;
|
|
}
|
|
float fishExp = GameManager.Instance.GetFishExp(iD, weight);
|
|
GameManager.Instance._playerData.AddSubPlayerExp(fishExp);
|
|
GameManager.Instance._playerData.AddFishToQuest((GameManager.FishSpecies)iD, weight);
|
|
if ((bool)halloweenQuest)
|
|
{
|
|
halloweenQuest.CheckHalloweenFish((GameManager.FishSpecies)iD);
|
|
}
|
|
FishCatchPanel.OnFishKeepGlobal?.Invoke();
|
|
int num = Mathf.RoundToInt(weight) * GameManager.Instance.gameFish[iD].rankingPoint;
|
|
if (num < 1)
|
|
{
|
|
num = 1;
|
|
}
|
|
if (SteamManager.Initialized && !Singleton<SaveDataManager>.Instance.IsCurrentlySandbox())
|
|
{
|
|
ServerManager.Instance.AddFishToRankings((GameManager.FishSpecies)iD, weight, num, FScriptsHandler.Instance.m_SceneSettings.sceneID);
|
|
ChatBackendPUN.Instance.SendMessageFishCatch(iD, weight);
|
|
}
|
|
}
|
|
if ((bool)TutorialManager.Instance && !TutorialManager.Instance.tutUpdateBool && TutorialManager.Instance.acctualLessonIndex == 11)
|
|
{
|
|
TutorialManager.Instance.FishCatchPanelInvoke();
|
|
}
|
|
FScriptsHandler.Instance.m_HudManager.ShowHideFishCatchPanel(visable: false);
|
|
}
|
|
|
|
public void ReleaseButton()
|
|
{
|
|
if ((bool)FishEntity.CurrentFishInFight)
|
|
{
|
|
int iD = FishEntity.CurrentFishInFight.Data.ID;
|
|
float weight = FishEntity.CurrentFishInFight.Weight;
|
|
GameManager.Instance.GetFishPrice(iD, weight);
|
|
float value = Mathf.Ceil(GameManager.Instance.GetFishExp(iD, weight) * 1.5f);
|
|
GameManager.Instance._playerData.AddSubPlayerExp(value);
|
|
GameManager.Instance._playerData.AddFishToQuest((GameManager.FishSpecies)iD, weight);
|
|
int num = Mathf.RoundToInt(weight) * GameManager.Instance.gameFish[iD].rankingPoint;
|
|
if (num < 1)
|
|
{
|
|
num = 1;
|
|
}
|
|
if (SteamManager.Initialized && !Singleton<SaveDataManager>.Instance.IsCurrentlySandbox())
|
|
{
|
|
ServerManager.Instance.AddFishToRankings((GameManager.FishSpecies)iD, weight, num, FScriptsHandler.Instance.m_SceneSettings.sceneID);
|
|
ChatBackendPUN.Instance.SendMessageFishCatch(iD, weight);
|
|
}
|
|
FishCatchPanel.OnFishReleaseGlobal?.Invoke();
|
|
}
|
|
FScriptsHandler.Instance.m_HudManager.ShowHideFishCatchPanel(visable: false);
|
|
}
|
|
|
|
public void SetMouseCursor(bool isRotate)
|
|
{
|
|
if (isRotate)
|
|
{
|
|
Cursor.SetCursor(rotateCamFishCursor, Vector2.zero, CursorMode.Auto);
|
|
}
|
|
else
|
|
{
|
|
Cursor.SetCursor(null, Vector2.zero, CursorMode.Auto);
|
|
}
|
|
}
|
|
|
|
private void OnDestroy()
|
|
{
|
|
if (!GameManager.Instance.currentLevelPopUp)
|
|
{
|
|
FScriptsHandler.Instance.m_PlayerMain.firstPersonController.UnFrezzeLook();
|
|
}
|
|
GameManager.Instance.fishCatchPanel = null;
|
|
try
|
|
{
|
|
if ((bool)FScriptsHandler.Instance.m_chatManager)
|
|
{
|
|
FScriptsHandler.Instance.m_chatManager.gameObject.SetActive(value: true);
|
|
}
|
|
}
|
|
catch
|
|
{
|
|
return;
|
|
}
|
|
FScriptsHandler.Instance.m_PlayerMain.DestroyFishViewAngler(fromPanel: true);
|
|
}
|
|
|
|
private void SetAchivmentZombieFish()
|
|
{
|
|
int iD = FishEntity.CurrentFishInFight.Data.ID;
|
|
_ = FishEntity.CurrentFishInFight.Weight;
|
|
if (iD == 68 && !Singleton<SaveDataManager>.Instance.IsCurrentlySandbox() && Singleton<SaveDataManager>.Instance.GetCurrentPlayerData().TotalZombiesFish >= 35 && SteamUserStats.GetAchievement("FISH_OR_TRICK", out var pbAchieved) && !pbAchieved && SteamUserStats.SetAchievement("FISH_OR_TRICK"))
|
|
{
|
|
SteamUserStats.StoreStats();
|
|
}
|
|
}
|
|
}
|