Compare commits

..

No commits in common. "bf043b91fd8155400815ad03421d60f4967fd3f8" and "4e5daf9a54cb802b15c769bec9cdbd8ed12f96f1" have entirely different histories.

17 changed files with 16 additions and 173 deletions

View File

@ -7,7 +7,6 @@ r.DefaultFeature.AutoExposure=False
[/Script/EngineSettings.GameMapsSettings]
EditorStartupMap=/Game/Maps/Main.Main
GameDefaultMap=/Game/Maps/Main.Main
GlobalDefaultGameMode=/Game/Blueprints/GameMode/BP_ToonTanksGameMode.BP_ToonTanksGameMode_C
[/Script/HardwareTargeting.HardwareTargetingSettings]
TargetedHardwareClass=Desktop
@ -72,6 +71,3 @@ ConnectionType=USBOnly
bUseManualIPAddress=False
ManualIPAddress=
[CoreRedirects]
+PropertyRedirects=(OldName="/Script/ToonTanks.Tank.PlayerControllerRef",NewName="/Script/ToonTanks.Tank.PlayerController")

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
Content/Maps/Main.umap (Stored with Git LFS)

Binary file not shown.

View File

@ -26,12 +26,6 @@ ABasePawn::ABasePawn()
ProjectileSpawnPoint->SetupAttachment(TurretMesh);
}
void ABasePawn::HandleDestruction()
{
// TODO: Visual & Sound Effect Implementation
}
void ABasePawn::RotateTurret(FVector LookAtTarget)
{
FVector ToTarget = LookAtTarget - TurretMesh->GetComponentLocation();

View File

@ -15,9 +15,6 @@ public:
// Sets default values for this pawn's properties
ABasePawn();
// Handles Base Pawn destruction by Damage
virtual void HandleDestruction();
protected:
// Rotate Turret to Target Location
void RotateTurret(FVector LookAtTarget);

View File

@ -3,9 +3,6 @@
#include "HealthComponent.h"
#include "ToonTanksGameMode.h"
#include "Kismet/GameplayStatics.h"
// Sets default values for this component's properties
UHealthComponent::UHealthComponent()
{
@ -23,7 +20,6 @@ void UHealthComponent::BeginPlay()
Super::BeginPlay();
Health = MaxHealth;
GetOwner()->OnTakeAnyDamage.AddDynamic(this, &UHealthComponent::DamageTaken);
GameMode = Cast<AToonTanksGameMode>(UGameplayStatics::GetGameMode(this));
}
@ -37,14 +33,8 @@ void UHealthComponent::TickComponent(float DeltaTime, ELevelTick TickType, FActo
void UHealthComponent::DamageTaken(AActor* DamagedActor, float Damage, const UDamageType* DamageType, AController* Instigator, AActor* DamageCauser)
{
if (Health <= 0.0f)
{
if (Damage <= 0.0f)
return;
}
Health -= Damage;
if (Health <= 0.0f && GameMode)
{
GameMode->ActorDied(DamagedActor);
}
UE_LOG(LogTemp, Warning, TEXT("Health: %f"), Health);
}

View File

@ -32,10 +32,6 @@ private:
UFUNCTION()
void DamageTaken(AActor* DamagedActor, float Damage, const UDamageType* DamageType, AController* Instigator, AActor* DamageCauser);
// AToonTanksGameMode Pointer for Handling Dead Actor
UPROPERTY()
class AToonTanksGameMode* GameMode;
public:
// Called every frame
virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;

View File

@ -3,7 +3,6 @@
#include "Tank.h"
#include "ToonTanksPlayerController.h"
#include "Camera/CameraComponent.h"
#include "GameFramework/SpringArmComponent.h"
#include "Kismet/GameplayStatics.h"
@ -30,35 +29,30 @@ void ATank::Tick(float DeltaTime)
Super::Tick(DeltaTime);
// Rotate Tank to Mouse Pointer Location
if (PlayerController)
if (PlayerControllerRef)
{
FHitResult HitResult;
PlayerController->GetHitResultUnderCursor(
PlayerControllerRef->GetHitResultUnderCursor(
ECollisionChannel::ECC_Visibility,
false,
HitResult
);
DrawDebugSphere(
GetWorld(),
HitResult.ImpactPoint,
25,
12,
FColor::Green
);
RotateTurret(HitResult.ImpactPoint);
}
}
void ATank::HandleDestruction()
{
Super::HandleDestruction();
SetActorHiddenInGame(true);
SetActorTickEnabled(false);
}
APlayerController* ATank::GetPlayerController() const
{
return this->PlayerController;
}
// Called when the game starts or when spawned
void ATank::BeginPlay()
{
Super::BeginPlay();
PlayerController = Cast<APlayerController>(GetController());
PlayerControllerRef = Cast<APlayerController>(GetController());
}
void ATank::Move(float Value)

View File

@ -23,12 +23,6 @@ public:
// Called every frame
virtual void Tick(float DeltaTime) override;
// Handle's Tank Destruction by Damage
virtual void HandleDestruction() override;
// Get Current Player Controller Pointer
APlayerController* GetPlayerController() const;
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
@ -52,7 +46,7 @@ private:
// PlayerController Pointer for Mouse Location Detection
UPROPERTY()
APlayerController* PlayerController;
APlayerController* PlayerControllerRef;
// Move operation through W/S key
void Move(float Value);

View File

@ -1,31 +0,0 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "ToonTanksGameMode.h"
#include "Tank.h"
#include "ToonTanksPlayerController.h"
#include "Tower.h"
#include "Kismet/GameplayStatics.h"
void AToonTanksGameMode::BeginPlay()
{
Super::BeginPlay();
Tank = Cast<ATank>(UGameplayStatics::GetPlayerPawn(this, 0));
PlayerController = Cast<AToonTanksPlayerController>(UGameplayStatics::GetPlayerController(this, 0));
}
void AToonTanksGameMode::ActorDied(AActor* DeadActor)
{
if (DeadActor == Tank)
{
Tank->HandleDestruction();
if (PlayerController)
{
PlayerController->SetPlayerEnabledState(false);
}
}
else if (ATower* DestroyedTower = Cast<ATower>(DeadActor))
{
DestroyedTower->HandleDestruction();
}
}

View File

@ -1,33 +0,0 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/GameModeBase.h"
#include "ToonTanksGameMode.generated.h"
/**
*
*/
UCLASS()
class TOONTANKS_API AToonTanksGameMode : public AGameModeBase
{
GENERATED_BODY()
public:
// Handles input or something after Actor died.
void ActorDied(AActor* DeadActor);
protected:
virtual void BeginPlay() override;
private:
// Tank Pointer for DeadActor which is ATank.
UPROPERTY()
class ATank* Tank;
// ToonTanksPlayerController Pointer of player pawn.
UPROPERTY()
class AToonTanksPlayerController* PlayerController;
};

View File

@ -1,17 +0,0 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "ToonTanksPlayerController.h"
void AToonTanksPlayerController::SetPlayerEnabledState(bool bPlayerEnabled)
{
if (bPlayerEnabled)
{
GetPawn()->EnableInput(this);
}
else
{
GetPawn()->DisableInput(this);
}
bShowMouseCursor = bPlayerEnabled;
}

View File

@ -1,21 +0,0 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/PlayerController.h"
#include "ToonTanksPlayerController.generated.h"
/**
*
*/
UCLASS()
class TOONTANKS_API AToonTanksPlayerController : public APlayerController
{
GENERATED_BODY()
public:
// Set this controller to Enabled or Disabled.
void SetPlayerEnabledState(bool bPlayerEnabled);
};

View File

@ -14,12 +14,6 @@ void ATower::Tick(float DeltaTime)
}
}
void ATower::HandleDestruction()
{
Super::HandleDestruction();
Destroy();
}
void ATower::BeginPlay()
{
Super::BeginPlay();

View File

@ -17,15 +17,11 @@ class TOONTANKS_API ATower : public ABasePawn
public:
virtual void Tick(float DeltaTime) override;
// Handles Tower Destruction by Damage
virtual void HandleDestruction() override;
protected:
virtual void BeginPlay() override;
private:
// Tank Object Pointer which is target
UPROPERTY()
class ATank* Tank;
// Distance to Start Tracking the target