26 lines
859 B
C++
26 lines
859 B
C++
// All rights reserved.
|
|
|
|
|
|
#include "SpawnManager.h"
|
|
|
|
// Sets default values
|
|
ASpawnManager::ASpawnManager()
|
|
{
|
|
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
|
|
PrimaryActorTick.bCanEverTick = false;
|
|
|
|
}
|
|
|
|
void ASpawnManager::GenerateBoard() {
|
|
int32 ClassesCount = SpawnableClasses.Num();
|
|
FVector ActorLocation = this->GetActorLocation();
|
|
|
|
for (int32 i = 0; i < BlocksY; i++) {
|
|
for (int32 o = 0; o < BlocksX; o++) {
|
|
int32 RandomIndex = FMath::RandRange(0, ClassesCount - 1);
|
|
FTransform SpawnTransform;
|
|
SpawnTransform.SetLocation(FVector((ActorLocation.X - (Distance * BlocksX / 2) + (o * Distance)), (ActorLocation.Y - (Distance * (BlocksY / 2)) + (i * Distance)), ActorLocation.Z));
|
|
GetWorld()->SpawnActor<ABuildingBlock>(SpawnableClasses[RandomIndex], SpawnTransform);
|
|
}
|
|
}
|
|
} |