43 lines
1.4 KiB
C#
43 lines
1.4 KiB
C#
|
|
using System.Collections;
|
||
|
|
using System.Collections.Generic;
|
||
|
|
using UnityEngine;
|
||
|
|
|
||
|
|
public class UICameraPositioner : MonoBehaviour
|
||
|
|
{
|
||
|
|
[SerializeField] Transform uiCameraTransform;
|
||
|
|
private PlayerUIRenderer uiCamera;
|
||
|
|
|
||
|
|
private readonly Vector3 alivePosition = new Vector3(1f, 1.5f, 2f);
|
||
|
|
private readonly Vector3 deadPosition = new Vector3(2.0f, 1.5f, 3.66f);
|
||
|
|
private readonly Vector3 meleeDeadPosition = new Vector3(1.2f, 1.5f, 1.14f);
|
||
|
|
private readonly Vector3 characterSelectPosition = new Vector3(1.206f, 1.214f,1.895f);
|
||
|
|
|
||
|
|
|
||
|
|
private void Awake()
|
||
|
|
{
|
||
|
|
uiCamera = uiCameraTransform.GetComponent<PlayerUIRenderer>();
|
||
|
|
}
|
||
|
|
private void Update()
|
||
|
|
{
|
||
|
|
if (uiCamera.CharacterSelectCanvasOpen())
|
||
|
|
{
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
Weapon currentWeaponConfig = Player.Instance.GetWeaponData();
|
||
|
|
if (currentWeaponConfig != null)
|
||
|
|
{
|
||
|
|
|
||
|
|
Vector3 moveToPosition = Player.Instance.IsAlive() ? alivePosition : currentWeaponConfig.weaponType == Weapon.WEAPON_TYPE.SWORD ? meleeDeadPosition : deadPosition;
|
||
|
|
uiCameraTransform.localPosition = Vector3.MoveTowards(uiCameraTransform.localPosition, moveToPosition, 5.0f * Time.deltaTime);
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
uiCameraTransform.localPosition = alivePosition;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public PlayerUIRenderer GetPlayerRenderer() => uiCamera;
|
||
|
|
public Transform GetPlayerRenderCameraTransform() => uiCameraTransform;
|
||
|
|
}
|