This commit is contained in:
2023-07-21 08:58:28 +02:00
parent 8906b1a492
commit 77bb47aeb9
77 changed files with 162 additions and 162 deletions

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.

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.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -21,6 +21,9 @@ public:
UPROPERTY(BlueprintReadWrite, EditAnywhere)
float Health = 100.0f;
UPROPERTY(BlueprintReadOnly)
int32 Index = 0;
UPROPERTY(BlueprintReadOnly)
float InitialHealth;

View File

@@ -14,35 +14,24 @@ UENUM(BlueprintType)
enum FireworksCategory
{
Firecracker UMETA(DisplayName="Firecracker"),
Volcano UMETA(DisplayName = "Volcano"),
RomanFire UMETA(DisplayName = "RomanFire"),
Rocket UMETA(DisplayName = "Rocket"),
Battery UMETA(DisplayName = "Battery"),
None UMETA(DisplayName="None")
};
UENUM(BlueprintType)
enum Firework
{
RedDragon UMETA(DisplayName = "RedDragon"),
Pirate UMETA(DisplayName = "Pirate"),
DoubleTrouble UMETA(DisplayName = "DoubleTrouble"),
InstantDeath UMETA(DisplayName = "InstantDeath"),
LongFuse UMETA(DisplayName = "LongFuse"),
WhiteWidow UMETA(DisplayName = "WhiteWidow"),
GreenGoblin UMETA(DisplayName = "GreenGoblin"),
TwelveGauge UMETA(DisplayName = "TwelveGauge"),
Comet5000 UMETA(DisplayName = "Comet5000"),
TwentyMegaton UMETA(DisplayName = "TwentyMegaton"),
Whistle UMETA(DisplayName = "Whistle"),
RedHornet UMETA(DisplayName = "RedHornet"),
BigDaddy UMETA(DisplayName = "BigDaddy"),
Kamikaze UMETA(DisplayName = "Kamikaze"),
Commando3000 UMETA(DisplayName = "Commando3000"),
AtomBomb UMETA(DisplayName = "AtomBomb"),
QuadrupleBazooka UMETA(DisplayName = "QuadrupleBazooka"),
RocketLauncher UMETA(DisplayName = "RocketLauncher"),
Panzerfaust UMETA(DisplayName = "Panzerfaust"),
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"),
};
@@ -71,26 +60,6 @@ struct FIREWORKDUELS_API FFireworkData : public FTableRowBase
UTexture2D* Icon = nullptr;
};
// Inventory Firework Entry
USTRUCT(BlueprintType)
struct FIREWORKDUELS_API FFireworkEntry
{
GENERATED_BODY()
FFireworkEntry(){}
FFireworkEntry(FFireworkData Data, int32 ThisQuantity)
{
FireworkData = Data;
Quantity = ThisQuantity;
}
UPROPERTY(EditAnywhere, BlueprintReadWrite)
FFireworkData FireworkData;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
int32 Quantity;
};
// Inventory
USTRUCT(BlueprintType)
@@ -99,7 +68,7 @@ struct FIREWORKDUELS_API FInventory
GENERATED_BODY()
UPROPERTY(EditAnywhere, BlueprintReadWrite)
TArray<FFireworkEntry> Items;
TArray<FFireworkData> Items;
};

View File

@@ -8,6 +8,7 @@
#include "Components/CapsuleComponent.h"
#include "WickComponent.h"
#include "NiagaraComponent.h"
#include "Kismet/KismetSystemLibrary.h"
#include "FireworkBase.generated.h"
UCLASS()
@@ -37,6 +38,9 @@ public:
UPROPERTY(EditAnywhere, BlueprintReadWrite)
bool IsBurning;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
float DamageRadius = 25.f;
UPROPERTY(EditDefaultsOnly)
bool IsDummyObject;
@@ -60,5 +64,4 @@ public:
UFUNCTION(BlueprintImplementableEvent, BlueprintCallable)
void ExplodeEffects();
};

View File

@@ -8,7 +8,7 @@ public class FireworkDuels : ModuleRules
{
PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "HeadMountedDisplay", "Niagara", "UMG" });
PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "HeadMountedDisplay", "Niagara", "UMG", "Paper2D" });
PrivateDependencyModuleNames.AddRange(new string[] { });

View File

