Game loop finished
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
Content/Blueprints/UI/BP_LevelCompleted.uasset
Normal file
BIN
Content/Blueprints/UI/BP_LevelCompleted.uasset
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
Content/UI/W_AfterMatch.uasset
Normal file
BIN
Content/UI/W_AfterMatch.uasset
Normal file
Binary file not shown.
Binary file not shown.
BIN
Content/UI/W_MainMenu_Bottom.uasset
Normal file
BIN
Content/UI/W_MainMenu_Bottom.uasset
Normal file
Binary file not shown.
@@ -52,3 +52,12 @@ TArray<ABuildingBlock*> ABuildingBlock::GetSameVariantNeighbours() {
|
|||||||
|
|
||||||
return Results;
|
return Results;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ABuildingBlock::DestroyBlock_Implementation() {
|
||||||
|
IsBeingDestroyed = true;
|
||||||
|
OnBlockDestroyed.ExecuteIfBound();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ABuildingBlock::DestroyWithDelay_Implementation() {
|
||||||
|
IsBeingDestroyed = true;
|
||||||
|
}
|
||||||
@@ -7,6 +7,8 @@
|
|||||||
#include "DrawDebugHelpers.h"
|
#include "DrawDebugHelpers.h"
|
||||||
#include "BuildingBlock.generated.h"
|
#include "BuildingBlock.generated.h"
|
||||||
|
|
||||||
|
DECLARE_DELEGATE(FBlockDestroyed);
|
||||||
|
|
||||||
UCLASS()
|
UCLASS()
|
||||||
class FIREWORKDUELS_API ABuildingBlock : public AActor
|
class FIREWORKDUELS_API ABuildingBlock : public AActor
|
||||||
{
|
{
|
||||||
@@ -35,16 +37,21 @@ public:
|
|||||||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
|
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
|
||||||
int32 Variant = 0;
|
int32 Variant = 0;
|
||||||
|
|
||||||
|
UPROPERTY(BlueprintReadOnly)
|
||||||
|
bool IsBeingDestroyed = false;
|
||||||
|
|
||||||
|
FBlockDestroyed OnBlockDestroyed;
|
||||||
|
|
||||||
UFUNCTION(BlueprintCallable)
|
UFUNCTION(BlueprintCallable)
|
||||||
void TakeHit();
|
void TakeHit();
|
||||||
|
|
||||||
UFUNCTION(BlueprintImplementableEvent, BlueprintCallable)
|
UFUNCTION(BlueprintNativeEvent, BlueprintCallable)
|
||||||
void DestroyBlock();
|
void DestroyBlock();
|
||||||
|
|
||||||
UFUNCTION(BlueprintImplementableEvent)
|
UFUNCTION(BlueprintImplementableEvent)
|
||||||
void FadeIn();
|
void FadeIn();
|
||||||
|
|
||||||
UFUNCTION(BlueprintImplementableEvent, BlueprintCallable)
|
UFUNCTION(BlueprintNativeEvent, BlueprintCallable)
|
||||||
void DestroyWithDelay();
|
void DestroyWithDelay();
|
||||||
|
|
||||||
// Get neighbouring Blocks with same color variant
|
// Get neighbouring Blocks with same color variant
|
||||||
|
|||||||
@@ -25,13 +25,10 @@ UENUM(BlueprintType)
|
|||||||
enum Firework
|
enum Firework
|
||||||
{
|
{
|
||||||
Impact UMETA(DisplayName = "Impact"),
|
Impact UMETA(DisplayName = "Impact"),
|
||||||
Timed UMETA(DisplayName = "Timed"),
|
|
||||||
Sticky UMETA(DisplayName = "Sticky"),
|
Sticky UMETA(DisplayName = "Sticky"),
|
||||||
Cluster UMETA(DisplayName = "Cluster"),
|
Cluster UMETA(DisplayName = "Cluster"),
|
||||||
ImpactRocket UMETA(DisplayName = "ImpactRocket"),
|
ImpactRocket UMETA(DisplayName = "ImpactRocket"),
|
||||||
TimedRocket UMETA(DisplayName = "TimedRocket"),
|
|
||||||
ClusterRocket UMETA(DisplayName = "ClusterRocket"),
|
ClusterRocket UMETA(DisplayName = "ClusterRocket"),
|
||||||
StickyRocket UMETA(DisplayName = "StickyRocket"),
|
|
||||||
GuidedRocket UMETA(DisplayName = "GuidedRocket"),
|
GuidedRocket UMETA(DisplayName = "GuidedRocket"),
|
||||||
|
|
||||||
Lighter UMETA(DisplayName = "Lighter"),
|
Lighter UMETA(DisplayName = "Lighter"),
|
||||||
|
|||||||
@@ -16,14 +16,15 @@ ALevelTemplate::ALevelTemplate()
|
|||||||
void ALevelTemplate::BeginPlay()
|
void ALevelTemplate::BeginPlay()
|
||||||
{
|
{
|
||||||
Super::BeginPlay();
|
Super::BeginPlay();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called every frame
|
// Called every frame
|
||||||
void ALevelTemplate::Tick(float DeltaTime)
|
void ALevelTemplate::Tick(float DeltaTime)
|
||||||
{
|
{
|
||||||
Super::Tick(DeltaTime);
|
Super::Tick(DeltaTime);
|
||||||
GameTime += DeltaTime;
|
if (CountTime) {
|
||||||
|
GameTime += DeltaTime;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ALevelTemplate::StartGame() {
|
void ALevelTemplate::StartGame() {
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ ASpawnManager::ASpawnManager()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ASpawnManager::GenerateBoard(const TSubclassOf<ALevelTemplate> Template) {
|
void ASpawnManager::GenerateBoard(const TSubclassOf<ALevelTemplate> Template) {
|
||||||
|
SpawnedBlocks = 0;
|
||||||
FVector ActorLocation = this->GetActorLocation();
|
FVector ActorLocation = this->GetActorLocation();
|
||||||
CurrentLevel = GetWorld()->SpawnActor<ALevelTemplate>(Template, this->GetActorTransform());
|
CurrentLevel = GetWorld()->SpawnActor<ALevelTemplate>(Template, this->GetActorTransform());
|
||||||
UPaperTileMapComponent* Tilemap = CurrentLevel->Template;
|
UPaperTileMapComponent* Tilemap = CurrentLevel->Template;
|
||||||
@@ -20,19 +21,40 @@ void ASpawnManager::GenerateBoard(const TSubclassOf<ALevelTemplate> Template) {
|
|||||||
|
|
||||||
for (int32 i = 0; i < BlocksY; i++) {
|
for (int32 i = 0; i < BlocksY; i++) {
|
||||||
for (int32 o = 0; o < BlocksX; o++) {
|
for (int32 o = 0; o < BlocksX; o++) {
|
||||||
// Make transform
|
|
||||||
FTransform SpawnTransform;
|
|
||||||
SpawnTransform.SetLocation(FVector((ActorLocation.X - (Distance * BlocksX / 2) + (o * Distance)), (ActorLocation.Y - (Distance * (BlocksY / 2)) + (i * Distance)), ActorLocation.Z));
|
|
||||||
|
|
||||||
// Spawn block
|
|
||||||
int32 TileId = Tilemap->GetTile(i, o, 0).GetTileIndex();
|
int32 TileId = Tilemap->GetTile(i, o, 0).GetTileIndex();
|
||||||
TSubclassOf<ABuildingBlock> TileClass = *BlockTemplates.Find(TileId);
|
|
||||||
ABuildingBlock* ThisBlock = GetWorld()->SpawnActor<ABuildingBlock>(TileClass, SpawnTransform);
|
// If TileId == 4 means, that there should be no tile at this location
|
||||||
ThisBlock->Index = (10 * i) + o;
|
if (TileId != 4) {
|
||||||
if (ThisBlock->HasVariants) {
|
// Make transform
|
||||||
ThisBlock->Variant = FMath::RandRange(1, MaxVariants);
|
FTransform SpawnTransform;
|
||||||
|
SpawnTransform.SetLocation(FVector((ActorLocation.X - (Distance * BlocksX / 2) + (o * Distance)), (ActorLocation.Y - (Distance * (BlocksY / 2)) + (i * Distance)), ActorLocation.Z));
|
||||||
|
|
||||||
|
// Spawn block
|
||||||
|
TSubclassOf<ABuildingBlock> TileClass = *BlockTemplates.Find(TileId);
|
||||||
|
ABuildingBlock* ThisBlock = GetWorld()->SpawnActor<ABuildingBlock>(TileClass, SpawnTransform);
|
||||||
|
ThisBlock->Index = (10 * i) + o;
|
||||||
|
if (ThisBlock->HasVariants) {
|
||||||
|
ThisBlock->Variant = FMath::RandRange(1, MaxVariants);
|
||||||
|
}
|
||||||
|
if (TileId != 5) {
|
||||||
|
SpawnedBlocks++;
|
||||||
|
ThisBlock->OnBlockDestroyed.BindUFunction(this, TEXT("RemoveBlock"));
|
||||||
|
}
|
||||||
|
ThisBlock->FadeIn();
|
||||||
}
|
}
|
||||||
ThisBlock->FadeIn();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ASpawnManager::RemoveBlock() {
|
||||||
|
SpawnedBlocks--;
|
||||||
|
UE_LOG(LogTemp, Warning, TEXT("Removed Block --- %i left"), SpawnedBlocks);
|
||||||
|
if (SpawnedBlocks <= 0)
|
||||||
|
{
|
||||||
|
UE_LOG(LogTemp, Warning, TEXT("All blocks destroyed, calling OnLevelCompleted"));
|
||||||
|
float Playtime = CurrentLevel->StopGame();
|
||||||
|
int32 AcquiredStars = CurrentLevel->GetAwardStars();
|
||||||
|
|
||||||
|
OnLevelCompleted(Playtime, AcquiredStars);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -38,9 +38,18 @@ protected:
|
|||||||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
|
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
|
||||||
TMap<int32, TSubclassOf<ABuildingBlock>> BlockTemplates;
|
TMap<int32, TSubclassOf<ABuildingBlock>> BlockTemplates;
|
||||||
|
|
||||||
|
UPROPERTY(BlueprintReadWrite)
|
||||||
|
int32 SpawnedBlocks = 0;
|
||||||
|
|
||||||
UFUNCTION(BlueprintCallable, CallInEditor)
|
UFUNCTION(BlueprintCallable, CallInEditor)
|
||||||
void GenerateBoard(const TSubclassOf<ALevelTemplate> Template);
|
void GenerateBoard(const TSubclassOf<ALevelTemplate> Template);
|
||||||
|
|
||||||
|
UFUNCTION()
|
||||||
|
void RemoveBlock();
|
||||||
|
|
||||||
|
UFUNCTION(BlueprintImplementableEvent)
|
||||||
|
void OnLevelCompleted(const float &Playtime,const int32 &AcquiredStars);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user