OldBlueWater/BlueWater/Assets/02.Scripts/CombatCamera.cs
NTG c63377124f 슬라임 및 로직 수정(상세내용 아래 참고)
수정 내역
1. 토끼 이미지, 크기 변경
2. 슬라임 이미지(색감), 크기 변경
3. 슬라임 그림자 이미지 변경
4. 슬라임 얼룩자국 이미지(색감) 변경
5. 토끼 슬라임 최대 4단계로 변경
6. 맵 이동 및 재시작 과정에서 전투플레이어 삭제 후 생성하는 로직으로 변경
7. 1단계 슬라임이 점프할 때, 카메라 흔들림 효과 강화
8. 슬라임 시작 또는 분열할 때, 0.5초 무적 기능 추가

버그 수정 내역
1. 일반 슬라임이 본체로 인식되는 버그 수정
2. 간헐적으로 슬라임 얼룩 자국이 남아있는 버그 수정
3. 마지막 보스를 스킬로 잡을 때, 전투플레이어 오류 수정
4. 대쉬 중에 디버프를 받는 버그 수정
2024-05-12 17:41:13 +09:00

164 lines
4.6 KiB
C#

using System;
using System.Collections;
using System.Collections.Generic;
using Cinemachine;
using Sirenix.OdinInspector;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Rendering.Universal;
// ReSharper disable once CheckNamespace
namespace BlueWaterProject
{
public class CombatCamera : MonoBehaviour
{
[Title("초기화 방식")]
[SerializeField] private bool autoInit = true;
[field: Title("카메라")]
[field: SerializeField] public CinemachineVirtualCamera BaseCombatCamera { get; private set; }
private GameObject cinemachineCameras;
private List<CinemachineVirtualCamera> cineCamList;
private Vignette vignette;
private Coroutine lowHpVignetteCoroutine;
private float originalRotation;
private const int CINE_CAM_NUM = 1;
private void Awake()
{
if (autoInit)
{
Init();
}
CameraManager.Inst.CombatCamera = this;
CameraManager.Inst.MainCam = Camera.main;
vignette = GetEffect<Vignette>();
vignette.active = false;
}
private void Start()
{
if (!GameManager.Inst) return;
GameManager.Inst.OnInstantiateCombatPlayer += SetFollowAndLookAt;
}
private void OnDestroy()
{
if (!GameManager.Inst) return;
GameManager.Inst.OnInstantiateCombatPlayer -= SetFollowAndLookAt;
}
[Button("셋팅 초기화")]
private void Init()
{
cinemachineCameras = GameObject.Find("CinemachineCameras");
if (!cinemachineCameras)
{
Debug.LogError("cineCams is null error");
return;
}
BaseCombatCamera = cinemachineCameras.transform.Find("BaseCombatCamera")?.GetComponent<CinemachineVirtualCamera>();
if (!BaseCombatCamera)
{
Debug.LogError("BaseShipCam is null error");
return;
}
cineCamList = new List<CinemachineVirtualCamera>(CINE_CAM_NUM)
{
BaseCombatCamera
};
foreach (var cam in cineCamList)
{
cam.Priority = 0;
}
BaseCombatCamera.Priority = 1;
CameraManager.Inst.MainCam = Camera.main;
}
public void SetFollowAndLookAt(Transform target)
{
BaseCombatCamera.Follow = target;
//BaseCombatCamera.LookAt = target;
}
#region PostProcessing
public void ToggleEffect<T>(bool value) where T : VolumeComponent
{
var effect = GetEffect<T>();
if (effect == null)
{
print(typeof(T) + "효과가 없습니다.");
return;
}
effect.active = value;
}
private T GetEffect<T>() where T : VolumeComponent
{
var postProcessVolume = FindAnyObjectByType<Volume>();
if (postProcessVolume == null)
{
print("Volume 컴포넌트를 가진 오브젝트가 없습니다.");
return null;
}
postProcessVolume.profile.TryGet(out T effect);
return effect;
}
public void LowHpVignette()
{
if (lowHpVignetteCoroutine == null)
{
lowHpVignetteCoroutine = StartCoroutine(LowHpVignetteCoroutine());
}
}
public void DefaultHpVignette()
{
if (lowHpVignetteCoroutine != null)
{
StopCoroutine(lowHpVignetteCoroutine);
lowHpVignetteCoroutine = null;
vignette.active = false;
}
}
private IEnumerator LowHpVignetteCoroutine()
{
var startValue = 0.2f;
var endValue = 0.3f;
var time = 0f;
vignette.intensity.value = startValue;
vignette.active = true;
while (true)
{
time += Time.deltaTime * 2f;
vignette.intensity.value = Mathf.Lerp(startValue, endValue, time);
if (time >= 1f)
{
(startValue, endValue) = (endValue, startValue);
time = 0f;
}
yield return null;
}
}
#endregion
}
}