OldBlueWater/BlueWater/Assets/02.Scripts/GameManager.cs

48 lines
1.5 KiB
C#
Raw Normal View History

using System;
2023-08-11 16:21:26 +00:00
using Sirenix.OdinInspector;
2023-08-08 07:08:41 +00:00
using UnityEngine;
2023-08-31 06:46:13 +00:00
// ReSharper disable once CheckNamespace
namespace BlueWaterProject
2023-08-08 07:08:41 +00:00
{
2023-09-20 09:06:45 +00:00
[DefaultExecutionOrder(-1)]
2023-08-31 06:46:13 +00:00
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
2023-12-26 05:18:14 +00:00
[Title("Tycoon")]
2024-01-03 02:54:03 +00:00
public TycoonPlayer TycoonPlayer { get; private set; }
2023-12-26 05:18:14 +00:00
public bool IsBuildMode { get; set; }
[field: SerializeField] public bool IsOnFollowCamera { get; set; }
2023-08-11 16:21:26 +00:00
2023-08-31 06:46:13 +00:00
private void Init()
{
2024-01-03 02:54:03 +00:00
TycoonPlayer = FindAnyObjectByType<TycoonPlayer>();
ShipPlayer = FindAnyObjectByType<ShipPlayer>();
2023-08-31 06:46:13 +00:00
}
protected override void OnAwake()
{
Init();
}
2023-08-31 06:46:13 +00:00
private void Start()
{
Cursor.lockState = CursorLockMode.Confined;
}
public void InstantiateCombatPlayer(Vector3 position, Quaternion rotation = default)
{
2024-05-13 16:23:53 +00:00
var instantiatePlayer = Instantiate(combatPlayerPrefab, position, rotation).GetComponent<CombatPlayer>();
CurrentCombatPlayer = instantiatePlayer;
OnInstantiateCombatPlayer?.Invoke(instantiatePlayer.transform);
}
}
2023-08-08 07:08:41 +00:00
}