-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUpgradeManager.h
184 lines (129 loc) · 4.45 KB
/
UpgradeManager.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "Components/ActorComponent.h"
#include "Runtime/Engine/Classes/Engine/DataTable.h"
#include "UpgradeManager.generated.h"
// TODO: Nitro upgrades
class UPlayerProfile;
UENUM()
enum class EUpgrades : uint8
{
Engine = 0 UMETA(DisplayName = "Engine"),
Gearbox = 1 UMETA(DisplayName = "Gearbox"),
Steering = 2 UMETA(DisplayName = "Steering"),
Brakes = 3 UMETA(DisplayName = "Brakes"),
Nitro = 4 UMETA(DisplayName = "Nitro")
};
USTRUCT(BlueprintType)
struct FUpgradeTableRow : public FTableRowBase
{
GENERATED_USTRUCT_BODY()
/// <summary>
/// UpgradeAmounts array explanation for each upgrade type (cumulative except price):
///
/// Engine: price-power-rpm-extra gear ratio
/// GearBox: price-gear change speed decrease
/// ...
/// </summary>
public:
FUpgradeTableRow() : UpgradeLevel(0), UpgradeAmounts({}) {}
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = LevelUp)
int32 UpgradeLevel;
// first element of this array is price, rest are properties that will change depending on upgraded part type
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = LevelUp)
TArray<float> UpgradeAmounts;
};
UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
class THEIMPOSSIBLE_API UUpgradeManager : public UActorComponent
{
GENERATED_BODY()
public:
// Sets default values for this component's properties
UUpgradeManager();
protected:
// Called when the game starts
virtual void BeginPlay() override;
public:
// Called every frame
virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
void SetActiveCar(FString CarName);
int32 GetUpgradeLevel(EUpgrades UpgradeType);
void Upgrade(EUpgrades UpgradeType);
UFUNCTION(BlueprintCallable)
void UpdateUpgrades();
UFUNCTION(BlueprintCallable)
int32 GetEngineUpgrade();
UFUNCTION(BlueprintCallable)
int32 GetGearBoxUpgrade();
UFUNCTION(BlueprintCallable)
int32 GetSteeringUpgrade();
UFUNCTION(BlueprintCallable)
int32 GetBrakesUpgrade();
UFUNCTION(BlueprintCallable)
int32 GetNitroUpgrade();
UFUNCTION(BlueprintCallable)
float GetEnginePrice();
UFUNCTION(BlueprintCallable)
float GetGearBoxPrice();
UFUNCTION(BlueprintCallable)
float GetSteeringPrice();
UFUNCTION(BlueprintCallable)
float GetBrakesPrice();
UFUNCTION(BlueprintCallable)
float GetNitroPrice();
UFUNCTION(BlueprintCallable)
bool UpgradeEngine();
UFUNCTION(BlueprintCallable)
bool UpgradeGearBox();
UFUNCTION(BlueprintCallable)
bool UpgradeSteering();
UFUNCTION(BlueprintCallable)
bool UpgradeBrakes();
UFUNCTION(BlueprintCallable)
bool UpgradeNitro();
UFUNCTION()
void ResetUpgrades();
UPROPERTY()
UPlayerProfile* OwnerProfile;
UPROPERTY()
FString ActiveCar = "Pantera";
//UPROPERTY()
//TArray<int32> ActiveUpgradeLevels = { 0, 0, 0, 0, 0 };
// Car Upgrade Stuff
float BasePrice = 10.f;
TArray<float> PriceMultipliers = { 0.8f, 2.4f, 2.4f, 2.4f, 2.4f }; // engine, gearbox, steering, brakes, nitro
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "General")
int32 MaxUpgrade = 29;
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "General")
int32 MaxUpgradeNitro = 29;
//int32 EngineUpgrade = 0;
//int32 GearBoxUpgrade = 0;
//int32 SteeringUpgrade = 0;
//int32 BrakesUpgrade = 0;
//int32 NitroUpgrade = 0;
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "General")
float ExtraEnginePower = 0.f;
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "General")
float ExtraEngineRPM = 0.f;
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "General")
float ExtraGearRatio = 0.f;
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "General")
float ExtraGearChangeSpeed = 0.f;
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "General")
float ExtraSteeringMultiplier = 0.f;
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "General")
float ExtraBrakePower = 0.f;
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "General")
float NitroTime = 0.f;
float EngineUpgradePriceMultiplier = 5.f;
float GearBoxUpgradePriceMultiplier = 5.f;
float SteeringUpgradePriceMultiplier = 5.f;
float BrakesUpgradePriceMultiplier = 5.f;
float NitroUpgradePriceMultiplier = 25.f;
class UDataTable* UpgradeTableEngine;
class UDataTable* UpgradeTableGearBox;
class UDataTable* UpgradeTableSteering;
class UDataTable* UpgradeTableBrakes;
class UDataTable* UpgradeTableNitro;
};