Merge pull request '후크가 사라져잇' (#9) from feature/hyeonsu-blackjack-card-bgm into main

Reviewed-on: #9
This commit was merged in pull request #9.
This commit is contained in:
2026-06-23 02:02:40 +00:00
131 changed files with 8478 additions and 41 deletions

View File

@@ -39,6 +39,11 @@ public class CardSpawnTest : MonoBehaviour
public TMP_Text dealerScoreText;
public TMP_Text resultText;
[Header("Dealer Card UI")]
public Image[] dealerCardImages;
public Sprite dealerCardBackSprite;
public Sprite[] cardSprites;
[Header("Win Mark UI")]
public GameObject[] playerWinMarks;
public GameObject[] dealerWinMarks;
@@ -57,6 +62,8 @@ public class CardSpawnTest : MonoBehaviour
private List<string> playerCards = new List<string>();
private List<string> dealerCards = new List<string>();
private Dictionary<string, Sprite> cardSpriteMap = new Dictionary<string, Sprite>();
private int playerHitIndex = 0;
private int dealerHitIndex = 0;
@@ -71,11 +78,36 @@ public class CardSpawnTest : MonoBehaviour
private bool hasMatchStarted = false;
private bool isEndingMatch = false;
void Awake()
{
BuildCardSpriteMap();
}
void Start()
{
PrepareBeforeStart();
}
void BuildCardSpriteMap()
{
cardSpriteMap.Clear();
foreach (Sprite sprite in cardSprites)
{
if (sprite == null)
{
continue;
}
string key = NormalizeCardName(sprite.name);
if (!cardSpriteMap.ContainsKey(key))
{
cardSpriteMap.Add(key, sprite);
}
}
}
void PrepareBeforeStart()
{
ClearSpawnedCards();
@@ -96,6 +128,7 @@ void PrepareBeforeStart()
isEndingMatch = false;
HideAllWinMarks();
HideDealerCardUI();
if (resultText != null)
{
@@ -104,12 +137,12 @@ void PrepareBeforeStart()
if (playerScoreText != null)
{
playerScoreText.text = "Player: 0";
playerScoreText.text = "플레이어: 0";
}
if (dealerScoreText != null)
{
dealerScoreText.text = "Dealer: ?";
dealerScoreText.text = "선장: ?";
}
if (hitButton != null)
@@ -122,7 +155,7 @@ void PrepareBeforeStart()
standButton.interactable = false;
}
Debug.Log("Blackjack ready. Waiting for player seated.");
Debug.Log("블랙잭 준비 완료. 플레이어가 앉기를 기다리는 중.");
}
public void StartMatch()
@@ -142,12 +175,13 @@ public void StartMatch()
HideAllWinMarks();
StartRound();
Debug.Log("Blackjack Match Start");
Debug.Log("블랙잭 승부 시작");
}
void StartRound()
{
ClearSpawnedCards();
HideDealerCardUI();
BuildDeck();
isPlayerTurn = true;
@@ -182,13 +216,8 @@ void StartRound()
UpdateScoreUI(false);
Debug.Log("New Round Start");
Debug.Log("Player Score: " + CalculateScore(playerCards));
if (dealerCards.Count > 0)
{
Debug.Log("Dealer Open Card Score: " + GetCardValue(dealerCards[0]));
}
Debug.Log("새 라운드 시작");
Debug.Log("플레이어 점수: " + CalculateScore(playerCards));
}
void BuildDeck()
@@ -203,14 +232,14 @@ void BuildDeck()
}
}
Debug.Log("Deck Count: " + deck.Count);
Debug.Log("덱 카드 수: " + deck.Count);
}
GameObject DrawRandomCard()
{
if (deck.Count == 0)
{
Debug.LogWarning("Deck is empty.");
Debug.LogWarning("덱이 비어 있습니다.");
return null;
}
@@ -245,6 +274,10 @@ GameObject DealDealerCard(Transform pos, bool faceDown)
}
dealerCards.Add(prefab.name);
int dealerCardIndex = dealerCards.Count - 1;
UpdateDealerCardUI(dealerCardIndex, prefab.name, faceDown);
return SpawnCard(prefab, pos, faceDown);
}
@@ -257,13 +290,13 @@ public void Hit()
if (!isPlayerTurn)
{
Debug.Log("You already stood. Hit is disabled.");
Debug.Log("이미 멈췄습니다. 카드를 더 받을 수 없습니다.");
return;
}
if (playerHitIndex >= playerHitPositions.Length)
{
Debug.Log("No more player card positions.");
Debug.Log("플레이어 카드 위치가 더 이상 없습니다.");
return;
}
@@ -273,12 +306,12 @@ public void Hit()
UpdateScoreUI(false);
int playerScore = CalculateScore(playerCards);
Debug.Log("Player Score After Hit: " + playerScore);
Debug.Log("카드 받은 후 플레이어 점수: " + playerScore);
if (playerScore > 21)
{
Debug.Log("Player Bust! Dealer wins this round.");
EndRound(-1, "Player Bust!\nDealer Wins Round!");
Debug.Log("플레이어 버스트! 이번 라운드는 선장 승리.");
EndRound(-1, "버스트!\n선장 승리!");
}
}
@@ -301,10 +334,11 @@ public void Stand()
dealerHiddenCard.transform.rotation = Quaternion.Euler(frontRotation);
}
RevealDealerCardsUI();
UpdateScoreUI(true);
Debug.Log("Stand: Dealer hidden card opened.");
Debug.Log("Dealer Score: " + CalculateScore(dealerCards));
Debug.Log("스탠드: 선장의 숨겨진 카드 공개.");
Debug.Log("선장 점수: " + CalculateScore(dealerCards));
DealerTurn();
}
@@ -315,7 +349,7 @@ void DealerTurn()
{
if (dealerHitIndex >= dealerHitPositions.Length)
{
Debug.Log("No more dealer card positions.");
Debug.Log("선장 카드 위치가 더 이상 없습니다.");
break;
}
@@ -324,7 +358,7 @@ void DealerTurn()
UpdateScoreUI(true);
Debug.Log("Dealer draws a card. Dealer Score: " + CalculateScore(dealerCards));
Debug.Log("선장이 카드를 받았습니다. 선장 점수: " + CalculateScore(dealerCards));
}
JudgeResult();
@@ -335,24 +369,24 @@ void JudgeResult()
int playerScore = CalculateScore(playerCards);
int dealerScore = CalculateScore(dealerCards);
Debug.Log("Final Player Score: " + playerScore);
Debug.Log("Final Dealer Score: " + dealerScore);
Debug.Log("최종 플레이어 점수: " + playerScore);
Debug.Log("최종 선장 점수: " + dealerScore);
if (dealerScore > 21)
{
EndRound(1, "Dealer Bust!\nPlayer Wins Round!");
EndRound(1, "선장 버스트!\n플레이어 승리!");
}
else if (playerScore > dealerScore)
{
EndRound(1, "Player Wins Round!");
EndRound(1, "플레이어 승리!");
}
else if (playerScore < dealerScore)
{
EndRound(-1, "Dealer Wins Round!");
EndRound(-1, "선장 승리!");
}
else
{
EndRound(0, "Draw!\nNo Score");
EndRound(0, "무승부!\n승점 없음");
}
}
@@ -395,8 +429,8 @@ void EndRound(int winner, string message)
if (playerWinCount >= targetWinCount)
{
isMatchOver = true;
ShowResult("Final Result\nPlayer Wins!");
Debug.Log("Final Result: Player Wins!");
ShowResult("최종 결과\n플레이어 승리!");
Debug.Log("최종 결과: 플레이어 승리");
StartCoroutine(EndMatchAfterDelay());
return;
@@ -405,8 +439,8 @@ void EndRound(int winner, string message)
if (dealerWinCount >= targetWinCount)
{
isMatchOver = true;
ShowResult("Final Result\nDealer Wins!\nTry Again!");
Debug.Log("Final Result: Dealer Wins! Restarting match.");
ShowResult("최종 결과\n선장 승리!\n다시 도전!");
Debug.Log("최종 결과: 선장 승리. 승부를 다시 시작합니다.");
StartCoroutine(RestartMatchAfterLose());
return;
@@ -461,7 +495,7 @@ IEnumerator RestartMatchAfterLose()
HideAllWinMarks();
StartRound();
Debug.Log("Blackjack restarted after player lost.");
Debug.Log("패배 후 블랙잭을 다시 시작합니다.");
}
void UpdateScoreUI(bool showDealerFullScore)
@@ -470,18 +504,18 @@ void UpdateScoreUI(bool showDealerFullScore)
if (playerScoreText != null)
{
playerScoreText.text = "Player: " + playerScore;
playerScoreText.text = "플레이어: " + playerScore;
}
if (dealerScoreText != null)
{
if (showDealerFullScore)
{
dealerScoreText.text = "Dealer: " + CalculateScore(dealerCards);
dealerScoreText.text = "선장: " + CalculateScore(dealerCards);
}
else
{
dealerScoreText.text = "Dealer: ?";
dealerScoreText.text = "선장: ?";
}
}
}
@@ -574,7 +608,7 @@ int GetCardValue(string cardName)
return int.Parse(match.Value);
}
Debug.LogWarning("Card value not found: " + cardName);
Debug.LogWarning("카드 값을 찾을 수 없습니다: " + cardName);
return 0;
}
@@ -587,7 +621,7 @@ GameObject SpawnCard(GameObject prefab, Transform pos, bool faceDown)
{
if (prefab == null || pos == null)
{
Debug.LogWarning("Card prefab or position is missing.");
Debug.LogWarning("카드 프리팹 또는 위치가 비어 있습니다.");
return null;
}
@@ -607,4 +641,85 @@ GameObject SpawnCard(GameObject prefab, Transform pos, bool faceDown)
return card;
}
void HideDealerCardUI()
{
if (dealerCardImages == null)
{
return;
}
foreach (Image image in dealerCardImages)
{
if (image == null)
{
continue;
}
image.sprite = null;
image.gameObject.SetActive(false);
}
}
void UpdateDealerCardUI(int index, string cardName, bool faceDown)
{
if (dealerCardImages == null || index < 0 || index >= dealerCardImages.Length)
{
return;
}
Image targetImage = dealerCardImages[index];
if (targetImage == null)
{
return;
}
targetImage.gameObject.SetActive(true);
if (faceDown)
{
targetImage.sprite = dealerCardBackSprite;
return;
}
targetImage.sprite = GetCardSprite(cardName);
}
void RevealDealerCardsUI()
{
for (int i = 0; i < dealerCards.Count; i++)
{
UpdateDealerCardUI(i, dealerCards[i], false);
}
}
Sprite GetCardSprite(string cardName)
{
string key = NormalizeCardName(cardName);
if (cardSpriteMap.TryGetValue(key, out Sprite sprite))
{
return sprite;
}
Debug.LogWarning("카드 UI 이미지를 찾을 수 없습니다: " + cardName);
return null;
}
string NormalizeCardName(string cardName)
{
if (string.IsNullOrEmpty(cardName))
{
return "";
}
return cardName
.Replace("(Clone)", "")
.Replace(" ", "")
.Replace("_", "")
.Replace("-", "")
.Trim()
.ToLower();
}
}

View File

@@ -5,5 +5,6 @@ public enum Zone
None,
Ocean,
Island,
Seaside
Seaside,
BlackjackGame
}