66 lines
1.3 KiB
C#
66 lines
1.3 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class PlayerSetup : MonoBehaviour
|
|
{
|
|
public static PlayerSetup Instance;
|
|
[SerializeField]
|
|
private PlayerInfo _playerInfo;
|
|
[SerializeField]
|
|
private Player _currentPlayer;
|
|
|
|
public PlayerInfo PlayerInfo => _playerInfo;
|
|
|
|
private void Awake()
|
|
{
|
|
if (Instance == null)
|
|
{
|
|
Instance = this;
|
|
}
|
|
else if (Instance == this)
|
|
{
|
|
Destroy(gameObject);
|
|
}
|
|
|
|
DontDestroyOnLoad(gameObject);
|
|
}
|
|
|
|
public Player CreateNewPlayer()
|
|
{
|
|
_currentPlayer = new Player();
|
|
return _currentPlayer;
|
|
}
|
|
|
|
public void SetPlayerScore(float value)
|
|
{
|
|
_currentPlayer.Score = value;
|
|
}
|
|
|
|
public void AddScore(float ammount)
|
|
{
|
|
_currentPlayer.Score += ammount;
|
|
}
|
|
|
|
public void SetPlayerName(string name)
|
|
{
|
|
_currentPlayer.Name = name;
|
|
}
|
|
|
|
public void UnlockMonument(MonumentInfo info)
|
|
{
|
|
_currentPlayer.UnlockedMonumets.Add(info);
|
|
AddScore(info.Score);
|
|
}
|
|
|
|
public bool TryFindMonument(MonumentInfo info)
|
|
{
|
|
return _currentPlayer.UnlockedMonumets.Contains(info);
|
|
}
|
|
|
|
public void SavePlayer()
|
|
{
|
|
_playerInfo.Players.Add(_currentPlayer);
|
|
}
|
|
}
|