Slight refactoring and more logging

pull/5/head
eyakm1 2 years ago
parent cdd8c11f8b
commit 985612b4de

@ -23,7 +23,6 @@ void AMyGameMode::InitializeBattleField() const
UE_LOG(LogTemp, Warning, TEXT("InitializeBattleField")); UE_LOG(LogTemp, Warning, TEXT("InitializeBattleField"));
FVector Location(2000.0f, -1000.0f, 0.0f); FVector Location(2000.0f, -1000.0f, 0.0f);
FRotator Rotation(0.0f, 180.0f, 0.0f); FRotator Rotation(0.0f, 180.0f, 0.0f);
FActorSpawnParameters const SpawnInfo;
uint8 TrooperCount = 0; uint8 TrooperCount = 0;

@ -3,7 +3,6 @@
#include "MyPlayerController.h" #include "MyPlayerController.h"
#include "Kismet/GameplayStatics.h" #include "Kismet/GameplayStatics.h"
#include "MyGameMode.h" #include "MyGameMode.h"
#include "AIController.h"
#include "Net/UnrealNetwork.h" #include "Net/UnrealNetwork.h"
AMyPlayerController::AMyPlayerController() : Super(), bIsMyTurn(false), SelectedTrooper(nullptr) AMyPlayerController::AMyPlayerController() : Super(), bIsMyTurn(false), SelectedTrooper(nullptr)
@ -24,8 +23,8 @@ void AMyPlayerController::SetMyTurn(bool bMyTurn)
if (bIsMyTurn) if (bIsMyTurn)
{ {
GEngine->AddOnScreenDebugMessage(-1, 3.0f, FColor::Green, GEngine->AddOnScreenDebugMessage(-1, 3.0f, FColor::Green,
FString::Printf( FString::Printf(
TEXT("YOUR TURN!"))); TEXT("CURRENT TURN: %d"), PlayerIndex));
} }
// OnMyTurnChanged.ExecuteIfBound(bIsMyTurn); // OnMyTurnChanged.ExecuteIfBound(bIsMyTurn);
} }
@ -33,13 +32,13 @@ void AMyPlayerController::SetMyTurn(bool bMyTurn)
void AMyPlayerController::StartTurn_Implementation() void AMyPlayerController::StartTurn_Implementation()
{ {
SetMyTurn(true); SetMyTurn(true);
UE_LOG(LogTemp, Warning, TEXT("Your turn")); UE_LOG(LogTemp, Warning, TEXT("Your turn, %d"), PlayerIndex);
} }
void AMyPlayerController::EndTurn_Implementation() void AMyPlayerController::EndTurn_Implementation()
{ {
SetMyTurn(false); SetMyTurn(false);
UE_LOG(LogTemp, Warning, TEXT("Not your turn")); UE_LOG(LogTemp, Warning, TEXT("Not your turn, %d"), PlayerIndex);
} }
auto AMyPlayerController::GetMyGameMode() const auto AMyPlayerController::GetMyGameMode() const

@ -20,6 +20,8 @@ class TURNBASEDTUTORIAL_API AMyPlayerController : public APlayerController
public: public:
// FOnMyTurnChangedDelegate OnMyTurnChanged; // FOnMyTurnChangedDelegate OnMyTurnChanged;
virtual void SetupInputComponent() override;
AMyPlayerController(); AMyPlayerController();
UFUNCTION(Client, Reliable) UFUNCTION(Client, Reliable)
@ -29,12 +31,10 @@ public:
void EndTurn(); void EndTurn();
UFUNCTION(Server, Reliable) UFUNCTION(Server, Reliable)
void MoveTrooper(ATrooper *Trooper, FVector Location); void MoveTrooper(ATrooper* Trooper, FVector Location);
UFUNCTION(Server, Reliable) UFUNCTION(Server, Reliable)
void AttackTrooper(ATrooper *Attacker, ATrooper *Victim); void AttackTrooper(ATrooper* Attacker, ATrooper* Victim);
virtual void SetupInputComponent() override;
UFUNCTION() UFUNCTION()
void SetPlayerIndex(uint8 NewPlayerIndex); void SetPlayerIndex(uint8 NewPlayerIndex);

Loading…
Cancel
Save