803 lines
25 KiB
C#
803 lines
25 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using BitStrap;
|
|
using CodeStage.AntiCheat.ObscuredTypes;
|
|
using I2.Loc;
|
|
using UnityEngine;
|
|
|
|
public class PlayerSettingsMy : MonoBehaviour
|
|
{
|
|
public enum Difficulty
|
|
{
|
|
CASUAL = 0,
|
|
SIMULATOR = 1,
|
|
SANDBOX = 2
|
|
}
|
|
|
|
[HideInInspector]
|
|
public bool wasInLevelScene;
|
|
|
|
[HideInInspector]
|
|
public bool firstMenuEnter = true;
|
|
|
|
public string playersName = string.Empty;
|
|
|
|
public ObscuredInt playersScore = 0;
|
|
|
|
public ObscuredInt playersMoney = 0;
|
|
|
|
public ObscuredInt playersExperience = 0;
|
|
|
|
public ObscuredInt playersLevel = 1;
|
|
|
|
public ObscuredFloat playersLuck = 0.33f;
|
|
|
|
public ObscuredFloat playersStrength = 0.33f;
|
|
|
|
public Difficulty tempDifficulty;
|
|
|
|
public Difficulty difficulty;
|
|
|
|
public ObscuredInt difficultyObscured = 0;
|
|
|
|
[Header("Settings")]
|
|
public bool imperialUnits;
|
|
|
|
public bool showBaitIndicator = true;
|
|
|
|
public bool showHookPrompt = true;
|
|
|
|
public bool manualFishingNet = true;
|
|
|
|
public bool showFloatWindow = true;
|
|
|
|
public float floatSizeMultiplier;
|
|
|
|
public float invertYAxis = 1f;
|
|
|
|
public float mouseSensitivity = 1f;
|
|
|
|
public bool gamepadVibration = true;
|
|
|
|
public bool showIngameControls = true;
|
|
|
|
public bool newChangelog;
|
|
|
|
public bool showMultiplayerAvatars = true;
|
|
|
|
public HUDFishing.TensionWidgetType tensionWidgetType;
|
|
|
|
public bool headBob = true;
|
|
|
|
[ReadOnly]
|
|
[Header("Editor")]
|
|
public bool editorUnderwaterEffect = true;
|
|
|
|
[Header("Experience")]
|
|
public ObscuredInt playersStartMoney = 150;
|
|
|
|
public ObscuredInt maxPlayerLevel = 20;
|
|
|
|
public ObscuredInt maxPlayerLevelPrices = 20;
|
|
|
|
public List<ObscuredInt> expLevels = new List<ObscuredInt>();
|
|
|
|
public List<ObscuredInt> expDiffs = new List<ObscuredInt>();
|
|
|
|
public ObscuredFloat expStartDiff = 100f;
|
|
|
|
public ObscuredFloat diffStartValue = 1.5f;
|
|
|
|
public ObscuredFloat diffSmoothValue = 0.995f;
|
|
|
|
[Space(10f)]
|
|
public ObscuredInt fishKgExp = 16;
|
|
|
|
public ObscuredInt fishKgMoney = 10;
|
|
|
|
public ObscuredFloat luckIncrease = 0.05f;
|
|
|
|
public ObscuredFloat strengthIncrease = 0.05f;
|
|
|
|
[HideInInspector]
|
|
public ObscuredInt versionNumber = 1000;
|
|
|
|
[HideInInspector]
|
|
public SkillsManager skillsManager;
|
|
|
|
private float scoreToFishRatio = 10000f;
|
|
|
|
[Header("Fish Price test")]
|
|
public List<float> fishWeigths = new List<float>();
|
|
|
|
public Vector2 minMaxMoney = new Vector3(3f, 1000f);
|
|
|
|
public Vector2 minMaxExp = new Vector3(2f, 5000f);
|
|
|
|
public float powerMoney = 6f;
|
|
|
|
public float powerExp = 3f;
|
|
|
|
public float realisticMultiplier = 0.75f;
|
|
|
|
private void Start()
|
|
{
|
|
int num = ObscuredPrefs.GetInt("versionNumber", 1000);
|
|
if (num < (int)versionNumber)
|
|
{
|
|
}
|
|
ObscuredPrefs.SetInt("versionNumber", versionNumber);
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
if ((bool)GlobalSettings.Instance && GlobalSettings.Instance.turnOnMyCheats && Input.GetKeyDown(KeyCode.F6))
|
|
{
|
|
UnlockEverythingAndSave(true);
|
|
}
|
|
}
|
|
|
|
public void AddScore(int value)
|
|
{
|
|
if (GlobalSettings.Instance.currentPlatform == GlobalSettings.Platform.ARCADE || IsSandbox())
|
|
{
|
|
return;
|
|
}
|
|
playersScore = (int)playersScore + value;
|
|
LeaderboardsManager.LeaderboardPlayerStats currentLeaderboardPlayerStats = LeaderboardsManager.Instance.GetCurrentLeaderboardPlayerStats(".MAIN.");
|
|
if (currentLeaderboardPlayerStats != null && (int)currentLeaderboardPlayerStats.leaderboardScore != -1)
|
|
{
|
|
LeaderboardsManager.LeaderboardPlayerStats leaderboardPlayerStats = currentLeaderboardPlayerStats;
|
|
leaderboardPlayerStats.leaderboardScore = (int)leaderboardPlayerStats.leaderboardScore + value;
|
|
}
|
|
if ((bool)GameController.Instance)
|
|
{
|
|
currentLeaderboardPlayerStats = LeaderboardsManager.Instance.GetCurrentLeaderboardPlayerStats(GlobalSettings.Instance.levelsManager.GetCurrentFishery().leaderboardName);
|
|
if (currentLeaderboardPlayerStats != null && (int)currentLeaderboardPlayerStats.leaderboardScore != -1)
|
|
{
|
|
LeaderboardsManager.LeaderboardPlayerStats leaderboardPlayerStats2 = currentLeaderboardPlayerStats;
|
|
leaderboardPlayerStats2.leaderboardScore = (int)leaderboardPlayerStats2.leaderboardScore + value;
|
|
}
|
|
}
|
|
if ((int)playersScore < 0)
|
|
{
|
|
playersScore = 0;
|
|
}
|
|
}
|
|
|
|
public void AddMoney(int value)
|
|
{
|
|
if (GlobalSettings.Instance.currentPlatform != GlobalSettings.Platform.ARCADE && !IsSandbox())
|
|
{
|
|
playersMoney = (int)playersMoney + value;
|
|
if ((int)playersMoney < 0)
|
|
{
|
|
playersMoney = 0;
|
|
}
|
|
}
|
|
}
|
|
|
|
public void AddExperience(int value)
|
|
{
|
|
if (GlobalSettings.Instance == null)
|
|
{
|
|
Debug.LogError("GlobalSettings.Instance == null jak to w ogole mozliwe?");
|
|
}
|
|
if (GlobalSettings.Instance.currentPlatform == GlobalSettings.Platform.ARCADE || IsSandbox())
|
|
{
|
|
return;
|
|
}
|
|
playersExperience = (int)playersExperience + value;
|
|
if ((int)playersExperience < 0)
|
|
{
|
|
playersExperience = 0;
|
|
}
|
|
if ((int)playersLevel == (int)maxPlayerLevel)
|
|
{
|
|
return;
|
|
}
|
|
int num = CalculateLevel(playersExperience);
|
|
if ((int)playersLevel != num)
|
|
{
|
|
if ((bool)AchievementManager.Instance)
|
|
{
|
|
AchievementManager.Instance.SetPlayersLevelProgress(num);
|
|
}
|
|
else
|
|
{
|
|
Debug.LogError("AchievementManager.Instance == null");
|
|
}
|
|
if ((bool)GlobalSettings.Instance.skillsManager)
|
|
{
|
|
GlobalSettings.Instance.skillsManager.AddSkillPoints(num - (int)playersLevel);
|
|
}
|
|
else
|
|
{
|
|
Debug.LogError("GlobalSettings.Instance.skillsManager == null");
|
|
}
|
|
playersLevel = num;
|
|
Save();
|
|
}
|
|
}
|
|
|
|
public int GetMoneyUpdated(int value)
|
|
{
|
|
float num = 0f;
|
|
if ((bool)skillsManager.GetSkill(SkillsManager.SkillType.MORE_MONEY_1).isUnlocked)
|
|
{
|
|
num += skillsManager.GetSkill(SkillsManager.SkillType.MORE_MONEY_1).param_1;
|
|
}
|
|
if ((bool)skillsManager.GetSkill(SkillsManager.SkillType.MORE_MONEY_2).isUnlocked)
|
|
{
|
|
num += skillsManager.GetSkill(SkillsManager.SkillType.MORE_MONEY_2).param_1;
|
|
}
|
|
if ((bool)skillsManager.GetSkill(SkillsManager.SkillType.MORE_MONEY_3).isUnlocked)
|
|
{
|
|
num += skillsManager.GetSkill(SkillsManager.SkillType.MORE_MONEY_3).param_1;
|
|
}
|
|
return Mathf.RoundToInt((float)value * (1f - num));
|
|
}
|
|
|
|
public int GetExpUpdated(int value)
|
|
{
|
|
float num = 0f;
|
|
if ((bool)skillsManager.GetSkill(SkillsManager.SkillType.MORE_EXP_1).isUnlocked)
|
|
{
|
|
num += skillsManager.GetSkill(SkillsManager.SkillType.MORE_EXP_1).param_1;
|
|
}
|
|
if ((bool)skillsManager.GetSkill(SkillsManager.SkillType.MORE_EXP_2).isUnlocked)
|
|
{
|
|
num += skillsManager.GetSkill(SkillsManager.SkillType.MORE_EXP_2).param_1;
|
|
}
|
|
if ((bool)skillsManager.GetSkill(SkillsManager.SkillType.MORE_EXP_3).isUnlocked)
|
|
{
|
|
num += skillsManager.GetSkill(SkillsManager.SkillType.MORE_EXP_3).param_1;
|
|
}
|
|
return Mathf.RoundToInt((float)value * (1f + num));
|
|
}
|
|
|
|
public void AddLuck()
|
|
{
|
|
playersLuck = (float)playersLuck + (float)luckIncrease;
|
|
if ((float)playersLuck > 0.6f)
|
|
{
|
|
playersLuck = 0.6f;
|
|
}
|
|
}
|
|
|
|
public void AddStrength()
|
|
{
|
|
playersStrength = (float)playersStrength + (float)strengthIncrease;
|
|
if ((float)playersStrength > 0.6f)
|
|
{
|
|
playersStrength = 0.6f;
|
|
}
|
|
}
|
|
|
|
public int GetThresholdExperience(int level)
|
|
{
|
|
if (level >= expLevels.Count || level < 0)
|
|
{
|
|
Debug.LogError("level >= expLevels.Count " + level + " " + expLevels.Count);
|
|
return 0;
|
|
}
|
|
return expLevels[level];
|
|
}
|
|
|
|
public int CalculateLevel(int experience)
|
|
{
|
|
int num = 1;
|
|
for (int i = 0; i < (int)maxPlayerLevel - 1 && experience >= (int)expLevels[i + 1]; i++)
|
|
{
|
|
num++;
|
|
}
|
|
return num;
|
|
}
|
|
|
|
public bool IsCasual()
|
|
{
|
|
return difficulty == Difficulty.CASUAL || difficulty == Difficulty.SANDBOX;
|
|
}
|
|
|
|
public bool IsSandbox()
|
|
{
|
|
return difficulty == Difficulty.SANDBOX;
|
|
}
|
|
|
|
public void SetImperialUnits(bool imperial)
|
|
{
|
|
imperialUnits = imperial;
|
|
Save();
|
|
}
|
|
|
|
public void SetBaitIndicator(bool show)
|
|
{
|
|
showBaitIndicator = show;
|
|
if ((bool)GameController.Instance)
|
|
{
|
|
GameController.Instance.ShowBaitIndicator(show);
|
|
}
|
|
Save();
|
|
}
|
|
|
|
public void SetHookPrompt(bool show)
|
|
{
|
|
showHookPrompt = show;
|
|
Save();
|
|
}
|
|
|
|
public void SetFloatWindow(bool show)
|
|
{
|
|
showFloatWindow = show;
|
|
if ((bool)GameController.Instance)
|
|
{
|
|
GameController.Instance.ShowFloatWindow(show);
|
|
}
|
|
Save();
|
|
}
|
|
|
|
public void SetFloatSizeMultiplier(float size)
|
|
{
|
|
floatSizeMultiplier = size;
|
|
if ((bool)GameController.Instance)
|
|
{
|
|
GameController.Instance.SetFloatSizeMultiplier(size);
|
|
}
|
|
Save();
|
|
}
|
|
|
|
public void SetMultiplayerAvatars(bool show)
|
|
{
|
|
showMultiplayerAvatars = show;
|
|
if ((bool)MultiplayerManager.Instance)
|
|
{
|
|
MultiplayerManager.Instance.ShowAvatars(show);
|
|
}
|
|
Save();
|
|
}
|
|
|
|
public void SetTensionWidgetType(HUDFishing.TensionWidgetType newType)
|
|
{
|
|
tensionWidgetType = newType;
|
|
if ((bool)GameController.Instance)
|
|
{
|
|
GameController.Instance.SetTensionWidgetType(newType);
|
|
}
|
|
Save();
|
|
}
|
|
|
|
public void SetManualFishingNet(bool manual)
|
|
{
|
|
manualFishingNet = manual;
|
|
if ((bool)GameController.Instance)
|
|
{
|
|
GameController.Instance.manualFishingNet = manualFishingNet;
|
|
}
|
|
Save();
|
|
}
|
|
|
|
public void ToggleUnits()
|
|
{
|
|
SetImperialUnits(!imperialUnits);
|
|
}
|
|
|
|
public void SetInvertYAxis(bool invert)
|
|
{
|
|
invertYAxis = ((!invert) ? 1f : (-1f));
|
|
if ((bool)GameController.Instance)
|
|
{
|
|
GameController.Instance.fishingPlayer.RefreshInputSettings();
|
|
}
|
|
Save();
|
|
}
|
|
|
|
public void SetMouseSensitivity(float sensitivity)
|
|
{
|
|
mouseSensitivity = sensitivity;
|
|
if ((bool)GameController.Instance)
|
|
{
|
|
GameController.Instance.fishingPlayer.RefreshInputSettings();
|
|
}
|
|
Save();
|
|
}
|
|
|
|
public void SetGamepadVibration(bool turnOn)
|
|
{
|
|
gamepadVibration = turnOn;
|
|
UtilitiesInput.StopVibration();
|
|
Save();
|
|
}
|
|
|
|
public void SetHeadBob(bool turnOn)
|
|
{
|
|
headBob = turnOn;
|
|
Save();
|
|
}
|
|
|
|
[Button]
|
|
public void CalculateExperienceLevels()
|
|
{
|
|
float num = diffStartValue;
|
|
expDiffs.Clear();
|
|
expLevels.Clear();
|
|
expDiffs.Capacity = maxPlayerLevel;
|
|
expLevels.Capacity = maxPlayerLevel;
|
|
expDiffs.Add(Mathf.RoundToInt(expStartDiff));
|
|
expLevels.Add(0);
|
|
for (int i = 0; i < (int)maxPlayerLevel - 1; i++)
|
|
{
|
|
expLevels.Add(Mathf.RoundToInt((int)expLevels[i] + (int)expDiffs[i]));
|
|
expDiffs.Add(Mathf.RoundToInt((float)(int)expDiffs[i] * num * 0.1f) * 10);
|
|
num *= (float)diffSmoothValue;
|
|
}
|
|
}
|
|
|
|
public bool CheckStatsIntegrity(LeaderboardsManager.LeaderboardType leaderboardType, string fisheryName, int score, int[] details)
|
|
{
|
|
if (details[6] > details[1])
|
|
{
|
|
Debug.LogError("Cheater: details[(int)LeaderboardsManager.LeaderboardStats.SCORE] > details[(int)LeaderboardsManager.LeaderboardStats.EXP]");
|
|
Debug.LogError("playersScore: " + details[6] + " playersExperience: " + details[1]);
|
|
return false;
|
|
}
|
|
if (details[0] < 1 || details[0] > (int)maxPlayerLevel)
|
|
{
|
|
Debug.LogError("Cheater: details[(int)LeaderboardsManager.LeaderboardStats.LEVEL] > maxPlayerLevel");
|
|
Debug.LogError("playersLevel: " + details[0] + " maxPlayerLevel: " + maxPlayerLevel);
|
|
return false;
|
|
}
|
|
if (details[6] > 0 && details[2] == 0)
|
|
{
|
|
Debug.LogError("Cheater: details[(int)LeaderboardsManager.LeaderboardStats.SCORE] > 0 && details[(int)LeaderboardsManager.LeaderboardStats.FISH_COUNT] == 0");
|
|
Debug.LogError("playersScore: " + details[6] + " fishManager.GetTotalFishCount(): " + details[2]);
|
|
return false;
|
|
}
|
|
Vector2 vector = new Vector2(GetThresholdExperience(details[0] - 1), GetThresholdExperience(details[0]));
|
|
if (vector.y == 0f)
|
|
{
|
|
vector.y = 2.1474836E+09f;
|
|
}
|
|
if ((float)details[1] < vector.x || (float)details[1] > vector.y)
|
|
{
|
|
Debug.LogError("Cheater: GetThresholdExperience() " + details[0] + " " + details[1]);
|
|
Debug.LogError("expThresholds.x: " + vector.x + " expThresholds.y: " + vector.y);
|
|
return false;
|
|
}
|
|
if (leaderboardType == LeaderboardsManager.LeaderboardType.Score && score != details[6])
|
|
{
|
|
Debug.LogError("Cheater: leaderboardType " + leaderboardType);
|
|
Debug.LogError("score: " + score + " details[(int)LeaderboardsManager.LeaderboardStats.SCORE]: " + details[6]);
|
|
return false;
|
|
}
|
|
if (leaderboardType == LeaderboardsManager.LeaderboardType.FishCount && score != details[2])
|
|
{
|
|
Debug.LogError("Cheater: leaderboardType " + leaderboardType);
|
|
Debug.LogError("score: " + score + " details[(int)LeaderboardsManager.LeaderboardStats.FISH_COUNT]: " + details[2]);
|
|
return false;
|
|
}
|
|
if (leaderboardType == LeaderboardsManager.LeaderboardType.FishWeight && score != details[3])
|
|
{
|
|
Debug.LogError("Cheater: leaderboardType " + leaderboardType);
|
|
Debug.LogError("score: " + score + " details[(int)LeaderboardsManager.LeaderboardStats.FISH_WEIGHT]: " + details[3]);
|
|
return false;
|
|
}
|
|
if (leaderboardType == LeaderboardsManager.LeaderboardType.BiggestWeight && score != details[5])
|
|
{
|
|
Debug.LogError("Cheater: leaderboardType " + leaderboardType);
|
|
Debug.LogError("score: " + score + " details[(int)LeaderboardsManager.LeaderboardStats.BIGGEST_WEIGHT]: " + details[5]);
|
|
return false;
|
|
}
|
|
if (leaderboardType == LeaderboardsManager.LeaderboardType.BiggestWeight)
|
|
{
|
|
float num = (float)details[5] * 0.001f;
|
|
if (details[4] < 0 || details[4] >= 144)
|
|
{
|
|
Debug.LogError("Cheater: leaderboardType " + leaderboardType);
|
|
Debug.LogError("score: " + score + " details[(int)LeaderboardsManager.LeaderboardStats.BIGGEST_WEIGHT] 1: " + num);
|
|
return false;
|
|
}
|
|
FishManager.FishDefinition fishDefinition = GlobalSettings.Instance.fishManager.GetFishDefinition((Fish.Species)details[4]);
|
|
if (fishDefinition == null || fishDefinition.fishPrefab == null)
|
|
{
|
|
Debug.LogError("Cheater: leaderboardType " + leaderboardType);
|
|
object[] obj = new object[4] { "score: ", score, " details[(int)LeaderboardsManager.LeaderboardStats.BIGGEST_WEIGHT] 2: ", null };
|
|
Fish.Species species = (Fish.Species)details[4];
|
|
obj[3] = species.ToString();
|
|
Debug.LogError(string.Concat(obj));
|
|
return false;
|
|
}
|
|
if (num > fishDefinition.fishPrefab.WeightMinMax.y + 1f)
|
|
{
|
|
Debug.LogError("Cheater: leaderboardType " + leaderboardType);
|
|
object[] obj2 = new object[6] { "score: ", score, " details[(int)LeaderboardsManager.LeaderboardStats.BIGGEST_WEIGHT] 3: ", num, " ", null };
|
|
Fish.Species species2 = (Fish.Species)details[4];
|
|
obj2[5] = species2.ToString();
|
|
Debug.LogError(string.Concat(obj2));
|
|
return false;
|
|
}
|
|
}
|
|
if ((float)details[6] / (float)details[2] > scoreToFishRatio)
|
|
{
|
|
Debug.LogError("$$$ Cheater: scoreToFishRatio > " + scoreToFishRatio + " " + (float)details[6] / (float)details[2]);
|
|
Debug.LogError("$$$ playersScore: " + details[6] + " fishManager.GetTotalFishCount(): " + details[2]);
|
|
return false;
|
|
}
|
|
LevelsManager.FisheryDefinition fisheryByLeaderboardName = GlobalSettings.Instance.levelsManager.GetFisheryByLeaderboardName(fisheryName);
|
|
if (fisheryByLeaderboardName != null && details[4] > -1 && !fisheryByLeaderboardName.fishSpecies.Contains((Fish.Species)details[4]))
|
|
{
|
|
Fish.Species species3 = (Fish.Species)details[4];
|
|
Debug.LogError("Cheater WRONG species: fisheryName: " + fisheryName + " species: " + species3);
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
public bool CheckMyStatsIntegrity()
|
|
{
|
|
int totalFishCount = GlobalSettings.Instance.fishManager.GetTotalFishCount();
|
|
if ((int)playersScore > (int)playersExperience)
|
|
{
|
|
Debug.LogError("Cheater: playersScore > playersExperience");
|
|
Debug.LogError(string.Concat("playersScore: ", playersScore, " playersExperience: ", playersExperience));
|
|
return false;
|
|
}
|
|
if ((int)playersLevel > (int)maxPlayerLevel)
|
|
{
|
|
Debug.LogError("Cheater: playersLevel > maxPlayerLevel");
|
|
Debug.LogError(string.Concat("playersLevel: ", playersLevel, " maxPlayerLevel: ", maxPlayerLevel));
|
|
return false;
|
|
}
|
|
if ((int)playersScore > 0 && totalFishCount == 0)
|
|
{
|
|
Debug.LogError("Cheater: playersScore > 0 && fishManager.GetTotalFishCount() == 0");
|
|
Debug.LogError(string.Concat("playersScore: ", playersScore, " fishManager.GetTotalFishCount(): ", totalFishCount));
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
[Button]
|
|
public void PrintFishToMoneyAndExp()
|
|
{
|
|
for (int i = 0; i < fishWeigths.Count; i++)
|
|
{
|
|
float num = Mathf.InverseLerp(0.15f, 900f, fishWeigths[i]);
|
|
float num2 = 1f - num;
|
|
num2 = Mathf.Pow(1f - num, powerMoney);
|
|
float f = Mathf.Lerp(minMaxMoney.x, minMaxMoney.y, 1f - num2);
|
|
f = Mathf.RoundToInt(f);
|
|
num2 = Mathf.Pow(1f - num, powerExp);
|
|
float f2 = Mathf.Lerp(minMaxExp.x, minMaxExp.y, 1f - num2);
|
|
f2 = Mathf.RoundToInt(f2);
|
|
Debug.Log(string.Empty + fishWeigths[i] + "kg " + num.ToString("F2") + " " + num2.ToString("F2") + " - " + f + "$ / " + fishWeigths[i] * (float)(int)fishKgMoney + "$ - " + f2 + "e / " + fishWeigths[i] * (float)(int)fishKgExp + "e");
|
|
}
|
|
}
|
|
|
|
public int GetFishToMoney(float fishWeight, float moneyFactor = 1f)
|
|
{
|
|
float num = Mathf.InverseLerp(0.15f, 900f, fishWeight);
|
|
float num2 = Mathf.Pow(1f - num, powerMoney);
|
|
float num3 = Mathf.Lerp(minMaxMoney.x, minMaxMoney.y, 1f - num2);
|
|
if (!IsCasual())
|
|
{
|
|
num3 *= realisticMultiplier;
|
|
}
|
|
return Mathf.RoundToInt(num3);
|
|
}
|
|
|
|
public int GetFishToExp(float fishWeight, float expFactor = 1f)
|
|
{
|
|
float num = Mathf.InverseLerp(0.15f, 900f, fishWeight);
|
|
float num2 = Mathf.Pow(1f - num, powerExp);
|
|
float num3 = Mathf.Lerp(minMaxExp.x, minMaxExp.y, 1f - num2);
|
|
if (!IsCasual())
|
|
{
|
|
num3 *= realisticMultiplier;
|
|
}
|
|
return Mathf.RoundToInt(num3);
|
|
}
|
|
|
|
public int GetFishToScore(float fishWeight)
|
|
{
|
|
return Mathf.RoundToInt(fishWeight * (float)(int)fishKgExp);
|
|
}
|
|
|
|
public static string GetDifficultyTranslation(Difficulty diff)
|
|
{
|
|
switch (diff)
|
|
{
|
|
case Difficulty.CASUAL:
|
|
return Utilities.GetTranslation("GUI/PROFILES_DIFFICULTY_NORMAL");
|
|
case Difficulty.SIMULATOR:
|
|
return Utilities.GetTranslation("GUI/PROFILES_DIFFICULTY_REALISTIC");
|
|
default:
|
|
return Utilities.GetTranslation("GUI/PROFILES_DIFFICULTY_SANDBOX");
|
|
}
|
|
}
|
|
|
|
[Button]
|
|
public void UnlockEverythingAndSave()
|
|
{
|
|
UnlockEverythingAndSave(true);
|
|
}
|
|
|
|
public void UnlockEverythingAndSave(bool makeSave)
|
|
{
|
|
GlobalSettings instance = GlobalSettings.Instance;
|
|
playersMoney = 90000;
|
|
playersExperience = 1200000;
|
|
AddExperience(1);
|
|
playersLevel = maxPlayerLevel;
|
|
instance.levelsManager.UnlockAll();
|
|
instance.levelsManager.AddAllLicences(1);
|
|
instance.skillsManager.UnlockAllSkills();
|
|
instance.equipmentManager.BuyAllMax();
|
|
instance.equipmentManager.RefreshStartEquipment();
|
|
if (makeSave)
|
|
{
|
|
instance.saveManager.Save();
|
|
}
|
|
Utilities.LogError("UnlockEverythingAndSave", "magenta", true);
|
|
}
|
|
|
|
[Button]
|
|
public void Save()
|
|
{
|
|
string currentProfilePrefix = GlobalSettings.Instance.saveManager.GetCurrentProfilePrefix();
|
|
using (ES2Writer eS2Writer = ES2Writer.Create(currentProfilePrefix))
|
|
{
|
|
eS2Writer.Write(GlobalSettings.Instance.gameVersion, "gameVersion");
|
|
eS2Writer.Write(LocalizationManager.CurrentLanguage, "language");
|
|
eS2Writer.Write((int)playersScore, "playersScore");
|
|
eS2Writer.Write((int)playersMoney, "playersMoney");
|
|
eS2Writer.Write((int)playersExperience, "playersExperience");
|
|
eS2Writer.Write((int)playersLevel, "playersLevel");
|
|
eS2Writer.Write((float)playersLuck, "playersLuck");
|
|
eS2Writer.Write((float)playersStrength, "playersStrength");
|
|
eS2Writer.Write((int)difficultyObscured, "difficultyObscured");
|
|
eS2Writer.Write(imperialUnits, "imperialUnits");
|
|
eS2Writer.Write(showBaitIndicator, "showBaitIndicator");
|
|
eS2Writer.Write(showHookPrompt, "showHookPrompt");
|
|
eS2Writer.Write(manualFishingNet, "manualFishingNet");
|
|
eS2Writer.Write(showFloatWindow, "showFloatWindow");
|
|
eS2Writer.Write(floatSizeMultiplier, "floatSizeMultiplier");
|
|
eS2Writer.Write(invertYAxis, "invertYAxis");
|
|
eS2Writer.Write(mouseSensitivity, "mouseSensitivity");
|
|
eS2Writer.Write(gamepadVibration, "gamepadVibration");
|
|
eS2Writer.Write(showIngameControls, "showIngameControls");
|
|
eS2Writer.Write(showMultiplayerAvatars, "showMultiplayerAvatars");
|
|
eS2Writer.Write((int)tensionWidgetType, "tensionWidgetType");
|
|
eS2Writer.Write(headBob, "headBob");
|
|
eS2Writer.Write(editorUnderwaterEffect, "editorUnderwaterEffect");
|
|
eS2Writer.Write(newChangelog, "newChangelog");
|
|
if ((bool)GlobalTournamentManager.Instance && GlobalTournamentManager.Instance.currentTournament != null)
|
|
{
|
|
eS2Writer.Write(GlobalTournamentManager.Instance.currentTournament.isSignedUp, "currentTournament_isSignedUp");
|
|
}
|
|
try
|
|
{
|
|
eS2Writer.Save();
|
|
}
|
|
catch (Exception exception)
|
|
{
|
|
Debug.LogException(exception, this);
|
|
}
|
|
Debug.Log("Save PlayerSettings");
|
|
}
|
|
}
|
|
|
|
public void SaveGameVersion()
|
|
{
|
|
string currentProfilePrefix = GlobalSettings.Instance.saveManager.GetCurrentProfilePrefix();
|
|
using (ES2Writer eS2Writer = ES2Writer.Create(currentProfilePrefix))
|
|
{
|
|
eS2Writer.Write(GlobalSettings.Instance.gameVersion, "gameVersion");
|
|
eS2Writer.Save();
|
|
Debug.Log("Save PlayerSettings SaveGameVersion");
|
|
}
|
|
}
|
|
|
|
public void Load()
|
|
{
|
|
if (GlobalSettings.Instance.currentPlatform == GlobalSettings.Platform.ARCADE)
|
|
{
|
|
}
|
|
string currentProfilePrefix = GlobalSettings.Instance.saveManager.GetCurrentProfilePrefix();
|
|
int savedGameVersion = GlobalSettings.Instance.gameVersion;
|
|
using (ES2Reader reader = ES2Reader.Create(currentProfilePrefix))
|
|
{
|
|
savedGameVersion = SaveManager.Read(reader, "gameVersion", -1);
|
|
string text = SaveManager.Read(reader, "language", string.Empty);
|
|
if (GlobalSettings.Instance.isDemo)
|
|
{
|
|
LocalizationManager.CurrentLanguage = LocalizationManager.GetAllLanguages()[0];
|
|
}
|
|
else if (LocalizationManager.HasLanguage(text))
|
|
{
|
|
LocalizationManager.CurrentLanguage = text;
|
|
}
|
|
else if (LocalizationManager.HasLanguage(Application.systemLanguage.ToString()))
|
|
{
|
|
LocalizationManager.CurrentLanguage = Application.systemLanguage.ToString();
|
|
}
|
|
else if (Application.systemLanguage == SystemLanguage.ChineseSimplified || Application.systemLanguage == SystemLanguage.ChineseTraditional)
|
|
{
|
|
LocalizationManager.CurrentLanguage = "Chinese";
|
|
}
|
|
else
|
|
{
|
|
LocalizationManager.CurrentLanguage = LocalizationManager.GetAllLanguages()[0];
|
|
}
|
|
playersScore = SaveManager.Read(reader, "playersScore", 0);
|
|
playersMoney = SaveManager.Read(reader, "playersMoney", (int)playersStartMoney);
|
|
playersExperience = SaveManager.Read(reader, "playersExperience", 0);
|
|
playersLevel = SaveManager.Read(reader, "playersLevel", 1);
|
|
playersLuck = SaveManager.Read(reader, "playersLuck", 0.33f);
|
|
playersStrength = SaveManager.Read(reader, "playersStrength", 0.33f);
|
|
difficulty = (Difficulty)SaveManager.Read(reader, "difficultyObscured", 0);
|
|
difficultyObscured = (int)difficulty;
|
|
imperialUnits = SaveManager.Read(reader, "imperialUnits", false);
|
|
showBaitIndicator = SaveManager.Read(reader, "showBaitIndicator", true);
|
|
showHookPrompt = SaveManager.Read(reader, "showHookPrompt", true);
|
|
manualFishingNet = SaveManager.Read(reader, "manualFishingNet", true);
|
|
showFloatWindow = SaveManager.Read(reader, "showFloatWindow", true);
|
|
floatSizeMultiplier = SaveManager.Read(reader, "floatSizeMultiplier", 0f);
|
|
invertYAxis = SaveManager.Read(reader, "invertYAxis", 1f);
|
|
mouseSensitivity = SaveManager.Read(reader, "mouseSensitivity", 1f);
|
|
gamepadVibration = SaveManager.Read(reader, "gamepadVibration", true);
|
|
showIngameControls = SaveManager.Read(reader, "showIngameControls", true);
|
|
showMultiplayerAvatars = SaveManager.Read(reader, "showMultiplayerAvatars", true);
|
|
tensionWidgetType = (HUDFishing.TensionWidgetType)SaveManager.Read(reader, "tensionWidgetType", 0);
|
|
headBob = SaveManager.Read(reader, "headBob", true);
|
|
editorUnderwaterEffect = SaveManager.Read(reader, "editorUnderwaterEffect", true);
|
|
newChangelog = SaveManager.Read(reader, "newChangelog", false);
|
|
if ((bool)GlobalTournamentManager.Instance && GlobalTournamentManager.Instance.currentTournament != null)
|
|
{
|
|
GlobalTournamentManager.Instance.currentTournament.isSignedUp = SaveManager.Read(reader, "currentTournament_isSignedUp", false);
|
|
if (GlobalTournamentManager.Instance.currentTournament.state == GlobalTournamentManager.TournamentState.FINISHED)
|
|
{
|
|
GlobalTournamentManager.Instance.currentTournament.isSignedUp = false;
|
|
}
|
|
}
|
|
}
|
|
if (GlobalSettings.Instance.turnOnMyCheats)
|
|
{
|
|
playersExperience = 999999999;
|
|
playersLevel = maxPlayerLevel;
|
|
}
|
|
GlobalSettings.Instance.CheckGameVersion(savedGameVersion);
|
|
}
|
|
|
|
public void Reset()
|
|
{
|
|
playersScore = 0;
|
|
playersMoney = playersStartMoney;
|
|
playersExperience = 0;
|
|
playersLevel = 1;
|
|
playersLuck = 0.33f;
|
|
playersStrength = 0.33f;
|
|
difficulty = tempDifficulty;
|
|
difficultyObscured = (int)tempDifficulty;
|
|
imperialUnits = false;
|
|
showBaitIndicator = true;
|
|
showHookPrompt = true;
|
|
manualFishingNet = true;
|
|
showFloatWindow = true;
|
|
floatSizeMultiplier = 0f;
|
|
invertYAxis = 1f;
|
|
mouseSensitivity = 1f;
|
|
gamepadVibration = true;
|
|
showIngameControls = true;
|
|
showMultiplayerAvatars = true;
|
|
tensionWidgetType = HUDFishing.TensionWidgetType.STRAIGHT_BOTTOM;
|
|
headBob = true;
|
|
editorUnderwaterEffect = true;
|
|
newChangelog = false;
|
|
if ((bool)GlobalTournamentManager.Instance && GlobalTournamentManager.Instance.currentTournament != null)
|
|
{
|
|
GlobalTournamentManager.Instance.currentTournament.isSignedUp = false;
|
|
}
|
|
Save();
|
|
}
|
|
}
|