This commit is contained in:
manhduyhoang90
2026-05-09 09:00:14 +07:00
parent 48fa714dec
commit 4fc787e83f
50 changed files with 4057 additions and 7 deletions

View File

@@ -0,0 +1,65 @@
using UnityEngine;
using UnityEngine.InputSystem;
public class RedPlayerController : MonoBehaviour
{
public GameObject shield;
public GameObject bulletPrefab;
public Transform firePoint;
public float shootCooldown = 0.5f;
private float cooldownTimer;
private bool isDead = false;
void Update()
{
if (Keyboard.current == null)
return;
if (isDead)
return;
cooldownTimer -= Time.deltaTime;
HandleShield();
HandleShoot();
}
void HandleShield()
{
// Giữ F => bỏ khiên
bool holdingF =
Keyboard.current.kKey.isPressed;
shield.SetActive(!holdingF);
}
void HandleShoot()
{
// Chỉ bắn khi đang bỏ khiên
if (!shield.activeSelf &&
Keyboard.current.jKey.wasPressedThisFrame &&
cooldownTimer <= 0f)
{
Instantiate(
bulletPrefab,
firePoint.position,
firePoint.rotation
);
cooldownTimer = shootCooldown;
}
}
public void Die()
{
isDead = true;
GameManager.Instance.ShowWinner("BLUE WIN!");
}
}