2022-02-25 23:38:09 +03:00
|
|
|
using Cinemachine;
|
2022-02-27 00:43:46 +03:00
|
|
|
using Level;
|
2022-02-25 23:38:09 +03:00
|
|
|
using UnityEngine;
|
2022-02-27 00:43:46 +03:00
|
|
|
using UnityEngine.U2D;
|
2022-02-25 23:38:09 +03:00
|
|
|
|
|
|
|
namespace Camera
|
|
|
|
{
|
|
|
|
public class CameraPlayerFinder : MonoBehaviour
|
|
|
|
{
|
2022-02-27 10:41:23 +03:00
|
|
|
[SerializeField] private int FixedResolutionX = 426;
|
|
|
|
[SerializeField] private int FixedResolutionY = 240;
|
|
|
|
[SerializeField] private int FollowResolutionX = 278;
|
|
|
|
[SerializeField] private int FollowResolutionY = 162;
|
|
|
|
|
2022-02-25 23:38:09 +03:00
|
|
|
private CinemachineVirtualCamera _cinemachineVirtualCamera;
|
2022-02-27 00:43:46 +03:00
|
|
|
private PixelPerfectCamera pixelPerfectCamera = null;
|
2022-02-25 23:38:09 +03:00
|
|
|
|
2022-02-27 10:41:23 +03:00
|
|
|
|
2022-02-25 23:38:09 +03:00
|
|
|
private void Awake()
|
|
|
|
{
|
|
|
|
_cinemachineVirtualCamera = GetComponent<CinemachineVirtualCamera>();
|
2022-02-27 00:43:46 +03:00
|
|
|
pixelPerfectCamera = GameObject.FindObjectOfType<PixelPerfectCamera>();
|
2022-02-25 23:38:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
private void Update()
|
|
|
|
{
|
2022-02-27 00:43:46 +03:00
|
|
|
if (LevelManager.Instance.CurrentLevel?.FixedCameraPoint == null)
|
|
|
|
{
|
|
|
|
if (_cinemachineVirtualCamera.Follow == null)
|
|
|
|
{
|
|
|
|
_cinemachineVirtualCamera.Follow = LevelManager.Instance.Player.transform;
|
2022-02-27 10:41:23 +03:00
|
|
|
pixelPerfectCamera.refResolutionX = FollowResolutionX;
|
|
|
|
pixelPerfectCamera.refResolutionY = FollowResolutionY;
|
2022-02-27 00:43:46 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (_cinemachineVirtualCamera.Follow != LevelManager.Instance.CurrentLevel.FixedCameraPoint)
|
|
|
|
{
|
|
|
|
_cinemachineVirtualCamera.Follow = LevelManager.Instance.CurrentLevel.FixedCameraPoint;
|
2022-02-27 10:41:23 +03:00
|
|
|
pixelPerfectCamera.refResolutionX = FixedResolutionX;
|
|
|
|
pixelPerfectCamera.refResolutionY = FixedResolutionY;
|
2022-02-27 00:43:46 +03:00
|
|
|
}
|
2022-02-25 23:38:09 +03:00
|
|
|
}
|
|
|
|
}
|
2022-02-27 00:43:46 +03:00
|
|
|
}
|