2023-07-24 16:38:13 +03:00
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
public class PlayerSetup : MonoBehaviour
|
|
|
|
{
|
2023-08-07 13:23:18 +03:00
|
|
|
public static PlayerSetup Instance;
|
2023-07-24 16:38:13 +03:00
|
|
|
[SerializeField]
|
|
|
|
private PlayerInfo _playerInfo;
|
2023-08-15 17:38:54 +03:00
|
|
|
[SerializeField]
|
2023-07-24 16:38:13 +03:00
|
|
|
private Player _currentPlayer;
|
2023-08-07 13:23:18 +03:00
|
|
|
|
|
|
|
public PlayerInfo PlayerInfo => _playerInfo;
|
|
|
|
|
|
|
|
private void Awake()
|
2023-07-24 16:38:13 +03:00
|
|
|
{
|
2023-08-07 13:23:18 +03:00
|
|
|
if (Instance == null)
|
|
|
|
{
|
|
|
|
Instance = this;
|
|
|
|
}
|
|
|
|
else if (Instance == this)
|
|
|
|
{
|
|
|
|
Destroy(gameObject);
|
|
|
|
}
|
|
|
|
|
|
|
|
DontDestroyOnLoad(gameObject);
|
2023-07-24 16:38:13 +03:00
|
|
|
}
|
|
|
|
|
2023-08-15 17:38:54 +03:00
|
|
|
public Player CreateNewPlayer()
|
2023-08-07 13:23:18 +03:00
|
|
|
{
|
|
|
|
_currentPlayer = new Player();
|
2023-08-15 17:38:54 +03:00
|
|
|
return _currentPlayer;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void SetPlayerScore(float value)
|
|
|
|
{
|
|
|
|
_currentPlayer.Score = value;
|
2023-08-07 13:23:18 +03:00
|
|
|
}
|
|
|
|
|
2023-08-15 17:38:54 +03:00
|
|
|
public void AddScore(float ammount)
|
2023-07-24 16:38:13 +03:00
|
|
|
{
|
2023-08-15 17:38:54 +03:00
|
|
|
_currentPlayer.Score += ammount;
|
2023-07-24 16:38:13 +03:00
|
|
|
}
|
2023-08-07 13:23:18 +03:00
|
|
|
|
|
|
|
public void SetPlayerName(string name)
|
|
|
|
{
|
|
|
|
_currentPlayer.Name = name;
|
|
|
|
}
|
|
|
|
|
2023-08-15 17:38:54 +03:00
|
|
|
public void UnlockMonument(MonumentInfo info)
|
2023-08-07 13:23:18 +03:00
|
|
|
{
|
|
|
|
_currentPlayer.UnlockedMonumets.Add(info);
|
2023-08-15 17:38:54 +03:00
|
|
|
AddScore(info.Score);
|
2023-08-07 13:23:18 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
}
|