48 lines
1.5 KiB
C#
48 lines
1.5 KiB
C#
using System;
|
|
using Sirenix.OdinInspector;
|
|
using UnityEngine;
|
|
|
|
// ReSharper disable once CheckNamespace
|
|
namespace BlueWaterProject
|
|
{
|
|
[DefaultExecutionOrder(-1)]
|
|
public class GameManager : Singleton<GameManager>
|
|
{
|
|
public ShipPlayer ShipPlayer { get; private set; }
|
|
|
|
// Combat
|
|
[Title("Combat")]
|
|
[SerializeField] private GameObject combatPlayerPrefab;
|
|
public CombatPlayer CurrentCombatPlayer { get; set; }
|
|
public event Action<Transform> OnInstantiateCombatPlayer;
|
|
|
|
// Tycoon
|
|
[Title("Tycoon")]
|
|
public TycoonPlayer TycoonPlayer { get; private set; }
|
|
public bool IsBuildMode { get; set; }
|
|
[field: SerializeField] public bool IsOnFollowCamera { get; set; }
|
|
|
|
private void Init()
|
|
{
|
|
TycoonPlayer = FindAnyObjectByType<TycoonPlayer>();
|
|
ShipPlayer = FindAnyObjectByType<ShipPlayer>();
|
|
}
|
|
protected override void OnAwake()
|
|
{
|
|
Init();
|
|
}
|
|
|
|
private void Start()
|
|
{
|
|
Cursor.lockState = CursorLockMode.Confined;
|
|
}
|
|
|
|
public void InstantiateCombatPlayer(Vector3 position, Quaternion rotation = default)
|
|
{
|
|
var instantiatePlayer = Instantiate(combatPlayerPrefab, position, rotation).GetComponent<CombatPlayer>();
|
|
CurrentCombatPlayer = instantiatePlayer;
|
|
OnInstantiateCombatPlayer?.Invoke(instantiatePlayer.transform);
|
|
}
|
|
}
|
|
}
|