diff --git a/Content/Blueprints/BP_FireworkBase.uasset b/Content/Blueprints/BP_FireworkBase.uasset index 788eb6a..366b802 100644 Binary files a/Content/Blueprints/BP_FireworkBase.uasset and b/Content/Blueprints/BP_FireworkBase.uasset differ diff --git a/Content/Blueprints/BP_FireworksPawn.uasset b/Content/Blueprints/BP_FireworksPawn.uasset index a6d159a..452ee19 100644 Binary files a/Content/Blueprints/BP_FireworksPawn.uasset and b/Content/Blueprints/BP_FireworksPawn.uasset differ diff --git a/Content/Blueprints/BP_SpawnManager.uasset b/Content/Blueprints/BP_SpawnManager.uasset index 9606c86..de44640 100644 Binary files a/Content/Blueprints/BP_SpawnManager.uasset and b/Content/Blueprints/BP_SpawnManager.uasset differ diff --git a/Content/Blueprints/Blocks/BP_Block.uasset b/Content/Blueprints/Blocks/BP_Block.uasset index 245eb69..70a8249 100644 Binary files a/Content/Blueprints/Blocks/BP_Block.uasset and b/Content/Blueprints/Blocks/BP_Block.uasset differ diff --git a/Content/Blueprints/Blocks/BP_Block_Explosive.uasset b/Content/Blueprints/Blocks/BP_Block_Explosive.uasset index f9632c6..71c4a8e 100644 Binary files a/Content/Blueprints/Blocks/BP_Block_Explosive.uasset and b/Content/Blueprints/Blocks/BP_Block_Explosive.uasset differ diff --git a/Content/Blueprints/Fireworks/BP_Bouncing.uasset b/Content/Blueprints/Fireworks/BP_Bouncing.uasset deleted file mode 100644 index bfe8896..0000000 Binary files a/Content/Blueprints/Fireworks/BP_Bouncing.uasset and /dev/null differ diff --git a/Content/Blueprints/Fireworks/BP_Cluster.uasset b/Content/Blueprints/Fireworks/BP_Cluster.uasset index 3aa355e..9cff1af 100644 Binary files a/Content/Blueprints/Fireworks/BP_Cluster.uasset and b/Content/Blueprints/Fireworks/BP_Cluster.uasset differ diff --git a/Content/Blueprints/Fireworks/BP_Impact.uasset b/Content/Blueprints/Fireworks/BP_Impact.uasset index c5a0277..8003489 100644 Binary files a/Content/Blueprints/Fireworks/BP_Impact.uasset and b/Content/Blueprints/Fireworks/BP_Impact.uasset differ diff --git a/Content/Blueprints/Fireworks/BP_RocketTimed.uasset b/Content/Blueprints/Fireworks/BP_RocketTimed.uasset deleted file mode 100644 index 65ddb55..0000000 Binary files a/Content/Blueprints/Fireworks/BP_RocketTimed.uasset and /dev/null differ diff --git a/Content/Blueprints/UI/BP_LevelCompleted.uasset b/Content/Blueprints/UI/BP_LevelCompleted.uasset new file mode 100644 index 0000000..127c6d9 Binary files /dev/null and b/Content/Blueprints/UI/BP_LevelCompleted.uasset differ diff --git a/Content/Blueprints/UI/BP_Menu.uasset b/Content/Blueprints/UI/BP_Menu.uasset index b001d28..f9e46ce 100644 Binary files a/Content/Blueprints/UI/BP_Menu.uasset and b/Content/Blueprints/UI/BP_Menu.uasset differ diff --git a/Content/Levels/L_MainLevel.umap b/Content/Levels/L_MainLevel.umap index 20889d1..3aff6e4 100644 Binary files a/Content/Levels/L_MainLevel.umap and b/Content/Levels/L_MainLevel.umap differ diff --git a/Content/Levels/Tilemaps/TM_Level1.uasset b/Content/Levels/Tilemaps/TM_Level1.uasset index 7311baf..9b91b66 100644 Binary files a/Content/Levels/Tilemaps/TM_Level1.uasset and b/Content/Levels/Tilemaps/TM_Level1.uasset differ diff --git a/Content/M5VFXVOL2/Particles/Explosion/Fire_Exp_00.uasset b/Content/M5VFXVOL2/Particles/Explosion/Fire_Exp_00.uasset index ab4a771..94570c2 100644 Binary files a/Content/M5VFXVOL2/Particles/Explosion/Fire_Exp_00.uasset and b/Content/M5VFXVOL2/Particles/Explosion/Fire_Exp_00.uasset differ diff --git a/Content/M5VFXVOL2/Particles/Explosion/Fire_Exp_03.uasset b/Content/M5VFXVOL2/Particles/Explosion/Fire_Exp_03.uasset index 2820036..ba045e3 100644 Binary files a/Content/M5VFXVOL2/Particles/Explosion/Fire_Exp_03.uasset and b/Content/M5VFXVOL2/Particles/Explosion/Fire_Exp_03.uasset differ diff --git a/Content/Particles/P_Trail.uasset b/Content/Particles/P_Trail.uasset index 780762e..0d5f703 100644 Binary files a/Content/Particles/P_Trail.uasset and b/Content/Particles/P_Trail.uasset differ diff --git a/Content/UI/UI_ShopTile.uasset b/Content/UI/UI_ShopTile.uasset index 9f74cdd..a2c9e58 100644 Binary files a/Content/UI/UI_ShopTile.uasset and b/Content/UI/UI_ShopTile.uasset differ diff --git a/Content/UI/W_AfterMatch.uasset b/Content/UI/W_AfterMatch.uasset new file mode 100644 index 0000000..0b0af99 Binary files /dev/null and b/Content/UI/W_AfterMatch.uasset differ diff --git a/Content/UI/W_MainMenu.uasset b/Content/UI/W_MainMenu.uasset index 569cd98..d0cd42c 100644 Binary files a/Content/UI/W_MainMenu.uasset and b/Content/UI/W_MainMenu.uasset differ diff --git a/Content/UI/W_MainMenu_Bottom.uasset b/Content/UI/W_MainMenu_Bottom.uasset new file mode 100644 index 0000000..926cc54 Binary files /dev/null and b/Content/UI/W_MainMenu_Bottom.uasset differ diff --git a/Source/FireworkDuels/BuildingBlock.cpp b/Source/FireworkDuels/BuildingBlock.cpp index c2bcec3..036d578 100644 --- a/Source/FireworkDuels/BuildingBlock.cpp +++ b/Source/FireworkDuels/BuildingBlock.cpp @@ -51,4 +51,13 @@ TArray ABuildingBlock::GetSameVariantNeighbours() { } return Results; +} + +void ABuildingBlock::DestroyBlock_Implementation() { + IsBeingDestroyed = true; + OnBlockDestroyed.ExecuteIfBound(); +} + +void ABuildingBlock::DestroyWithDelay_Implementation() { + IsBeingDestroyed = true; } \ No newline at end of file diff --git a/Source/FireworkDuels/BuildingBlock.h b/Source/FireworkDuels/BuildingBlock.h index eaea857..cc1a02a 100644 --- a/Source/FireworkDuels/BuildingBlock.h +++ b/Source/FireworkDuels/BuildingBlock.h @@ -7,6 +7,8 @@ #include "DrawDebugHelpers.h" #include "BuildingBlock.generated.h" +DECLARE_DELEGATE(FBlockDestroyed); + UCLASS() class FIREWORKDUELS_API ABuildingBlock : public AActor { @@ -35,16 +37,21 @@ public: UPROPERTY(EditDefaultsOnly, BlueprintReadWrite) int32 Variant = 0; + UPROPERTY(BlueprintReadOnly) + bool IsBeingDestroyed = false; + + FBlockDestroyed OnBlockDestroyed; + UFUNCTION(BlueprintCallable) void TakeHit(); - UFUNCTION(BlueprintImplementableEvent, BlueprintCallable) + UFUNCTION(BlueprintNativeEvent, BlueprintCallable) void DestroyBlock(); UFUNCTION(BlueprintImplementableEvent) void FadeIn(); - UFUNCTION(BlueprintImplementableEvent, BlueprintCallable) + UFUNCTION(BlueprintNativeEvent, BlueprintCallable) void DestroyWithDelay(); // Get neighbouring Blocks with same color variant diff --git a/Source/FireworkDuels/CustomDataTypes.h b/Source/FireworkDuels/CustomDataTypes.h index 1b80575..9db7cf2 100644 --- a/Source/FireworkDuels/CustomDataTypes.h +++ b/Source/FireworkDuels/CustomDataTypes.h @@ -25,13 +25,10 @@ UENUM(BlueprintType) enum Firework { Impact UMETA(DisplayName = "Impact"), - Timed UMETA(DisplayName = "Timed"), Sticky UMETA(DisplayName = "Sticky"), Cluster UMETA(DisplayName = "Cluster"), ImpactRocket UMETA(DisplayName = "ImpactRocket"), - TimedRocket UMETA(DisplayName = "TimedRocket"), ClusterRocket UMETA(DisplayName = "ClusterRocket"), - StickyRocket UMETA(DisplayName = "StickyRocket"), GuidedRocket UMETA(DisplayName = "GuidedRocket"), Lighter UMETA(DisplayName = "Lighter"), diff --git a/Source/FireworkDuels/Private/LevelTemplate.cpp b/Source/FireworkDuels/Private/LevelTemplate.cpp index 81bae2c..03d4f50 100644 --- a/Source/FireworkDuels/Private/LevelTemplate.cpp +++ b/Source/FireworkDuels/Private/LevelTemplate.cpp @@ -16,14 +16,15 @@ ALevelTemplate::ALevelTemplate() void ALevelTemplate::BeginPlay() { Super::BeginPlay(); - } // Called every frame void ALevelTemplate::Tick(float DeltaTime) { Super::Tick(DeltaTime); - GameTime += DeltaTime; + if (CountTime) { + GameTime += DeltaTime; + } } void ALevelTemplate::StartGame() { diff --git a/Source/FireworkDuels/SpawnManager.cpp b/Source/FireworkDuels/SpawnManager.cpp index 3788fb2..1f2d615 100644 --- a/Source/FireworkDuels/SpawnManager.cpp +++ b/Source/FireworkDuels/SpawnManager.cpp @@ -12,6 +12,7 @@ ASpawnManager::ASpawnManager() } void ASpawnManager::GenerateBoard(const TSubclassOf Template) { + SpawnedBlocks = 0; FVector ActorLocation = this->GetActorLocation(); CurrentLevel = GetWorld()->SpawnActor(Template, this->GetActorTransform()); UPaperTileMapComponent* Tilemap = CurrentLevel->Template; @@ -20,19 +21,40 @@ void ASpawnManager::GenerateBoard(const TSubclassOf Template) { for (int32 i = 0; i < BlocksY; i++) { 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(); - TSubclassOf TileClass = *BlockTemplates.Find(TileId); - ABuildingBlock* ThisBlock = GetWorld()->SpawnActor(TileClass, SpawnTransform); - ThisBlock->Index = (10 * i) + o; - if (ThisBlock->HasVariants) { - ThisBlock->Variant = FMath::RandRange(1, MaxVariants); + + // If TileId == 4 means, that there should be no tile at this location + if (TileId != 4) { + // 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 + TSubclassOf TileClass = *BlockTemplates.Find(TileId); + ABuildingBlock* ThisBlock = GetWorld()->SpawnActor(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); + } } \ No newline at end of file diff --git a/Source/FireworkDuels/SpawnManager.h b/Source/FireworkDuels/SpawnManager.h index ad343f9..0b86126 100644 --- a/Source/FireworkDuels/SpawnManager.h +++ b/Source/FireworkDuels/SpawnManager.h @@ -38,9 +38,18 @@ protected: UPROPERTY(EditDefaultsOnly, BlueprintReadWrite) TMap> BlockTemplates; + UPROPERTY(BlueprintReadWrite) + int32 SpawnedBlocks = 0; + UFUNCTION(BlueprintCallable, CallInEditor) void GenerateBoard(const TSubclassOf Template); + UFUNCTION() + void RemoveBlock(); + + UFUNCTION(BlueprintImplementableEvent) + void OnLevelCompleted(const float &Playtime,const int32 &AcquiredStars); + public: };