블랙잭 NPC 코인 및 AI Navigation 기능 추가
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using TMPro;
|
||||
using UnityEngine.Events;
|
||||
|
||||
public class CardSpawnTest : MonoBehaviour
|
||||
{
|
||||
@@ -45,6 +46,10 @@ public class CardSpawnTest : MonoBehaviour
|
||||
[Header("Match Setting")]
|
||||
public int targetWinCount = 3;
|
||||
public float nextRoundDelay = 2f;
|
||||
public float matchEndDelay = 3f;
|
||||
|
||||
[Header("Match End Event")]
|
||||
public UnityEvent onMatchEnded;
|
||||
|
||||
private List<GameObject> deck = new List<GameObject>();
|
||||
private List<GameObject> spawnedCards = new List<GameObject>();
|
||||
@@ -60,23 +65,84 @@ public class CardSpawnTest : MonoBehaviour
|
||||
|
||||
private GameObject dealerHiddenCard;
|
||||
|
||||
private bool isPlayerTurn = true;
|
||||
private bool isGameOver = false;
|
||||
private bool isPlayerTurn = false;
|
||||
private bool isGameOver = true;
|
||||
private bool isMatchOver = false;
|
||||
private bool hasMatchStarted = false;
|
||||
private bool isEndingMatch = false;
|
||||
|
||||
void Start()
|
||||
{
|
||||
StartMatch();
|
||||
PrepareBeforeStart();
|
||||
}
|
||||
|
||||
void StartMatch()
|
||||
void PrepareBeforeStart()
|
||||
{
|
||||
ClearSpawnedCards();
|
||||
|
||||
playerCards.Clear();
|
||||
dealerCards.Clear();
|
||||
|
||||
playerHitIndex = 0;
|
||||
dealerHitIndex = 0;
|
||||
|
||||
playerWinCount = 0;
|
||||
dealerWinCount = 0;
|
||||
|
||||
isPlayerTurn = false;
|
||||
isGameOver = true;
|
||||
isMatchOver = false;
|
||||
hasMatchStarted = false;
|
||||
isEndingMatch = false;
|
||||
|
||||
HideAllWinMarks();
|
||||
|
||||
if (resultText != null)
|
||||
{
|
||||
resultText.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
if (playerScoreText != null)
|
||||
{
|
||||
playerScoreText.text = "Player: 0";
|
||||
}
|
||||
|
||||
if (dealerScoreText != null)
|
||||
{
|
||||
dealerScoreText.text = "Dealer: ?";
|
||||
}
|
||||
|
||||
if (hitButton != null)
|
||||
{
|
||||
hitButton.interactable = false;
|
||||
}
|
||||
|
||||
if (standButton != null)
|
||||
{
|
||||
standButton.interactable = false;
|
||||
}
|
||||
|
||||
Debug.Log("Blackjack ready. Waiting for player seated.");
|
||||
}
|
||||
|
||||
public void StartMatch()
|
||||
{
|
||||
if (hasMatchStarted)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
hasMatchStarted = true;
|
||||
|
||||
playerWinCount = 0;
|
||||
dealerWinCount = 0;
|
||||
isMatchOver = false;
|
||||
isEndingMatch = false;
|
||||
|
||||
HideAllWinMarks();
|
||||
StartRound();
|
||||
|
||||
Debug.Log("Blackjack Match Start");
|
||||
}
|
||||
|
||||
void StartRound()
|
||||
@@ -118,7 +184,11 @@ void StartRound()
|
||||
|
||||
Debug.Log("New Round Start");
|
||||
Debug.Log("Player Score: " + CalculateScore(playerCards));
|
||||
Debug.Log("Dealer Open Card Score: " + GetCardValue(dealerCards[0]));
|
||||
|
||||
if (dealerCards.Count > 0)
|
||||
{
|
||||
Debug.Log("Dealer Open Card Score: " + GetCardValue(dealerCards[0]));
|
||||
}
|
||||
}
|
||||
|
||||
void BuildDeck()
|
||||
@@ -327,6 +397,8 @@ void EndRound(int winner, string message)
|
||||
isMatchOver = true;
|
||||
ShowResult("Final Result\nPlayer Wins!");
|
||||
Debug.Log("Final Result: Player Wins!");
|
||||
|
||||
StartCoroutine(EndMatchAfterDelay());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -335,6 +407,8 @@ void EndRound(int winner, string message)
|
||||
isMatchOver = true;
|
||||
ShowResult("Final Result\nDealer Wins!");
|
||||
Debug.Log("Final Result: Dealer Wins!");
|
||||
|
||||
StartCoroutine(EndMatchAfterDelay());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -351,6 +425,20 @@ IEnumerator StartNextRoundAfterDelay()
|
||||
}
|
||||
}
|
||||
|
||||
IEnumerator EndMatchAfterDelay()
|
||||
{
|
||||
if (isEndingMatch)
|
||||
{
|
||||
yield break;
|
||||
}
|
||||
|
||||
isEndingMatch = true;
|
||||
|
||||
yield return new WaitForSeconds(matchEndDelay);
|
||||
|
||||
onMatchEnded?.Invoke();
|
||||
}
|
||||
|
||||
void UpdateScoreUI(bool showDealerFullScore)
|
||||
{
|
||||
int playerScore = CalculateScore(playerCards);
|
||||
|
||||
Reference in New Issue
Block a user