using System; using System.Collections; using System.Collections.Generic; using Sirenix.OdinInspector; using UnityEngine; using UnityEngine.InputSystem; // ReSharper disable once CheckNamespace namespace BlueWaterProject { [DefaultExecutionOrder(-1)] public class GameManager : Singleton { // 섬 안의 플레이어 모드 선택 [field: Title("InIsland Data")] [field: SerializeField] public GlobalValue.InIslandPlayerMode IslandPlayerMode { get; private set; } [field: Required("Viking Prefab을 넣어주세요.")] [field: SerializeField] public GameObject InIslandPlayerPrefab { get; private set; } [field: SerializeField] public List CrewmatePrefabList { get; private set; } [field: SerializeField] public List CurrentCrewmateList { get; set; } public IInIslandPlayer CurrentInIslandPlayer { get; set; } public ShipPlayer ShipPlayer { get; private set; } [Title("Tycoon")] public TycoonPlayer TycoonPlayer { get; private set; } public bool IsBuildMode { get; set; } // Game Data [Title("Game Data")] [Range(0f, 1f)] [SerializeField] private float slowSpeed = 0.1f; private const string IN_ISLAND_PLAYER_NAME = "InIslandPlayer"; private void Init() { TycoonPlayer = FindAnyObjectByType(); ShipPlayer = FindAnyObjectByType(); } protected override void OnAwake() { Init(); } private void Start() { Cursor.lockState = CursorLockMode.Confined; } public IEnumerator ApplySlowMotion(float targetTimeScale, float duration) { var startScale = Time.timeScale; var time = 0f; while (time < duration) { Time.timeScale = Mathf.Lerp(startScale, targetTimeScale, time / duration); Time.fixedDeltaTime = 0.02f * Time.timeScale; time += Time.unscaledDeltaTime; yield return null; } Time.timeScale = targetTimeScale; } public void SlowSpeedMode() { Time.timeScale = slowSpeed; Time.fixedDeltaTime = 0.02f * Time.timeScale; } public void DefaultSpeedMode() { Time.timeScale = 1f; Time.fixedDeltaTime = 0.02f; } public void SetCurrentInIslandPlayer(IInIslandPlayer inIslandPlayer) { // PlayerInput currentPlayerInput; // // if (CurrentInIslandPlayer != null) // { // currentPlayerInput = CurrentInIslandPlayer.Transform.GetComponent(); // if (currentPlayerInput != null) // { // currentPlayerInput.enabled = false; // } // } // // CurrentInIslandPlayer = inIslandPlayer; // InIslandCamera.Inst.SetTarget(inIslandPlayer.Transform); // // currentPlayerInput = CurrentInIslandPlayer.Transform.GetComponent(); // if (currentPlayerInput != null) // { // currentPlayerInput.enabled = true; // } } } }