chip-game/Assets/Scripts/DifficultyManager.cs
2026-01-12 09:36:17 +03:00

46 lines
1.4 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
{
public static DifficultyManager instance;
public UnityEvent OnVictory = new UnityEvent();
public int currentOpponent = 0;
void Awake()
{
if (instance == null)
{
instance = this;
currentOpponent = 0;
}
}
public DifficultyPreset DifficultyPreset => CharacterController.CurrentCharacter.CurrentDifficultyPreset;
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();
}
}