73 lines
2.6 KiB
C#
73 lines
2.6 KiB
C#
using UnityEngine;
|
||
using UnityEngine.Events;
|
||
|
||
public class DifficultyManager : MonoBehaviour
|
||
{
|
||
|
||
private static DifficultyManager instance;
|
||
public static DifficultyManager Instance
|
||
{
|
||
get
|
||
{
|
||
if (instance == null)
|
||
{
|
||
instance = FindObjectOfType<DifficultyManager>();
|
||
|
||
if (instance == null)
|
||
{
|
||
Debug.LogWarning($"Не найден {typeof(DifficultyManager)}");
|
||
}
|
||
else
|
||
{
|
||
instance.currentOpponent = 0;
|
||
}
|
||
}
|
||
return instance;
|
||
}
|
||
}
|
||
|
||
public UnityEvent OnVictory = new UnityEvent();
|
||
public int currentOpponent = 0;
|
||
public DifficultyPreset DifficultyPreset => CharacterController.CurrentCharacter.CurrentDifficultyPreset;
|
||
|
||
public DifficultyPreset DummyPreset;
|
||
public bool dummyBots = false;
|
||
public void IncreaseDifficulty()
|
||
{
|
||
if (currentOpponent + 1 == CharacterController.CharactersAmount)//победили самую большую сложность
|
||
{
|
||
OnVictory?.Invoke();
|
||
}
|
||
CharacterController.CurrentCharacter.IncreaseDifficuly();//увеличиваем сложность у того с кем бились
|
||
currentOpponent = (currentOpponent + 1) % CharacterController.CharactersAmount;//если победили последнего, то возвращаемся на первого
|
||
}
|
||
public void DecreaseDifficulty()
|
||
{
|
||
CharacterController.CurrentCharacter.DecreaseDifficuly();//уменьшаем сложность у того с кем бились
|
||
if (currentOpponent != 0)
|
||
{
|
||
currentOpponent--;
|
||
}
|
||
}
|
||
public void ResetDifficulty()
|
||
{
|
||
currentOpponent = 0;
|
||
CharacterController.ResetCharactersDifficulty();
|
||
}
|
||
|
||
public void upgradeFeeshkaDifficulty()
|
||
{
|
||
string difficultyType = SettingsManager.GetString("BaseBotDifficulty", "Обычная");
|
||
if (difficultyType == "Обычная")
|
||
{
|
||
PlayerPrefs.SetInt("PulsesCounter", 0);
|
||
Setting difficultySetting = SettingsManager.Container.TryGetSetting("BaseBotDifficulty");
|
||
difficultySetting.StringValue = "Повышенная";
|
||
SettingsManager.OnSettingsChanged?.Invoke();
|
||
SettingsManager.SaveContainerToFile();
|
||
GameManager.instance.AdminPanel.GetComponent<SettingsScreen>().RefreshViews();
|
||
print("Сложность повышена");
|
||
}
|
||
}
|
||
}
|