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

104 lines
3.4 KiB
C#
Raw Normal View History

using System;
using System.Collections;
2023-08-08 07:08:41 +00:00
using System.Collections.Generic;
2023-08-11 16:21:26 +00:00
using Sirenix.OdinInspector;
2023-08-08 07:08:41 +00:00
using UnityEngine;
2023-10-05 04:11:46 +00:00
using UnityEngine.InputSystem;
2023-08-08 07:08:41 +00:00
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>
{
// 섬 안의 플레이어 모드 선택
[field: Title("InIsland Data")]
[field: SerializeField] public GlobalValue.InIslandPlayerMode IslandPlayerMode { get; private set; }
2023-10-17 07:31:10 +00:00
[field: Required("Viking Prefab을 넣어주세요.")]
[field: SerializeField] public GameObject InIslandPlayerPrefab { get; private set; }
[field: SerializeField] public List<Crewmate> CrewmatePrefabList { get; private set; }
[field: SerializeField] public List<Crewmate> CurrentCrewmateList { get; set; }
public IInIslandPlayer CurrentInIslandPlayer { get; set; }
public ShipPlayer ShipPlayer { get; private set; }
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
// Game Data
[Title("Game Data")]
2023-08-31 06:46:13 +00:00
[Range(0f, 1f)]
[SerializeField] private float slowSpeed = 0.1f;
2023-10-05 04:11:46 +00:00
private const string IN_ISLAND_PLAYER_NAME = "InIslandPlayer";
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;
}
2023-10-06 05:41:16 +00:00
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;
}
2023-08-31 06:46:13 +00:00
public void SlowSpeedMode()
{
Time.timeScale = slowSpeed;
Time.fixedDeltaTime = 0.02f * Time.timeScale;
}
2023-08-31 06:46:13 +00:00
public void DefaultSpeedMode()
{
Time.timeScale = 1f;
Time.fixedDeltaTime = 0.02f;
}
2023-10-06 05:41:16 +00:00
public void SetCurrentInIslandPlayer(IInIslandPlayer inIslandPlayer)
{
// PlayerInput currentPlayerInput;
//
// if (CurrentInIslandPlayer != null)
// {
// currentPlayerInput = CurrentInIslandPlayer.Transform.GetComponent<PlayerInput>();
// if (currentPlayerInput != null)
// {
// currentPlayerInput.enabled = false;
// }
// }
//
// CurrentInIslandPlayer = inIslandPlayer;
// InIslandCamera.Inst.SetTarget(inIslandPlayer.Transform);
//
// currentPlayerInput = CurrentInIslandPlayer.Transform.GetComponent<PlayerInput>();
// if (currentPlayerInput != null)
// {
// currentPlayerInput.enabled = true;
// }
}
}
2023-08-08 07:08:41 +00:00
}