Merge pull request '블랙잭 NPC 코인 및 AI Navigation 기능 추가' (#7) from feature/hyeonsu-blackjack-restore into main

Reviewed-on: #7
This commit was merged in pull request #7.
This commit is contained in:
2026-06-19 06:35:40 +00:00
795 changed files with 49564 additions and 55 deletions

View File

@@ -0,0 +1,73 @@
using UnityEngine;
using TMPro;
public class CoinManager : MonoBehaviour
{
public static CoinManager Instance;
[Header("Coin Data")]
public int currentCoins = 0;
[Header("UI")]
public TMP_Text coinText;
[Header("Scene Setting")]
public bool dontDestroyOnLoad = true;
void Awake()
{
if (Instance != null && Instance != this)
{
Destroy(gameObject);
return;
}
Instance = this;
if (dontDestroyOnLoad)
{
DontDestroyOnLoad(gameObject);
}
}
void Start()
{
UpdateCoinUI();
}
public void AddCoin(int amount)
{
currentCoins += amount;
UpdateCoinUI();
Debug.Log("Coin Added: " + amount + " / Total Coin: " + currentCoins);
}
public bool SpendCoin(int amount)
{
if (currentCoins < amount)
{
Debug.Log("Not enough coins. Current: " + currentCoins + " / Need: " + amount);
return false;
}
currentCoins -= amount;
UpdateCoinUI();
Debug.Log("Coin Spent: " + amount + " / Total Coin: " + currentCoins);
return true;
}
public int GetCoinCount()
{
return currentCoins;
}
void UpdateCoinUI()
{
if (coinText != null)
{
coinText.text = "Coin: " + currentCoins;
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 3730fd3e77bda8849aedc74946d2254a

View File

@@ -0,0 +1,145 @@
using UnityEngine;
using UnityEngine.XR.Interaction.Toolkit;
using UnityEngine.XR.Interaction.Toolkit.Interactables;
public class CoinPickup : MonoBehaviour
{
[Header("Coin Setting")]
public int coinValue = 1;
[Header("Visual Spin")]
public Transform visualRoot;
public bool rotate = true;
public float rotateSpeed = 180f;
[Tooltip("게임 코인처럼 세로로 빙글빙글 돌 때 보통 Y축")]
public Vector3 rotateAxis = Vector3.up;
[Header("Float Motion")]
public bool floatMotion = true;
public float floatHeight = 0.08f;
public float floatSpeed = 2f;
[Header("Sound")]
public AudioSource pickupSound;
private bool isCollected = false;
private Vector3 startPosition;
private XRSimpleInteractable simpleInteractable;
void Awake()
{
simpleInteractable = GetComponent<XRSimpleInteractable>();
if (simpleInteractable != null)
{
simpleInteractable.selectEntered.AddListener(OnSelected);
}
else
{
Debug.LogWarning("XRSimpleInteractable not found on coin.");
}
if (visualRoot == null)
{
visualRoot = transform;
}
}
void OnDestroy()
{
if (simpleInteractable != null)
{
simpleInteractable.selectEntered.RemoveListener(OnSelected);
}
}
void Start()
{
startPosition = transform.position;
}
void Update()
{
if (isCollected)
{
return;
}
if (rotate && visualRoot != null)
{
visualRoot.Rotate(rotateAxis.normalized, rotateSpeed * Time.deltaTime, Space.Self);
}
if (floatMotion)
{
float yOffset = Mathf.Sin(Time.time * floatSpeed) * floatHeight;
transform.position = startPosition + new Vector3(0f, yOffset, 0f);
}
}
private void OnSelected(SelectEnterEventArgs args)
{
Debug.Log("Coin selected by XR Simple Interactable.");
CollectCoin();
}
public void CollectCoin()
{
if (isCollected)
{
return;
}
isCollected = true;
Debug.Log("CollectCoin called.");
if (CoinManager.Instance != null)
{
CoinManager.Instance.AddCoin(coinValue);
}
else
{
Debug.LogWarning("CoinManager not found.");
}
HideCoinImmediately();
if (pickupSound != null && pickupSound.clip != null)
{
pickupSound.transform.parent = null;
pickupSound.Play();
Destroy(pickupSound.gameObject, pickupSound.clip.length);
}
Destroy(gameObject);
}
void HideCoinImmediately()
{
MeshRenderer[] renderers = GetComponentsInChildren<MeshRenderer>();
foreach (MeshRenderer renderer in renderers)
{
renderer.enabled = false;
}
Collider[] colliders = GetComponentsInChildren<Collider>();
foreach (Collider collider in colliders)
{
collider.enabled = false;
}
Rigidbody rb = GetComponent<Rigidbody>();
if (rb != null)
{
rb.isKinematic = true;
rb.useGravity = false;
}
if (simpleInteractable != null)
{
simpleInteractable.enabled = false;
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 6ccf1d0aa82d6794785d3b8d3318a8a6