|
|
@ -6,6 +6,7 @@
|
|
|
|
#include "MyGameState.h"
|
|
|
|
#include "MyGameState.h"
|
|
|
|
#include "MyPlayerController.h"
|
|
|
|
#include "MyPlayerController.h"
|
|
|
|
#include "MyPlayerState.h"
|
|
|
|
#include "MyPlayerState.h"
|
|
|
|
|
|
|
|
#include "SinglePlayerGS.h"
|
|
|
|
#include "Trooper.h"
|
|
|
|
#include "Trooper.h"
|
|
|
|
|
|
|
|
|
|
|
|
AMyGameMode::AMyGameMode()
|
|
|
|
AMyGameMode::AMyGameMode()
|
|
|
@ -26,7 +27,7 @@ auto AMyGameMode::GetMyGameState() const {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void AMyGameMode::InitializeBattleField_Implementation() const {
|
|
|
|
void AMyGameMode::InitializeBattleField_Implementation() {
|
|
|
|
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);
|
|
|
@ -39,7 +40,7 @@ void AMyGameMode::InitializeBattleField_Implementation() const {
|
|
|
|
),
|
|
|
|
),
|
|
|
|
TEXT("Blueprint'/Game/Troopers/TrooperWizard.TrooperWizard_C'")
|
|
|
|
TEXT("Blueprint'/Game/Troopers/TrooperWizard.TrooperWizard_C'")
|
|
|
|
};
|
|
|
|
};
|
|
|
|
TArray<UClass *> LoadedBpAssets;
|
|
|
|
// TArray<UClass *> LoadedBpAssets;
|
|
|
|
for (int i = 0; i < bpPaths.Num(); ++i) {
|
|
|
|
for (int i = 0; i < bpPaths.Num(); ++i) {
|
|
|
|
TSoftClassPtr<ATrooper> ActorBpClass = TSoftClassPtr<ATrooper>(
|
|
|
|
TSoftClassPtr<ATrooper> ActorBpClass = TSoftClassPtr<ATrooper>(
|
|
|
|
FSoftObjectPath(bpPaths[i])
|
|
|
|
FSoftObjectPath(bpPaths[i])
|
|
|
@ -61,25 +62,31 @@ void AMyGameMode::InitializeBattleField_Implementation() const {
|
|
|
|
GetMyGameState()->AddTrooper(Cast<ATrooper>(Spawned));
|
|
|
|
GetMyGameState()->AddTrooper(Cast<ATrooper>(Spawned));
|
|
|
|
Location += {0.f, 500.f, 0.0f};
|
|
|
|
Location += {0.f, 500.f, 0.0f};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Location = {-2000.0f, -1000.0f, 0.0f};
|
|
|
|
if (bIsMultiplayer) {
|
|
|
|
Rotation = {0.0f, 0.0f, 0.0f};
|
|
|
|
Location = {-2000.0f, -1000.0f, 0.0f};
|
|
|
|
for (int i = 0; i < 5; ++i) {
|
|
|
|
Rotation = {0.0f, 0.0f, 0.0f};
|
|
|
|
FTransform SpawnLocationAndRotation(Rotation);
|
|
|
|
for (int i = 0; i < 5; ++i) {
|
|
|
|
SpawnLocationAndRotation.SetLocation(Location);
|
|
|
|
FTransform SpawnLocationAndRotation(Rotation);
|
|
|
|
AActor *Spawned = GetWorld()->SpawnActorDeferred<ATrooper>(
|
|
|
|
SpawnLocationAndRotation.SetLocation(Location);
|
|
|
|
LoadedBpAssets[i % 2], SpawnLocationAndRotation);
|
|
|
|
AActor *Spawned = GetWorld()->SpawnActorDeferred<ATrooper>(
|
|
|
|
// AActor *Spawned = GetWorld()->SpawnActorDeferred<ATrooper>(
|
|
|
|
LoadedBpAssets[i % 2], SpawnLocationAndRotation);
|
|
|
|
// ATrooper::StaticClass(), SpawnLocationAndRotation);
|
|
|
|
// AActor *Spawned = GetWorld()->SpawnActorDeferred<ATrooper>(
|
|
|
|
Cast<ATrooper>(Spawned)->Initialize(
|
|
|
|
// ATrooper::StaticClass(), SpawnLocationAndRotation);
|
|
|
|
1, Location, TrooperCount++);
|
|
|
|
Cast<ATrooper>(Spawned)->Initialize(
|
|
|
|
Spawned->FinishSpawning(SpawnLocationAndRotation);
|
|
|
|
1, Location, TrooperCount++);
|
|
|
|
Spawned->SetActorLocation(Location);
|
|
|
|
Spawned->FinishSpawning(SpawnLocationAndRotation);
|
|
|
|
GetMyGameState()->AddTrooper(Cast<ATrooper>(Spawned));
|
|
|
|
Spawned->SetActorLocation(Location);
|
|
|
|
Location += {0.f, 500.f, 0.0f};
|
|
|
|
GetMyGameState()->AddTrooper(Cast<ATrooper>(Spawned));
|
|
|
|
|
|
|
|
Location += {0.f, 500.f, 0.0f};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
// Cast<ASinglePlayerGS>(GetMyGameState())->GetEnemyAIController()->
|
|
|
|
|
|
|
|
// SetTrooperAssetsAndSpawn(
|
|
|
|
|
|
|
|
// LoadedBpAssets,
|
|
|
|
|
|
|
|
// TrooperCount);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
AActor *AMyGameMode::ChoosePlayerStart_Implementation(AController *Player) {
|
|
|
|
AActor *AMyGameMode::ChoosePlayerStart_Implementation(AController *Player) {
|
|
|
|
UE_LOG(LogTemp, Warning, TEXT("GameMode ChoosePlayerStart %d"),
|
|
|
|
UE_LOG(LogTemp, Warning, TEXT("GameMode ChoosePlayerStart %d"),
|
|
|
|
GetNumPlayers());
|
|
|
|
GetNumPlayers());
|
|
|
@ -206,4 +213,3 @@ void AMyGameMode::StartGame_Implementation() {
|
|
|
|
// return Cast<AMyPlayerController>(
|
|
|
|
// return Cast<AMyPlayerController>(
|
|
|
|
// UGameplayStatics::GetPlayerController(GetWorld(), PlayerIndex));
|
|
|
|
// UGameplayStatics::GetPlayerController(GetWorld(), PlayerIndex));
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|