chip-gameV3/Assets/Scripts/Gameplay/DifficultyManager.cs
sega 116b9b3116 Рефакторинг Character.cs: приведение к SRP и вынос логики
Инкапсулированы методы появления и ухода персонажа
Инкапсулирована работа с аниматором
Работа с репликами вынесена в ScriptableObject
Логика MessageBox вынесена в отдельный класс
Переработан event bus персонажей
Сложность и призовой модуль вынесены в отдельные классы
Character.cs приведён к Single Responsibility Principle.
2026-08-13 16:19:56 +03:00

74 lines
2.6 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using CharacterSystem;
using UnityEngine;
using UnityEngine.Events;
public class DifficultyManager : MonoBehaviour
{
private static DifficultyManager instance;
public static DifficultyManager Instance
{
get
{
if (instance == null)
{
instance = FindAnyObjectByType<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 DummyPreset;
public bool dummyBots = false;
public void IncreaseDifficulty()
{
if (currentOpponent + 1 == CharactersController.CharactersAmount)//победили самую большую сложность
{
OnVictory?.Invoke();
}
CharactersController.CurrentCharacter.difficultyModule.IncreaseDifficuly();//увеличиваем сложность у того с кем бились
currentOpponent = (currentOpponent + 1) % CharactersController.CharactersAmount;//если победили последнего, то возвращаемся на первого
}
public void DecreaseDifficulty()
{
CharactersController.CurrentCharacter.difficultyModule.DecreaseDifficuly();//уменьшаем сложность у того с кем бились
if (currentOpponent != 0)
{
currentOpponent--;
}
}
public void ResetDifficulty()
{
currentOpponent = 0;
CharactersController.ResetAllCharactersDifficulty();
}
public void upgradeFeeshkaDifficulty()
{
string difficultyMode = SettingsManager.GetString(SettingKey.DIFFICULTY_MODE);
//todo: разобраться
// if (difficultyMode == "Прохождение")
// {
// PaymentSystem.ResetPulsesCounter();
// Setting difficultySetting = SettingsManager.Container.TryGetSetting(SettingKeys.DIFFICULTY_MODE);
// difficultySetting.StringValue = "Заработок";
// SettingsManager.OnSettingsChanged?.Invoke();
// SettingsManager.SaveContainerToFile();
// GameManager.instance.AdminPanel.GetComponent<SettingsScreen>().RefreshViews();
// print("Сложность повышена");
// }
}
}