rabidus-test/Assets/Scripts/PlayerSetup.cs

59 lines
1.2 KiB
C#
Raw Normal View History

2023-07-24 16:38:13 +03:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerSetup : MonoBehaviour
{
public static PlayerSetup Instance;
2023-07-24 16:38:13 +03:00
[SerializeField]
private PlayerInfo _playerInfo;
private Player _currentPlayer;
public PlayerInfo PlayerInfo => _playerInfo;
private void Awake()
2023-07-24 16:38:13 +03:00
{
if (Instance == null)
{
Instance = this;
}
else if (Instance == this)
{
Destroy(gameObject);
}
DontDestroyOnLoad(gameObject);
2023-07-24 16:38:13 +03:00
}
public void CreateNewPlayer()
{
_currentPlayer = new Player();
}
public void SetPlayerScore(float ammount)
2023-07-24 16:38:13 +03:00
{
_currentPlayer.Score = ammount;
}
public void SetPlayerName(string name)
{
_currentPlayer.Name = name;
}
public void UnlockMonument(MonumentInfo info, float score)
{
info.Score = score;
_currentPlayer.UnlockedMonumets.Add(info);
}
public bool TryFindMonument(MonumentInfo info)
{
return _currentPlayer.UnlockedMonumets.Contains(info);
}
public void SavePlayer()
{
_playerInfo.Players.Add(_currentPlayer);
}
2023-07-24 16:38:13 +03:00
}