parent
7816cf735f
commit
24279b7255
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.
@ -0,0 +1,22 @@
|
|||||||
|
// Fill out your copyright notice in the Description page of Project Settings.
|
||||||
|
|
||||||
|
#include "Ability.h"
|
||||||
|
|
||||||
|
// Sets default values for this component's properties
|
||||||
|
UAbility::UAbility() {
|
||||||
|
PrimaryComponentTick.bCanEverTick = false;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Called when the game starts
|
||||||
|
void UAbility::BeginPlay() {
|
||||||
|
Super::BeginPlay();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// void UAbility::TickComponent(float DeltaTime,
|
||||||
|
// ELevelTick TickType,
|
||||||
|
// FActorComponentTickFunction *ThisTickFunction) {
|
||||||
|
// Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
|
||||||
|
//
|
||||||
|
// }
|
@ -0,0 +1,18 @@
|
|||||||
|
// Fill out your copyright notice in the Description page of Project Settings.
|
||||||
|
|
||||||
|
|
||||||
|
#include "HealthBar.h"
|
||||||
|
|
||||||
|
#include "Components/ProgressBar.h"
|
||||||
|
|
||||||
|
void UHealthBar::SetOwnerTrooper(ATrooper *Trooper) {
|
||||||
|
OwnerTrooper = Trooper;
|
||||||
|
}
|
||||||
|
|
||||||
|
void UHealthBar::NativeTick(const FGeometry &MyGeometry, float InDeltaTime) {
|
||||||
|
Super::NativeTick(MyGeometry, InDeltaTime);
|
||||||
|
if (!OwnerTrooper.IsValid())
|
||||||
|
return;
|
||||||
|
|
||||||
|
HealthBar->SetPercent(OwnerTrooper->GetHitPoints() / OwnerTrooper->GetMaxHitPoints());
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
// Fill out your copyright notice in the Description page of Project Settings.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "CoreMinimal.h"
|
||||||
|
#include "Trooper.h"
|
||||||
|
#include "Blueprint/UserWidget.h"
|
||||||
|
#include "HealthBar.generated.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
UCLASS(Abstract)
|
||||||
|
class TURNBASEDTUTORIAL_API UHealthBar : public UUserWidget {
|
||||||
|
GENERATED_BODY()
|
||||||
|
public:
|
||||||
|
void SetOwnerTrooper(ATrooper *Trooper);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
TWeakObjectPtr<ATrooper> OwnerTrooper;
|
||||||
|
|
||||||
|
UPROPERTY(meta=(BindWidget))
|
||||||
|
class UProgressBar *HealthBar;
|
||||||
|
|
||||||
|
virtual void NativeTick(const FGeometry &MyGeometry, float InDeltaTime) override;
|
||||||
|
};
|
@ -1,8 +1,87 @@
|
|||||||
// Fill out your copyright notice in the Description page of Project Settings.
|
// Fill out your copyright notice in the Description page of Project Settings.
|
||||||
|
|
||||||
|
|
||||||
#include "MyGameState.h"
|
#include "MyGameState.h"
|
||||||
|
|
||||||
|
// #include "MyPlayerController.h"
|
||||||
|
// #include "Trooper.h"
|
||||||
|
// #include "Kismet/GameplayStatics.h"
|
||||||
|
|
||||||
|
// void AMyGameState::InitializeBattleField() const {
|
||||||
|
// UE_LOG(LogTemp, Warning, TEXT("InitializeBattleField"));
|
||||||
|
// FVector Location(2000.0f, -1000.0f, 0.0f);
|
||||||
|
// FRotator Rotation(0.0f, 180.0f, 0.0f);
|
||||||
|
//
|
||||||
|
// uint8 TrooperCount = 0;
|
||||||
|
//
|
||||||
|
// TArray<const TCHAR *> bpPaths{
|
||||||
|
// TEXT(
|
||||||
|
// "Blueprint'/Game/Troopers/TrooperSkeletonMelee.TrooperSkeletonMelee_C'"
|
||||||
|
// ),
|
||||||
|
// TEXT("Blueprint'/Game/Troopers/TrooperWizard.TrooperWizard_C'")
|
||||||
|
// };
|
||||||
|
// TArray<UClass *> LoadedBpAssets;
|
||||||
|
// for (int i = 0; i < bpPaths.Num(); ++i) {
|
||||||
|
// TSoftClassPtr<ATrooper> ActorBpClass = TSoftClassPtr<ATrooper>(
|
||||||
|
// FSoftObjectPath(bpPaths[i])
|
||||||
|
// );
|
||||||
|
// LoadedBpAssets.Push(ActorBpClass.LoadSynchronous());
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// for (int i = 0; i < 5; ++i) {
|
||||||
|
// FTransform SpawnLocationAndRotation(Rotation);
|
||||||
|
// SpawnLocationAndRotation.SetLocation(Location);
|
||||||
|
// AActor *Spawned = GetWorld()->SpawnActorDeferred<ATrooper>(
|
||||||
|
// LoadedBpAssets[i % 2], SpawnLocationAndRotation);
|
||||||
|
// // AActor *Spawned = GetWorld()->SpawnActorDeferred<ATrooper>(
|
||||||
|
// // ATrooper::StaticClass(), SpawnLocationAndRotation);
|
||||||
|
// dynamic_cast<ATrooper *>(Spawned)->Initialize(
|
||||||
|
// 0, Location, TrooperCount++);
|
||||||
|
// Spawned->FinishSpawning(SpawnLocationAndRotation);
|
||||||
|
// Spawned->SetActorLocation(Location);
|
||||||
|
// Location += {0.f, 500.f, 0.0f};
|
||||||
|
// }
|
||||||
|
// Location = {-2000.0f, -1000.0f, 0.0f};
|
||||||
|
// Rotation = {0.0f, 0.0f, 0.0f};
|
||||||
|
// for (int i = 0; i < 5; ++i) {
|
||||||
|
// FTransform SpawnLocationAndRotation(Rotation);
|
||||||
|
// SpawnLocationAndRotation.SetLocation(Location);
|
||||||
|
// AActor *Spawned = GetWorld()->SpawnActorDeferred<ATrooper>(
|
||||||
|
// LoadedBpAssets[i % 2], SpawnLocationAndRotation);
|
||||||
|
// // AActor *Spawned = GetWorld()->SpawnActorDeferred<ATrooper>(
|
||||||
|
// // ATrooper::StaticClass(), SpawnLocationAndRotation);
|
||||||
|
// dynamic_cast<ATrooper *>(Spawned)->Initialize(
|
||||||
|
// 1, Location, TrooperCount++);
|
||||||
|
// Spawned->FinishSpawning(SpawnLocationAndRotation);
|
||||||
|
// Spawned->SetActorLocation(Location);
|
||||||
|
// Location += {0.f, 500.f, 0.0f};
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// AMyPlayerController *AMyGameState::GetMyPlayerController(
|
||||||
|
// uint8 const PlayerIndex) const {
|
||||||
|
// return dynamic_cast<AMyPlayerController *>(
|
||||||
|
// UGameplayStatics::GetPlayerController(GetWorld(), PlayerIndex));
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// void AMyGameState::StartGame() {
|
||||||
|
// // InitializeBattleField();
|
||||||
|
// PlayerInTurn()->StartTurn();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// void AMyGameState::CycleTurns() {
|
||||||
|
// PlayerInTurn()->EndTurn();
|
||||||
|
// if (CurrentPlayerTurn == 0) {
|
||||||
|
// CurrentPlayerTurn = 1;
|
||||||
|
// } else {
|
||||||
|
// CurrentPlayerTurn = 0;
|
||||||
|
// }
|
||||||
|
// PlayerInTurn()->StartTurn();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// AMyPlayerController *AMyGameState::PlayerInTurn() const {
|
||||||
|
// return GetMyPlayerController(CurrentPlayerTurn);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// AMyPlayerController *AMyGameState::PlayerNotInTurn() const {
|
||||||
|
// return GetMyPlayerController(CurrentPlayerTurn == 0 ? 1 : 0);
|
||||||
|
// }
|
||||||
|
Loading…
Reference in new issue