2023-08-22 17:02:25 +03:00
|
|
|
|
using System;
|
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
|
|
|
|
private PlayerInfo _playerInfo;
|
|
|
|
|
private Player _currentPlayer;
|
2023-08-07 13:23:18 +03:00
|
|
|
|
|
2023-08-22 15:41:12 +03:00
|
|
|
|
public Player CurrentPlayer => _currentPlayer;
|
2023-10-05 17:56:59 +03:00
|
|
|
|
public List<Player> AllPlayers
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return _playerInfo.Players;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string DefaultName = "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 367";
|
2023-08-07 13:23:18 +03:00
|
|
|
|
|
|
|
|
|
private void Awake()
|
2023-07-24 16:38:13 +03:00
|
|
|
|
{
|
2023-10-05 17:56:59 +03:00
|
|
|
|
transform.parent = null;
|
|
|
|
|
|
2023-08-07 13:23:18 +03:00
|
|
|
|
if (Instance == null)
|
|
|
|
|
{
|
2023-10-05 17:56:59 +03:00
|
|
|
|
Instance = this;
|
|
|
|
|
DontDestroyOnLoad(gameObject);
|
|
|
|
|
LoadPlayerData();
|
2023-08-07 13:23:18 +03:00
|
|
|
|
}
|
|
|
|
|
else if (Instance == this)
|
|
|
|
|
{
|
|
|
|
|
Destroy(gameObject);
|
|
|
|
|
}
|
2023-08-22 17:02:25 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void LoadPlayerData()
|
|
|
|
|
{
|
|
|
|
|
SaveLoadController.Instance.Load(ref _playerInfo);
|
2023-07-24 16:38:13 +03:00
|
|
|
|
}
|
|
|
|
|
|
2023-10-05 17:56:59 +03:00
|
|
|
|
public void CreateNewPlayer()
|
2023-08-07 13:23:18 +03:00
|
|
|
|
{
|
|
|
|
|
_currentPlayer = new Player();
|
2023-10-05 17:56:59 +03:00
|
|
|
|
_currentPlayer.Name = DefaultName;
|
|
|
|
|
_currentPlayer.DateTime = DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss");
|
|
|
|
|
|
2023-08-22 17:02:25 +03:00
|
|
|
|
_playerInfo.AddNewPlayer(_currentPlayer);
|
2023-08-15 17:38:54 +03:00
|
|
|
|
}
|
|
|
|
|
|
2023-08-22 15:41:12 +03:00
|
|
|
|
public void SetPlayerName(string name)
|
2023-07-24 16:38:13 +03:00
|
|
|
|
{
|
2023-08-22 15:41:12 +03:00
|
|
|
|
_currentPlayer.Name = name;
|
2023-07-24 16:38:13 +03:00
|
|
|
|
}
|
2023-08-07 13:23:18 +03:00
|
|
|
|
|
2023-10-05 17:56:59 +03:00
|
|
|
|
public void AddPlayerScore(int score)
|
2023-08-07 13:23:18 +03:00
|
|
|
|
{
|
2023-10-05 17:56:59 +03:00
|
|
|
|
_currentPlayer.Score += score;
|
2023-08-07 13:23:18 +03:00
|
|
|
|
}
|
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool TryFindMonument(MonumentInfo info)
|
|
|
|
|
{
|
|
|
|
|
return _currentPlayer.UnlockedMonumets.Contains(info);
|
|
|
|
|
}
|
2023-10-05 17:56:59 +03:00
|
|
|
|
|
|
|
|
|
public void SaveCurrnetPlayerData()
|
|
|
|
|
{
|
|
|
|
|
SaveLoadController.Instance.Save(_playerInfo);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Player DebugPlayer;
|
|
|
|
|
[ContextMenu("Add debug player")]
|
|
|
|
|
private void AddDebug()
|
|
|
|
|
{
|
|
|
|
|
DebugPlayer.DateTime = DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss");
|
|
|
|
|
_playerInfo.AddNewPlayer(DebugPlayer);
|
|
|
|
|
SaveCurrnetPlayerData();
|
|
|
|
|
}
|
2023-07-24 16:38:13 +03:00
|
|
|
|
}
|