KLingo Project Documentation 1.0.0
Unreal Engine 5.6 C++ Project Documentation
로딩중...
검색중...
일치하는것 없음
ALingoGameMode.cpp
이 파일의 문서화 페이지로 가기
1// Copyright (c) 2025 Doppleddiggong. All rights reserved. Unauthorized copying, modification, or distribution of this file, via any medium is strictly prohibited. Proprietary and confidential.
2
3
4#include "ALingoGameMode.h"
5#include "ALingoGameState.h"
6#include "ALingoPlayerState.h"
7#include "APlayerControl.h"
8#include "luggage.h"
9#include "UBroadcastManager.h"
10#include "GameLogging.h"
11#include "TimerManager.h"
12#include "TutorialComponent.h"
13#include "ULingoGameHelper.h"
14
15#include "Engine/World.h"
16#include "GameFramework/PlayerState.h"
17
19{
20 // GameState와 PlayerState 클래스 설정
21 GameStateClass = ALingoGameState::StaticClass();
22 PlayerStateClass = ALingoPlayerState::StaticClass();
23
24 // Tick 비활성화 (Timer 기반으로 동작)
25 PrimaryActorTick.bCanEverTick = false;
26}
27
29{
30 auto PSList = ULingoGameHelper::GetLingoPlayerStateList(GetWorld());
31 const int32 PlayerCount = PSList.Num();
32
33 if (PlayerCount == 1)
34 {
35 PSList[0]->QuestRole = EQuestRole::Both;
36 }
37 else if (PlayerCount >= 2)
38 {
39 PSList[0]->QuestRole = EQuestRole::OnlyQuestion1;
40 PSList[1]->QuestRole = EQuestRole::OnlyQuestion2;
41 }
42}
43
45{
46 if (!HasAuthority())
47 return;
48
50
51 if (auto GS = GetGameState<ALingoGameState>())
52 {
53 GS->SetReadScenarioData(InResponseData);
54
55 GS->SetAllCompassVisibility(false);
56 GS->SetCompassVisibilityByTag("ReadQuest", true);
57 }
58}
59
61{
62 if (!HasAuthority())
63 return;
64
65 // UpdateQuestRole();
66
67 if (auto GS = GetGameState<ALingoGameState>())
68 {
69 GS->SetListenScenarioData(InResponseData);
70
71 GS->SetAllCompassVisibility(false);
72 GS->SetCompassVisibilityByTag("ListenQuest", true);
73 }
74}
75
76void ALingoGameMode::HandleLuggageSelection(APlayerState* Player, Aluggage* luggage)
77{
78 if (!HasAuthority())
79 return;
80
81 if (!Player || !luggage)
82 return;
83
84 ALingoPlayerState* LingoPlayerState = Cast<ALingoPlayerState>(Player);
85 if (!LingoPlayerState)
86 return;
87
88 // 정답 판정
89 if ( ValidateAnswer(LingoPlayerState, luggage) )
90 {
91 HandleCorrectAnswer(LingoPlayerState);
92 }
93 else
94 {
95 // 틀린 항목 확인
96 bool bSymbolCorrect = (LingoPlayerState->SelectedWord1 == luggage->Target1);
97 bool bColorCorrect = (LingoPlayerState->SelectedWord2 == luggage->Target2);
98
99 HandleWrongAnswer(LingoPlayerState, bSymbolCorrect, bColorCorrect);
100 }
101}
102
104{
105 if (!Player || !Luggage)
106 return false;
107
108 const bool bSymbolCorrect = (Player->SelectedWord1 == Luggage->Target1);
109 const bool bColorCorrect = (Player->SelectedWord2 == Luggage->Target2);
110
111 PRINTLOG(TEXT("[GameMode] ValidateAnswer - Symbol: %s vs %s (%s), Color: %s vs %s (%s)"),
112 *Player->SelectedWord1, *Luggage->Target1, bSymbolCorrect ? TEXT("Correct") : TEXT("Wrong"),
113 *Player->SelectedWord2, *Luggage->Target2, bColorCorrect ? TEXT("Correct") : TEXT("Wrong"));
114
115 return bSymbolCorrect && bColorCorrect;
116}
117
119{
120 if (!HasAuthority() )
121 return;
122
123 if (!Player)
124 return;
125
126 ALingoGameState* LingoGameState = GetGameState<ALingoGameState>();
127 if (!LingoGameState)
128 return;
129
130 // 타이머 중지
131 LingoGameState->StopMissionTimer();
132}
133
134void ALingoGameMode::HandleWrongAnswer(ALingoPlayerState* Player, bool bSymbolCorrect, bool bColorCorrect)
135{
136 if (!HasAuthority())
137 return;
138
139 if (!Player)
140 return;
141
142 ALingoGameState* LingoGameState = GetGameState<ALingoGameState>();
143 if (!LingoGameState)
144 return;
145
146 // 타이머 패널티
147 constexpr float Penalty = 30.f;
148 LingoGameState->DecreaseMissionTimer(Penalty);
149
150 // 틀린 항목 판정
151 if (!bSymbolCorrect)
152 {
153 Player->SelectedWord1 = TEXT("");
154 Player->bWrongWord1 = true;
155 PRINTLOG(TEXT("[GameMode] Symbol was wrong - Cleared selection"));
156 }
157
158 if (!bColorCorrect)
159 {
160 Player->SelectedWord2 = TEXT("");
161 Player->bWrongWord2 = true;
162 PRINTLOG(TEXT("[GameMode] Color was wrong - Cleared selection"));
163 }
164
165 // 시도 횟수 증가
166 Player->AttemptCount++;
167
168 PRINTLOG(TEXT("[GameMode] HandleWrongAnswer - Attempt count: %d"), Player->AttemptCount);
169}
APlayerControl 선언에 대한 Doxygen 주석을 제공합니다.
YiSan 전반에서 사용하는 공용 인터페이스를 선언합니다.
#define PRINTLOG(fmt,...)
Definition GameLogging.h:30
void HandleCorrectAnswer(class ALingoPlayerState *Player)
정답 처리
void HandleWrongAnswer(class ALingoPlayerState *Player, bool bSymbolCorrect, bool bColorCorrect)
오답 처리
void BeginReadQuest(const FResponseReadScenario &InResponseData)
void HandleLuggageSelection(class APlayerState *Player, class Aluggage *luggage)
void BeginListenQuest(const FResponseListenScenario &InResponseData)
bool ValidateAnswer(class ALingoPlayerState *Player, class Aluggage *Luggage)
정답을 판정합니다
void StopMissionTimer()
미션 타이머를 중지합니다
void DecreaseMissionTimer(const float InValue)
FString SelectedWord2
선택한 색상 (문제2 답변)
FString SelectedWord1
선택한 심볼 (문제1 답변)
int32 AttemptCount
시도 횟수
bool bWrongWord1
심볼 오답 플래그
bool bWrongWord2
색상 오답 플래그
상호작용 가능한 수하물 액터
Definition luggage.h:15
FString Target2
캐리어의 색상 (문제2 정답)
Definition luggage.h:141
FString Target1
캐리어의 심볼 (문제1 정답)
Definition luggage.h:137
static TArray< class ALingoPlayerState * > GetLingoPlayerStateList(const UObject *WorldContextObject)