배경 쉐이더 추가
적 만들어주세요
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -1,3 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
@@ -8,7 +9,9 @@ public class Player : MonoBehaviour
|
||||
private Queue<GameObject> _bulletPool = new Queue<GameObject>();
|
||||
|
||||
public GameObject bulletPrefab;
|
||||
public int bulletCount = 30;
|
||||
public int bulletCount = 21;
|
||||
public GameObject backGround;
|
||||
public int moveSpeed = 20;
|
||||
|
||||
[Header("연사 설정")]
|
||||
public float fireRate = 0.1f; // 총알 발사 간격 (0.1초마다 1발)
|
||||
@@ -23,8 +26,8 @@ public class Player : MonoBehaviour
|
||||
_fireTimer = fireRate;
|
||||
|
||||
// 기존의 performed 대신 클릭 시작(started)과 종료(canceled) 이벤트를 연결합니다.
|
||||
InputManager.InputSystem.UI.Click.started += OnShootStarted;
|
||||
InputManager.InputSystem.UI.Click.canceled += OnShootCanceled;
|
||||
InputManager.InputSystem.Player.Click.started += OnShootStarted;
|
||||
InputManager.InputSystem.Player.Click.canceled += OnShootCanceled;
|
||||
|
||||
for (int i = 0; i < bulletCount; i++)
|
||||
{
|
||||
@@ -34,6 +37,14 @@ public class Player : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
private void FixedUpdate()
|
||||
{
|
||||
var readValue = InputManager.InputSystem.Player.Move.ReadValue<Vector2>();
|
||||
var moveDir = new Vector3(readValue.x, readValue.y, 0);
|
||||
transform.position += moveDir * (Time.fixedDeltaTime * moveSpeed);
|
||||
backGround.transform.position = transform.position;
|
||||
}
|
||||
|
||||
// 마우스를 클릭하기 시작했을 때
|
||||
private void OnShootStarted(InputAction.CallbackContext obj)
|
||||
{
|
||||
@@ -79,7 +90,7 @@ public class Player : MonoBehaviour
|
||||
|
||||
Vector2 direction = screenToWorldPoint - transform.position;
|
||||
var rad2Deg = Mathf.Atan2(direction.y, direction.x) * Mathf.Rad2Deg;
|
||||
transform.rotation = Quaternion.Euler(0, 0, rad2Deg - 90);
|
||||
transform.rotation = Quaternion.Euler(0, 0, rad2Deg + 90);
|
||||
|
||||
// 2. 연사 처리 로직
|
||||
_fireTimer += Time.deltaTime; // 타이머는 매 프레임 증가
|
||||
@@ -96,8 +107,8 @@ public class Player : MonoBehaviour
|
||||
{
|
||||
if (InputManager.InputSystem != null)
|
||||
{
|
||||
InputManager.InputSystem.UI.Click.started -= OnShootStarted;
|
||||
InputManager.InputSystem.UI.Click.canceled -= OnShootCanceled;
|
||||
InputManager.InputSystem.Player.Click.started -= OnShootStarted;
|
||||
InputManager.InputSystem.Player.Click.canceled -= OnShootCanceled;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user