|
|
|
// Fill out your copyright notice in the Description page of Project Settings.
|
|
|
|
|
|
|
|
#include "Kismet/GameplayStatics.h"
|
|
|
|
#include "MyGameMode.h"
|
|
|
|
#include "Trooper.h"
|
|
|
|
|
|
|
|
AMyGameMode::AMyGameMode() : Super() {
|
|
|
|
UE_LOG(LogTemp, Warning, TEXT("GameMode Constructor"));
|
|
|
|
PlayerControllerClass = AMyPlayerController::StaticClass();
|
|
|
|
}
|
|
|
|
|
|
|
|
void AMyGameMode::BeginPlay() {
|
|
|
|
Super::BeginPlay();
|
|
|
|
UE_LOG(LogTemp, Warning, TEXT("GameMode BeginPlay"));
|
|
|
|
if (GetWorld()->GetMapName().Contains("BattleFieldMap")) {
|
|
|
|
UE_LOG(LogTemp, Warning, TEXT("Player Logined"));
|
|
|
|
StartGame();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void AMyGameMode::StartGame() {
|
|
|
|
FVector Location(0.0f, 0.0f, 0.0f);
|
|
|
|
FRotator Rotation(0.0f, 0.0f, 0.0f);
|
|
|
|
FActorSpawnParameters SpawnInfo;
|
|
|
|
GetWorld()->SpawnActor<ATrooper>(Location, Rotation, SpawnInfo);
|
|
|
|
GetPlayerController()->StartTurn();
|
|
|
|
}
|
|
|
|
|
|
|
|
AMyPlayerController *AMyGameMode::GetPlayerController() {
|
|
|
|
return dynamic_cast<AMyPlayerController *>(
|
|
|
|
UGameplayStatics::GetPlayerController(GetWorld(), 0)
|
|
|
|
);
|
|
|
|
}
|