Run-and-capture/Assets/Scripts/MainMenu/BotsCountSetter.cs

28 lines
519 B
C#

using UnityEngine;
public class BotsCountSetter : MonoBehaviour
{
[Range(0, 3)]
[SerializeField] private int _botsCount = 1;
private int _currentBotsCount;
private void Start()
{
SetBotsCount(_botsCount);
}
private void Update()
{
if (_botsCount != _currentBotsCount)
{
SetBotsCount(_botsCount);
}
}
private void SetBotsCount(int count)
{
_currentBotsCount = count;
GameData.gameMaxPlayers = count + 1;
}
}