[Update] 로직 변경 및 회전 문제 해결 등

1. 회전 시 펜스가 사라지거나 남았던 현상 해결
   - 펜스의 LOD가 여러개여서 필요한것만 남기고 삭제

2. 실드 ui 조정
   - 별도의 스크립트와 핸들러를 이용해 빈 오브젝트(앵커)에 소속하게 변경
   - pc에서는 화면 우측 상단으로 이동
   - 모바일에서는 버튼 안으로 이동

3. 폰트 변경
This commit is contained in:
jongjae0305
2026-04-22 13:56:03 +09:00
parent 6c84f865d8
commit ed1e24be1d
22 changed files with 14832 additions and 907 deletions
+38 -71
View File
@@ -1,56 +1,46 @@
using TMPro;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
public class PlayerController : MonoBehaviour
{
private Rigidbody playerRigidbody;
[Header("Movement")]
public float speed = 8f;
private Rigidbody playerRigidbody;
public VirtualJoystick joystick;
[Header("Shield System")]
public int shieldCount = 3;
private bool isShieldActive = false;
public GameObject shieldVisual;
public Image shieldIcon;
public TextMeshProUGUI countText;
// [추가] 조이스틱 연결용 변수
public VirtualJoystick joystick;
public void Die()
{
gameObject.SetActive(false);
GameManager gm = FindFirstObjectByType<GameManager>();
gm.EndGame();
}
public ShieldUIHandler shieldUI; // UI 전용 스크립트 참조
void Start()
{
playerRigidbody = GetComponent<Rigidbody>();
if (GameSettings.IsMobile)
{
if (shieldIcon != null) shieldIcon.gameObject.SetActive(false);
if (countText != null) countText.gameObject.SetActive(false);
}
else
{
UpdateShieldUI();
}
// 초기 UI 상태 반영
if (shieldUI != null) shieldUI.UpdateShieldUI(shieldCount);
}
void Update()
{
float x = 0;
float z = 0;
HandleMovement();
// PC 입력 처리 (모바일 아닐 때만)
if (!GameSettings.IsMobile && Input.GetKeyDown(KeyCode.Alpha1))
{
ActivateShieldLogic();
}
}
void HandleMovement()
{
float x = 0, z = 0;
// [수정] 플랫폼에 따라 입력 방식 분기
if (GameSettings.IsMobile && joystick != null)
{
Vector2 input = joystick.GetInput();
x = input.x;
z = input.y;
x = input.x; z = input.y;
}
else
{
@@ -58,67 +48,44 @@ public class PlayerController : MonoBehaviour
z = Input.GetAxis("Vertical");
}
float xSpeed = x * speed;
float zSpeed = z * speed;
playerRigidbody.linearVelocity = new Vector3(x * speed, 0f, z * speed);
bool moveInput = (x != 0 || z != 0);
Vector3 newVelocity = new Vector3(xSpeed, 0f, zSpeed);
playerRigidbody.linearVelocity = newVelocity;
if (moveInput)
if (x != 0 || z != 0)
{
Vector3 moveDirection = new Vector3(x, 0f, z);
Quaternion newRotation = Quaternion.LookRotation(moveDirection);
transform.rotation = newRotation;
}
// PC일 때만 키보드 실드 입력 허용
if (!GameSettings.IsMobile && Input.GetKeyDown(KeyCode.Alpha1))
{
ActivateShieldLogic();
transform.rotation = Quaternion.LookRotation(new Vector3(x, 0f, z));
}
// 애니메이션
Animator anim = GetComponentInChildren<Animator>();
if (anim != null)
{
anim.SetBool("isMoving", moveInput);
}
if (anim != null) anim.SetBool("isMoving", (x != 0 || z != 0));
}
public void ActivateShieldLogic()
{
if (shieldCount > 0 && !isShieldActive)
{
StartCoroutine(ActivateShield());
StartCoroutine(ActivateShieldRoutine());
}
}
void UpdateShieldUI()
{
if (countText != null)
{
countText.text = shieldCount.ToString();
if (shieldCount <= 0)
{
countText.gameObject.SetActive(false);
if (shieldIcon != null)
{
shieldIcon.color = new Color(0.2f, 0.2f, 0.2f, 0.5f);
}
}
}
}
IEnumerator ActivateShield()
private IEnumerator ActivateShieldRoutine()
{
isShieldActive = true;
shieldCount--;
UpdateShieldUI();
// UI 업데이트 위임
if (shieldUI != null) shieldUI.UpdateShieldUI(shieldCount);
if (shieldVisual != null) shieldVisual.SetActive(true);
yield return new WaitForSeconds(2f);
if (shieldVisual != null) shieldVisual.SetActive(false);
isShieldActive = false;
}
public void Die()
{
gameObject.SetActive(false);
FindFirstObjectByType<GameManager>()?.EndGame();
}
}