@@ -238,18 +238,6 @@ bool AFireworksPawn::Drop(EControllerHand Hand)
return true;
}
// Add firecracker to inventory
void AFireworksPawn::AddToInventory(const FFireworkEntry& Entry)
{
}
// Remove firecracker from inventory
void AFireworksPawn::RemoveFromInventory(const FFireworkData& Item)
{
}
// Enable laser on specific hand
void AFireworksPawn::EnableLaserOnHand(EControllerHand Hand)
{

View File

@@ -81,8 +81,8 @@ public:
// Variables
UPROPERTY(BlueprintReadWrite)
FInventory Inventory;
UPROPERTY(BlueprintReadWrite, EditAnywhere)
TArray<FFireworkData> Inventory;
UPROPERTY(BlueprintReadWrite)
APickableObject* HeldObject_R;
@@ -123,9 +123,6 @@ public:
UPROPERTY(VisibleAnywhere, BlueprintReadOnly)
FHitResult CurrentLaserHitR;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
AActor* TeleportVisual;
// How much velocity samples should be recorded for throwing direction approximation
UPROPERTY(EditDefaultsOnly, Category = "Throwing")
int32 VelocitySamples = 5;
@@ -159,14 +156,6 @@ public:
// Approximate throw velocity
FVector ApproximateThrowVelocity(EControllerHand Hand);
// Add firecracker to inventory
UFUNCTION(BlueprintCallable)
void AddToInventory(const FFireworkEntry& Entry);
// Remove firecracker from inventory
UFUNCTION(BlueprintCallable)
void RemoveFromInventory(const FFireworkData& Item);
// ABA ABA
UFUNCTION(BlueprintCallable)
void EnableLaserOnHand(EControllerHand Hand);

View File

@@ -36,7 +36,7 @@ public:
UStaticMesh* StaticMesh;
UPROPERTY(BlueprintReadOnly)
FFireworkEntry FireworkEntryData;
FFireworkData FireworkData;
UPROPERTY(BlueprintReadOnly, VisibleAnywhere)
float TargetDistanceAlongSpline;

View File

@@ -1,71 +1 @@
#include "InventoryManager.h"
// Add item to inventory
void AInventoryManager::AddToInventory(const FFireworkData& Item, const int32& Quantity, const APawn* Pawn)
{
FInventory* InventoryToUpdate = Inventory.Find(Pawn);
// If there's no inventory associated with supplied pawn, create one
if (!InventoryToUpdate)
{
InventoryToUpdate = new FInventory();
}
FFireworkEntry* ItemToUpdate = InventoryToUpdate->Items.FindByPredicate([&](const FFireworkEntry& ThisItem)
{
return ThisItem.FireworkData.Firework == Item.Firework;
});
if (ItemToUpdate == nullptr) {
UE_LOG(LogTemp, Warning, TEXT("ItemToUpdate not found - creating one"));
ItemToUpdate = new FFireworkEntry(Item, Quantity);
InventoryToUpdate->Items.Add(*ItemToUpdate);
}
else {
UE_LOG(LogTemp, Warning, TEXT("ItemToUpdate was found, updating..."));
ItemToUpdate->Quantity += 1;
}
}
// Remove item from inventory
void AInventoryManager::RemoveFromInventory(const FFireworkData& Item, const APawn* Pawn)
{
// code
}
// Remove all items of a specified player from inventory (for example if he quits match mid game)
void AInventoryManager::RemovePlayerItems(const APawn* Pawn)
{
// code
}
// Get joint inventory of all players
FInventory AInventoryManager::GetInventory()
{
FInventory Joint;
TArray<APawn*> Pawns;
Inventory.GetKeys(Pawns);
for (int32 i = 0; i < Pawns.Num(); i++)
{
FInventory* ThisInventory = Inventory.Find(Pawns[i]);
for (int32 f = 0; f < ThisInventory->Items.Num(); f++)
{
// Check if items of this category already exist in joint inventory
FFireworkEntry* ItemToUpdate = Joint.Items.FindByPredicate([&](const FFireworkEntry& ThisItem) {
return ThisItem.FireworkData.Firework == ThisInventory->Items[i].FireworkData.Firework;
});
if (ItemToUpdate == nullptr) {
ItemToUpdate = &ThisInventory->Items[i];
}
else {
ItemToUpdate->Quantity += ThisInventory->Items[i].Quantity;
}
Joint.Items.Add(*ItemToUpdate);
}
}
return Joint;
}

View File

@@ -16,17 +16,4 @@ class FIREWORKDUELS_API AInventoryManager : public AActor
public:
UPROPERTY(BlueprintReadOnly)
TMap<APawn*, FInventory> Inventory;
UFUNCTION(BlueprintCallable)
void AddToInventory(const FFireworkData& Item, const int32& Quantity, const APawn* Pawn);
UFUNCTION(BlueprintCallable)
void RemoveFromInventory(const FFireworkData& Item, const APawn* Pawn);
UFUNCTION(BlueprintCallable)
void RemovePlayerItems(const APawn* Pawn);
UFUNCTION(BlueprintCallable)
FInventory GetInventory();
};

