rabidus-test/Assets/Scripts/PlayerSetup.cs

57 lines
1.2 KiB
C#

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerSetup : MonoBehaviour
{
public static PlayerSetup Instance;
private Player _currentPlayer;
public Player CurrentPlayer => _currentPlayer;
public string DefaultName = "Ïåíçåíåö 367";
private void Awake()
{
//transform.parent = null;
if (Instance == null)
{
Instance = this;
//DontDestroyOnLoad(gameObject);
}
else if (Instance != this)
{
Destroy(gameObject);
}
}
public void CreateNewPlayer()
{
_currentPlayer = new Player();
_currentPlayer.Name = DefaultName;
}
public void SetPlayerName(string name)
{
_currentPlayer.Name = name;
}
public void AddPlayerScore(int score)
{
if (_currentPlayer != null)
_currentPlayer.Score += score;
}
public void UnlockMonument(MonumentInfo info)
{
_currentPlayer.UnlockedMonumets.Add(info);
}
public bool TryFindMonument(MonumentInfo info)
{
return _currentPlayer.UnlockedMonumets.Contains(info);
}
}