You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
101 lines
2.1 KiB
101 lines
2.1 KiB
// Copyright Zelle Games
|
|
|
|
|
|
#include "StatsSubsystem.h"
|
|
|
|
#include "Components/DirectionalLightComponent.h"
|
|
|
|
void UStatsSubsystem::RotateSun(ADirectionalLight* DirectionalLight)
|
|
{
|
|
float YAngle = SunRotations[(CurrentWave % 3)];
|
|
UDirectionalLightComponent* DirectionalLightComponent = Cast<UDirectionalLightComponent>(DirectionalLight->GetLightComponent());
|
|
DirectionalLightComponent->SetWorldRotation(FRotator(YAngle, 43, 0));
|
|
}
|
|
|
|
bool UStatsSubsystem::IncreaseStat(FString StatName)
|
|
{
|
|
int32* StatToIncrease = &AttackPower;
|
|
int32 NextCost = 0;
|
|
|
|
if(StatName == "HP")
|
|
{
|
|
NextCost = GetNextCost(MaxHP, StatName);
|
|
StatToIncrease = &MaxHP;
|
|
} else if(StatName == "ATK")
|
|
{
|
|
NextCost = GetNextCost(AttackPower, StatName);
|
|
} else if(StatName == "ASPD")
|
|
{
|
|
NextCost = GetNextCostFloat(AttackSpeed, StatName);
|
|
} else if(StatName == "DEF")
|
|
{
|
|
NextCost = GetNextCost(DefensePower, StatName);
|
|
StatToIncrease = &DefensePower;
|
|
} else if(StatName == "DEX")
|
|
{
|
|
NextCost = GetNextCost(Dexterity, StatName);
|
|
StatToIncrease = &Dexterity;
|
|
} else if(StatName == "REC")
|
|
{
|
|
NextCost = GetNextCost(RecoveryPerTurn, StatName);
|
|
StatToIncrease = &RecoveryPerTurn;
|
|
}
|
|
|
|
if(XP >= NextCost)
|
|
{
|
|
XP -= NextCost;
|
|
if(StatName == "ASPD")
|
|
{
|
|
AttackSpeed += 0.01f;
|
|
} else if(StatName == "HP")
|
|
{
|
|
(*StatToIncrease) += 10;
|
|
}else
|
|
{
|
|
(*StatToIncrease)++;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
int32 UStatsSubsystem::GetNextCost(int32 Input, FString StatName)
|
|
{
|
|
int32 Divisor;
|
|
float Multiplier;
|
|
if(StatName == "HP")
|
|
{
|
|
Divisor = 100;
|
|
Multiplier = 1.5f;
|
|
} else
|
|
{
|
|
Divisor = 10;
|
|
Multiplier = 1.5f;
|
|
}
|
|
|
|
int32 NumBreakpoints = FMath::DivideAndRoundDown(Input, Divisor);
|
|
return FMath::CeilToInt(NumBreakpoints * Multiplier) + 1;
|
|
|
|
}
|
|
|
|
int32 UStatsSubsystem::GetNextCostFloat(float Input, FString StatName)
|
|
{
|
|
int32 Divisor;
|
|
float Multiplier;
|
|
float Base;
|
|
if(StatName == "ASPD")
|
|
{
|
|
Divisor = 20;
|
|
Multiplier = 1.2f;
|
|
Base = 0.33f;
|
|
} else
|
|
{
|
|
Divisor = 10;
|
|
Multiplier = 1.5f;
|
|
Base = 0.33f;
|
|
}
|
|
|
|
int32 NumBreakpoints = FMath::DivideAndRoundDown(FMath::FloorToInt((Input - Base) * 100) , Divisor);
|
|
return FMath::CeilToInt(NumBreakpoints * Multiplier) + 1;
|
|
} |