Death Square Added

This commit is contained in:
2022-02-27 11:03:05 +03:00
parent 3496f6042a
commit 64fb6d3bcf
5 changed files with 80626 additions and 16345 deletions

View File

@@ -1,6 +1,8 @@
using System;
using Cinemachine;
using Level;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.U2D;
namespace Camera
@@ -20,20 +22,18 @@ namespace Camera
{
_cinemachineVirtualCamera = GetComponent<CinemachineVirtualCamera>();
pixelPerfectCamera = GameObject.FindObjectOfType<PixelPerfectCamera>();
LevelManager.Instance.OnLevelChanged.AddListener(UpdateCamera);
}
private void Update()
private void UpdateCamera()
{
if (LevelManager.Instance.CurrentLevel?.FixedCameraPoint == null)
if (LevelManager.Instance.CurrentLevel.FixedCameraPoint == null)
{
if (_cinemachineVirtualCamera.Follow == null)
{
_cinemachineVirtualCamera.Follow = LevelManager.Instance.Player.transform;
pixelPerfectCamera.refResolutionX = FollowResolutionX;
pixelPerfectCamera.refResolutionY = FollowResolutionY;
}
_cinemachineVirtualCamera.Follow = LevelManager.Instance.Player.transform;
pixelPerfectCamera.refResolutionX = FollowResolutionX;
pixelPerfectCamera.refResolutionY = FollowResolutionY;
}
else if (_cinemachineVirtualCamera.Follow != LevelManager.Instance.CurrentLevel.FixedCameraPoint)
else
{
_cinemachineVirtualCamera.Follow = LevelManager.Instance.CurrentLevel.FixedCameraPoint;
pixelPerfectCamera.refResolutionX = FixedResolutionX;

View File

@@ -2,6 +2,7 @@ using System;
using System.Collections.Generic;
using UI;
using UnityEngine;
using UnityEngine.Events;
namespace Level
{
@@ -38,6 +39,8 @@ namespace Level
private Level currentLevel = null;
public Level CurrentLevel => currentLevel;
public UnityEvent OnLevelChanged = new UnityEvent();
private void Awake()
{
if (_instance == null)
@@ -92,6 +95,7 @@ namespace Level
Player.GetComponent<Rigidbody2D>().velocity = Vector2.zero;
UIManager.Instance.CloseAllCanvases();
OnLevelChanged?.Invoke();
}
public void DisableAllLevels()