diff --git a/Content/StarterContent/Architecture/Floor_400x400.uasset b/Content/StarterContent/Architecture/Floor_400x400.uasset index 7ec619f..a08b055 100644 Binary files a/Content/StarterContent/Architecture/Floor_400x400.uasset and b/Content/StarterContent/Architecture/Floor_400x400.uasset differ diff --git a/Content/StarterContent/Maps/Minimal_Default.umap b/Content/StarterContent/Maps/Minimal_Default.umap index 7b52307..e056d46 100644 Binary files a/Content/StarterContent/Maps/Minimal_Default.umap and b/Content/StarterContent/Maps/Minimal_Default.umap differ diff --git a/Content/StarterContent/Particles/Materials/M_Burst.uasset b/Content/StarterContent/Particles/Materials/M_Burst.uasset index 1bc05f7..95fa7fe 100644 Binary files a/Content/StarterContent/Particles/Materials/M_Burst.uasset and b/Content/StarterContent/Particles/Materials/M_Burst.uasset differ diff --git a/Content/StarterContent/Particles/Materials/M_Fire_SubUV.uasset b/Content/StarterContent/Particles/Materials/M_Fire_SubUV.uasset index d0f7225..4b2548d 100644 Binary files a/Content/StarterContent/Particles/Materials/M_Fire_SubUV.uasset and b/Content/StarterContent/Particles/Materials/M_Fire_SubUV.uasset differ diff --git a/Content/StarterContent/Particles/Materials/M_smoke_subUV.uasset b/Content/StarterContent/Particles/Materials/M_smoke_subUV.uasset index d96330b..8a89654 100644 Binary files a/Content/StarterContent/Particles/Materials/M_smoke_subUV.uasset and b/Content/StarterContent/Particles/Materials/M_smoke_subUV.uasset differ diff --git a/Content/StarterContent/Props/Materials/M_MaterialSphere.uasset b/Content/StarterContent/Props/Materials/M_MaterialSphere.uasset index 377dd95..f0101ee 100644 Binary files a/Content/StarterContent/Props/Materials/M_MaterialSphere.uasset and b/Content/StarterContent/Props/Materials/M_MaterialSphere.uasset differ diff --git a/Content/StarterContent/Props/Materials/M_MaterialSphere_Plain.uasset b/Content/StarterContent/Props/Materials/M_MaterialSphere_Plain.uasset index 5a88d52..7d6bfe5 100644 Binary files a/Content/StarterContent/Props/Materials/M_MaterialSphere_Plain.uasset and b/Content/StarterContent/Props/Materials/M_MaterialSphere_Plain.uasset differ diff --git a/Source/TurnBasedTutorial/MyGameMode.cpp b/Source/TurnBasedTutorial/MyGameMode.cpp index 44dd9cc..d354852 100644 --- a/Source/TurnBasedTutorial/MyGameMode.cpp +++ b/Source/TurnBasedTutorial/MyGameMode.cpp @@ -4,41 +4,38 @@ #include "Kismet/GameplayStatics.h" -AMyGameMode::AMyGameMode() : Super() { - UE_LOG(LogTemp, Warning, TEXT("GameMode Constructor")); - GameStateClass = AMyGameState::StaticClass(); - PlayerControllerClass = AMyPlayerController::StaticClass(); - DefaultPawnClass = AMyPawn::StaticClass(); +AMyGameMode::AMyGameMode() : Super() +{ + UE_LOG(LogTemp, Warning, TEXT("GameMode Constructor")); + GameStateClass = AMyGameState::StaticClass(); + PlayerControllerClass = AMyPlayerController::StaticClass(); + DefaultPawnClass = AMyPawn::StaticClass(); } -AActor *AMyGameMode::ChoosePlayerStart_Implementation(AController *Player) { - UE_LOG(LogTemp, Warning, TEXT("GameMode ChoosePlayerStart %d"), GetNumPlayers()); - InitializeSpawnPointsIfNeeded(); - auto ptr = *SpawnPoints.Find(GetNumPlayers()); - UE_LOG(LogTemp, Warning, TEXT("GameMode ChoosePlayerStart end %d"), ptr->GetPlayerIndex()); - return ptr; +AActor* AMyGameMode::ChoosePlayerStart_Implementation(AController* Player) +{ + UE_LOG(LogTemp, Warning, TEXT("GameMode ChoosePlayerStart %d"), GetNumPlayers()); + InitializeSpawnPointsIfNeeded(); + auto ptr = *SpawnPoints.Find(GetNumPlayers()); + UE_LOG(LogTemp, Warning, TEXT("GameMode ChoosePlayerStart end %d"), ptr->GetPlayerIndex()); + return ptr; } -void AMyGameMode::InitializeSpawnPointsIfNeeded() { - if (SpawnPoints.Num() != 0) { - return; - } - for (TActorIterator PlayerStartIterator(GetWorld()); PlayerStartIterator; ++PlayerStartIterator) { - UE_LOG(LogTemp, Warning, TEXT("PlayerStart iterator %d"), PlayerStartIterator->GetPlayerIndex()); - SpawnPoints.Add(PlayerStartIterator->GetPlayerIndex(), *PlayerStartIterator); - } -} - -void AMyGameMode::BeginPlay() { - Super::BeginPlay(); -} - -void AMyGameMode::StartGame() { - GetPlayerController()->StartTurn(); -} - -AMyPlayerController *AMyGameMode::GetPlayerController() { - return dynamic_cast( - UGameplayStatics::GetPlayerController(GetWorld(), 0) - ); +void AMyGameMode::InitializeSpawnPointsIfNeeded() +{ + if (SpawnPoints.Num() != 0) + { + return; + } + for (TActorIterator PlayerStartIterator(GetWorld()); PlayerStartIterator; ++PlayerStartIterator) { + UE_LOG(LogTemp, Warning, TEXT("PlayerStart iterator %d"), PlayerStartIterator->GetPlayerIndex()); + SpawnPoints.Add(PlayerStartIterator->GetPlayerIndex(), *PlayerStartIterator); + } + // TArray MyPlayerStartObjects; + // UGameplayStatics::GetAllActorsOfClass(GetWorld(), AMyPlayerStart::StaticClass(), MyPlayerStartObjects); + // for (const auto& PlayerStart : MyPlayerStartObjects) + // { + // SpawnPoints.Add(dynamic_cast(PlayerStart)->GetPlayerIndex(), + // dynamic_cast(PlayerStart)); + // } } diff --git a/Source/TurnBasedTutorial/MyGameMode.h b/Source/TurnBasedTutorial/MyGameMode.h index df523f1..9eafea1 100644 --- a/Source/TurnBasedTutorial/MyGameMode.h +++ b/Source/TurnBasedTutorial/MyGameMode.h @@ -12,7 +12,6 @@ #include "MyGameMode.generated.h" - UCLASS() class TURNBASEDTUTORIAL_API AMyGameMode : public AGameMode { @@ -21,15 +20,10 @@ class TURNBASEDTUTORIAL_API AMyGameMode : public AGameMode public: AMyGameMode(); - void BeginPlay() override; + AActor* ChoosePlayerStart_Implementation(AController* Player); - AActor *ChoosePlayerStart_Implementation(AController * Player); private: - void StartGame(); - - void InitializeSpawnPointsIfNeeded(); - - AMyPlayerController *GetPlayerController(); + void InitializeSpawnPointsIfNeeded(); - TMap SpawnPoints; + TMap SpawnPoints; }; diff --git a/Source/TurnBasedTutorial/MyPlayerController.cpp b/Source/TurnBasedTutorial/MyPlayerController.cpp index f069d84..6504d78 100644 --- a/Source/TurnBasedTutorial/MyPlayerController.cpp +++ b/Source/TurnBasedTutorial/MyPlayerController.cpp @@ -2,62 +2,62 @@ #include "MyPlayerController.h" -AMyPlayerController::AMyPlayerController() : Super(), IsMyTurn(false), SelectedTrooper(nullptr) { - UE_LOG(LogTemp, Warning, TEXT("Player controller created")); -} - -void AMyPlayerController::SetupInputComponent() { - Super::SetupInputComponent(); - InputComponent->BindAction("MyAction", IE_Pressed, this, - &AMyPlayerController::OnLeftMouseClick); -} - -void AMyPlayerController::StartTurn() { - IsMyTurn = true; - UE_LOG(LogTemp, Warning, TEXT("Your turn")); -} - -void AMyPlayerController::EndTurn() { - IsMyTurn = false; - UE_LOG(LogTemp, Warning, TEXT("Not your turn")); -} - -void AMyPlayerController::SetTrooperIsMoving(bool isMoving) { - IsThereTrooperMoving = isMoving; -} - -void AMyPlayerController::OnLeftMouseClick() { - if (IsThereTrooperMoving) { - return; - } - UE_LOG(LogTemp, Warning, TEXT("Mouse clicked")); - FHitResult HitResult; - bool IsHitResult = GetHitResultUnderCursorByChannel(TraceTypeQuery1, false, HitResult); - if (IsHitResult) { - AActor *actor = HitResult.Actor.Get(); - if (actor->ActorHasTag(FName("Trooper"))) { - ATrooper* trooper = dynamic_cast(actor); - if (trooper != nullptr && trooper != SelectedTrooper) { - if (trooper->IsOnPlayersSide()) { - UE_LOG(LogTemp, Warning, TEXT("Hitted trooper id: %d, on our side"), - trooper->GetId()); - SelectedTrooper = trooper; - } - else { - UE_LOG(LogTemp, Warning, TEXT("Hitted trooper id: %d, enemy"), - trooper->GetId()); - UE_LOG(LogTemp, Warning, TEXT("Trooper #%d hit enemy trooper #%d"), - SelectedTrooper->GetId(), trooper->GetId()); - } - } - } - else if (actor->ActorHasTag(FName("Floor"))) { - UE_LOG(LogTemp, Warning, TEXT("Hitted floor: %f, %f, %f"), HitResult.Location.X, - HitResult.Location.Y, HitResult.Location.Z); - if (SelectedTrooper != nullptr) { - SelectedTrooper->MoveTrooper(HitResult.Location); - IsThereTrooperMoving = true; - } - } - } -} +// AMyPlayerController::AMyPlayerController() : Super(), IsMyTurn(false), SelectedTrooper(nullptr) { +// UE_LOG(LogTemp, Warning, TEXT("Player controller created")); +// } +// +// void AMyPlayerController::SetupInputComponent() { +// Super::SetupInputComponent(); +// InputComponent->BindAction("MyAction", IE_Pressed, this, +// &AMyPlayerController::OnLeftMouseClick); +// } +// +// void AMyPlayerController::StartTurn() { +// IsMyTurn = true; +// UE_LOG(LogTemp, Warning, TEXT("Your turn")); +// } +// +// void AMyPlayerController::EndTurn() { +// IsMyTurn = false; +// UE_LOG(LogTemp, Warning, TEXT("Not your turn")); +// } +// +// void AMyPlayerController::SetTrooperIsMoving(bool isMoving) { +// IsThereTrooperMoving = isMoving; +// } +// +// void AMyPlayerController::OnLeftMouseClick() { +// if (IsThereTrooperMoving) { +// return; +// } +// UE_LOG(LogTemp, Warning, TEXT("Mouse clicked")); +// FHitResult HitResult; +// bool IsHitResult = GetHitResultUnderCursorByChannel(TraceTypeQuery1, false, HitResult); +// if (IsHitResult) { +// AActor *actor = HitResult.Actor.Get(); +// if (actor->ActorHasTag(FName("Trooper"))) { +// ATrooper* trooper = dynamic_cast(actor); +// if (trooper != nullptr && trooper != SelectedTrooper) { +// if (trooper->IsOnPlayersSide()) { +// UE_LOG(LogTemp, Warning, TEXT("Hitted trooper id: %d, on our side"), +// trooper->GetId()); +// SelectedTrooper = trooper; +// } +// else { +// UE_LOG(LogTemp, Warning, TEXT("Hitted trooper id: %d, enemy"), +// trooper->GetId()); +// UE_LOG(LogTemp, Warning, TEXT("Trooper #%d hit enemy trooper #%d"), +// SelectedTrooper->GetId(), trooper->GetId()); +// } +// } +// } +// else if (actor->ActorHasTag(FName("Floor"))) { +// UE_LOG(LogTemp, Warning, TEXT("Hitted floor: %f, %f, %f"), HitResult.Location.X, +// HitResult.Location.Y, HitResult.Location.Z); +// if (SelectedTrooper != nullptr) { +// SelectedTrooper->MoveTrooper(HitResult.Location); +// IsThereTrooperMoving = true; +// } +// } +// } +// } diff --git a/Source/TurnBasedTutorial/MyPlayerController.h b/Source/TurnBasedTutorial/MyPlayerController.h index 90fb98a..17b9cda 100644 --- a/Source/TurnBasedTutorial/MyPlayerController.h +++ b/Source/TurnBasedTutorial/MyPlayerController.h @@ -15,23 +15,23 @@ class TURNBASEDTUTORIAL_API AMyPlayerController : public APlayerController GENERATED_BODY() public: - AMyPlayerController(); - - void StartTurn(); - - void EndTurn(); - - virtual void SetupInputComponent() override; - - void SetTrooperIsMoving(bool isMoving); + // AMyPlayerController(); + // + // void StartTurn(); + // + // void EndTurn(); + // + // virtual void SetupInputComponent() override; + // + // void SetTrooperIsMoving(bool isMoving); private: - bool IsMyTurn; - - bool IsThereTrooperMoving = false; - - ATrooper* SelectedTrooper; - - void OnLeftMouseClick(); + // bool IsMyTurn; + // + // bool IsThereTrooperMoving = false; + // + // ATrooper* SelectedTrooper; + // + // void OnLeftMouseClick(); }; diff --git a/Source/TurnBasedTutorial/MyPlayerStart.cpp b/Source/TurnBasedTutorial/MyPlayerStart.cpp index 1d6c5c8..e963a5a 100644 --- a/Source/TurnBasedTutorial/MyPlayerStart.cpp +++ b/Source/TurnBasedTutorial/MyPlayerStart.cpp @@ -3,8 +3,7 @@ #include "MyPlayerStart.h" -uint8 AMyPlayerStart::GetPlayerIndex() const { - return PlayerIndex; +uint8 AMyPlayerStart::GetPlayerIndex() const +{ + return PlayerIndex; } - - diff --git a/Source/TurnBasedTutorial/Trooper.cpp b/Source/TurnBasedTutorial/Trooper.cpp index 2315b23..92ee67c 100644 --- a/Source/TurnBasedTutorial/Trooper.cpp +++ b/Source/TurnBasedTutorial/Trooper.cpp @@ -26,22 +26,22 @@ void ATrooper::BeginPlay() } void ATrooper::Tick(float deltaTime) { - if (IsMoving) { - FVector vector = (MoveToVector - Position); - vector.Normalize(); - vector *= (Speed * deltaTime); - if (vector.Size() >= (MoveToVector - Position).Size()) { - Position = MoveToVector; - IsMoving = false; - dynamic_cast( - UGameplayStatics::GetPlayerController(GetWorld(), 0) - )->SetTrooperIsMoving(false); - } - else { - Position += vector; - } - SetActorLocation(Position); - } + // if (IsMoving) { + // FVector vector = (MoveToVector - Position); + // vector.Normalize(); + // vector *= (Speed * deltaTime); + // if (vector.Size() >= (MoveToVector - Position).Size()) { + // Position = MoveToVector; + // IsMoving = false; + // dynamic_cast( + // UGameplayStatics::GetPlayerController(GetWorld(), 0) + // )->SetTrooperIsMoving(false); + // } + // else { + // Position += vector; + // } + // SetActorLocation(Position); + // } } void ATrooper::MoveTrooper(FVector newPos) { diff --git a/TurnBased.uproject b/TurnBased.uproject index 7454dbb..d0fc005 100644 --- a/TurnBased.uproject +++ b/TurnBased.uproject @@ -1,6 +1,6 @@ { "FileVersion": 3, - "EngineAssociation": "{B4FE6467-4579-3D84-B22A-558A3D607596}", + "EngineAssociation": "4.27", "Category": "", "Description": "", "Modules": [