Init
This commit is contained in:
35
Source/FireworkDuels/BuildingBlock.cpp
Normal file
35
Source/FireworkDuels/BuildingBlock.cpp
Normal file
@@ -0,0 +1,35 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "BuildingBlock.h"
|
||||
|
||||
// Sets default values
|
||||
ABuildingBlock::ABuildingBlock()
|
||||
{
|
||||
// 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;
|
||||
InitialHealth = Health;
|
||||
|
||||
StaticMesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("StaticMesh"));
|
||||
}
|
||||
|
||||
void ABuildingBlock::DepleteHealth(float Amount) {
|
||||
Health =- Amount;
|
||||
|
||||
if (Health <= 0.f) {
|
||||
DestroyBlock();
|
||||
}
|
||||
else {
|
||||
uint8 DestructionLevel = 0;
|
||||
if (Health <= InitialHealth * 0.66f) {
|
||||
if (Health <= InitialHealth * 0.33f) {
|
||||
DestructionLevel = 2;
|
||||
}
|
||||
else {
|
||||
DestructionLevel = 1;
|
||||
}
|
||||
}
|
||||
|
||||
UpdateDestructionLevel(DestructionLevel);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user