66 lines
1.4 KiB
C#
66 lines
1.4 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class PlayerSetup : MonoBehaviour
|
|
{
|
|
public static PlayerSetup Instance;
|
|
private PlayerInfo _playerInfo;
|
|
[SerializeField]
|
|
private Player _currentPlayer;
|
|
|
|
public Player CurrentPlayer => _currentPlayer;
|
|
public PlayerInfo PlayerInfo => _playerInfo;
|
|
|
|
private void Awake()
|
|
{
|
|
if (Instance == null)
|
|
{
|
|
Instance = this;
|
|
}
|
|
else if (Instance == this)
|
|
{
|
|
Destroy(gameObject);
|
|
}
|
|
|
|
DontDestroyOnLoad(gameObject);
|
|
|
|
LoadPlayerData();
|
|
}
|
|
|
|
private void LoadPlayerData()
|
|
{
|
|
SaveLoadController.Instance.Load(ref _playerInfo);
|
|
}
|
|
|
|
public Player CreateNewPlayer()
|
|
{
|
|
_currentPlayer = new Player();
|
|
_playerInfo.AddNewPlayer(_currentPlayer);
|
|
SaveLoadController.Instance.Save(_playerInfo);
|
|
return _currentPlayer;
|
|
}
|
|
|
|
public void SetPlayerName(string name)
|
|
{
|
|
_currentPlayer.Name = name;
|
|
SaveLoadController.Instance.Save(_playerInfo);
|
|
}
|
|
|
|
public void SetPlayerScore(float score)
|
|
{
|
|
_currentPlayer.Score = score;
|
|
}
|
|
|
|
public void UnlockMonument(MonumentInfo info)
|
|
{
|
|
_currentPlayer.UnlockedMonumets.Add(info);
|
|
}
|
|
|
|
public bool TryFindMonument(MonumentInfo info)
|
|
{
|
|
return _currentPlayer.UnlockedMonumets.Contains(info);
|
|
}
|
|
}
|