58 lines
1.8 KiB
C#
58 lines
1.8 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 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();
|
||
}
|
||
}
|