View File

@@ -0,0 +1,27 @@
// All rights reserved.
#include "LevelTemplate.h"
// Sets default values
ALevelTemplate::ALevelTemplate()
{
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
}
// Called when the game starts or when spawned
void ALevelTemplate::BeginPlay()
{
Super::BeginPlay();
}
// Called every frame
void ALevelTemplate::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
}

View File

@@ -0,0 +1,27 @@
// All rights reserved.
#include "Powerup.h"
// Sets default values
APowerup::APowerup()
{
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
}
// Called when the game starts or when spawned
void APowerup::BeginPlay()
{
Super::BeginPlay();
}
// Called every frame
void APowerup::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
}

View File

@@ -0,0 +1,39 @@
// All rights reserved.
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "PaperTileMapComponent.h"
#include "LevelTemplate.generated.h"
UCLASS()
class FIREWORKDUELS_API ALevelTemplate : public AActor
{
GENERATED_BODY()
public:
// Sets default values for this actor's properties
ALevelTemplate();
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
UPaperTileMapComponent* Template;
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
int32 OneStarTarget = 180;
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
int32 TwoStarTarget = 120;
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
int32 ThreeStarTarget = 60;
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
public:
// Called every frame
virtual void Tick(float DeltaTime) override;
};

View File

@@ -0,0 +1,26 @@
// All rights reserved.
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "Powerup.generated.h"
UCLASS()
class FIREWORKDUELS_API APowerup : public AActor
{
GENERATED_BODY()
public:
// Sets default values for this actor's properties
APowerup();
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
public:
// Called every frame
virtual void Tick(float DeltaTime) override;
};

View File

@@ -11,16 +11,24 @@ ASpawnManager::ASpawnManager()
}
void ASpawnManager::GenerateBoard() {
int32 ClassesCount = SpawnableClasses.Num();
void ASpawnManager::GenerateBoard(TSubclassOf<ALevelTemplate> &Template) {
FVector ActorLocation = this->GetActorLocation();
CurrentLevel = GetWorld()->SpawnActor<ALevelTemplate>(Template, this->GetActorTransform());
UPaperTileMapComponent* Tilemap = CurrentLevel->Template;
TArray<TSubclassOf<ABuildingBlock>> Classes;
for (int32 i = 0; i < BlocksY; i++) {
for (int32 o = 0; o < BlocksX; o++) {
int32 RandomIndex = FMath::RandRange(0, ClassesCount - 1);
// Make transform
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);
// Spawn block
int32 TileId = Tilemap->GetTile(i, o, 0).GetTileIndex();
TSubclassOf<ABuildingBlock> TileClass = *BlockTemplates.Find(TileId);
ABuildingBlock* ThisBlock = GetWorld()->SpawnActor<ABuildingBlock>(TileClass, SpawnTransform);
ThisBlock->Index = (10 * i) + o;
}
}
}

View File

@@ -6,6 +6,7 @@
#include "GameFramework/Actor.h"
#include "BuildingBlock.h"
#include "Math/UnrealMathUtility.h"
#include "LevelTemplate.h"
#include "SpawnManager.generated.h"
UCLASS()
@@ -19,20 +20,23 @@ public:
protected:
UPROPERTY(EditDefaultsOnly)
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
float Distance = 45.0f;
UPROPERTY(BlueprintReadWrite, EditAnywhere)
int32 BlocksX = 5;
int32 BlocksX = 10;
UPROPERTY(BlueprintReadWrite, EditAnywhere)
int32 BlocksY = 5;
int32 BlocksY = 10;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
TArray<TSubclassOf<ABuildingBlock>> SpawnableClasses;
ALevelTemplate* CurrentLevel;
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
TMap<int32, TSubclassOf<ABuildingBlock>> BlockTemplates;
UFUNCTION(BlueprintCallable, CallInEditor)
void GenerateBoard();
void GenerateBoard(TSubclassOf<ALevelTemplate> &Template);
public: