Skip to content

Commit e7b3a83

Browse files
committed
Added power to 'BatteryCollectorCharacter'
1 parent e749447 commit e7b3a83

4 files changed

Lines changed: 47 additions & 0 deletions

File tree

629 Bytes
Binary file not shown.
4.22 KB
Binary file not shown.

Source/BatteryCollector/BatteryCollectorCharacter.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ ABatteryCollectorCharacter::ABatteryCollectorCharacter()
4545

4646
// Note: The skeletal mesh and anim blueprint references on the Mesh component (inherited from Character)
4747
// are set in the derived blueprint asset named MyCharacter (to avoid direct content references in C++)
48+
49+
//set a base power level for the character
50+
InitialPower = 2000.f;
51+
CharacterPower = InitialPower;
4852
}
4953

5054
//////////////////////////////////////////////////////////////////////////
@@ -155,3 +159,22 @@ void ABatteryCollectorCharacter::CollectPickups()
155159
}
156160
}
157161
}
162+
163+
// Reports starting power
164+
float ABatteryCollectorCharacter::GetInitialPower()
165+
{
166+
return InitialPower;
167+
}
168+
169+
// Reports current power
170+
float ABatteryCollectorCharacter::GetCurrentPower()
171+
{
172+
return CharacterPower;
173+
}
174+
175+
// called whenever power is increased or decreased
176+
void ABatteryCollectorCharacter::UpdatePower(float PowerChange)
177+
{
178+
// change power
179+
CharacterPower = CharacterPower + PowerChange;
180+
}

Source/BatteryCollector/BatteryCollectorCharacter.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,21 @@ class ABatteryCollectorCharacter : public ACharacter
3030
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category=Camera)
3131
float BaseLookUpRate;
3232

33+
/** Accessor function for initial power */
34+
UFUNCTION(BlueprintPure, Category = "Power")
35+
float GetInitialPower();
36+
37+
/** Accessor function for current power */
38+
UFUNCTION(BlueprintPure, Category = "Power")
39+
float GetCurrentPower();
40+
41+
/**
42+
Function to update the character's power
43+
* @param PowerChange This is the amount to change the power by, and it can be positive or negative.
44+
*/
45+
UFUNCTION(BlueprintCallable, Category = "Power")
46+
void UpdatePower(float PowerChange);
47+
3348
protected:
3449

3550
/** Called for forwards/backward input */
@@ -65,6 +80,15 @@ class ABatteryCollectorCharacter : public ACharacter
6580
UFUNCTION(BlueprintCallable, Category = "Pickups")
6681
void CollectPickups();
6782

83+
/**The starting power level of our character */
84+
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Power", Meta = (BlueprintProtected = "true"))
85+
float InitialPower;
86+
87+
private:
88+
/**Current power level of our character */
89+
UPROPERTY(VisibleAnywhere, Category = "Power")
90+
float CharacterPower;
91+
6892
public:
6993
/** Returns CameraBoom subobject **/
7094
FORCEINLINE class USpringArmComponent* GetCameraBoom() const { return CameraBoom; }

0 commit comments

Comments
 (0)