chip-gameV3/Assets/Scripts/Gameplay/DifficultyManager.cs
sega 8a6d23b77d Реорг Scripts
Разделено на 4 модуля
- Menu
- Gameplay
- Settings
- Common
2026-07-15 10:49:55 +03:00

73 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 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 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 == "Обычная")
{
PaymentSystem.ResetPulsesCounter();
Setting difficultySetting = SettingsManager.Container.TryGetSetting("BaseBotDifficulty");
difficultySetting.StringValue = "Повышенная";
SettingsManager.OnSettingsChanged?.Invoke();
SettingsManager.SaveContainerToFile();
GameManager.instance.AdminPanel.GetComponent<SettingsScreen>().RefreshViews();
print("Сложность повышена");
}
}
}