Class TCastleAliveBehavior
Unit
Declaration
type TCastleAliveBehavior = class(TCastleBehavior)
Description
Behavior that tracks life points, and determines being alive/dead for game purposes.
Using this class in your own games is completely optional. You can implement "alive" functionality yourself trivially, and then make your own decisions about various details (e.g. is life a float, or integer? does life equal "precisely zero" means being still alive, or dead?).
Hierarchy
- TObject
- TPersistent
- TComponent
- TCastleComponent
- TCastleBehavior
- TCastleAliveBehavior
Overview
Fields
nested const DefaultLife = 100.0; |
Methods
function CanAttachToParent(const NewParent: TCastleTransform; out ReasonWhyCannot: String): Boolean; override; |
|
constructor Create(AOwner: TComponent); override; |
|
function PropertySections(const PropertyName: String): TPropertySections; override; |
|
function Dead: Boolean; |
|
procedure Hurt(const LifeLoss: Single; const AHurtDirection: TVector3; const AHurtStrength: Single = 0; const AnAttacker: TCastleAliveBehavior = nil); virtual; |
Properties
property HurtDirection: TVector3 read FHurtDirection; |
|
property HurtStrength: Single read FHurtStrength; |
|
property Attacker: TCastleAliveBehavior read FAttacker write SetAttacker; |
|
property Life: Single read FLife write FLife default DefaultLife; |
|
property MaxLife: Single read FMaxLife write FMaxLife default DefaultLife; |
Description
Fields
nested const DefaultLife = 100.0; |
|
Methods
function CanAttachToParent(const NewParent: TCastleTransform; out ReasonWhyCannot: String): Boolean; override; |
|
constructor Create(AOwner: TComponent); override; |
|
function PropertySections(const PropertyName: String): TPropertySections; override; |
|
function Dead: Boolean; |
|
Shortcut for checking Life <= 0. |
procedure Hurt(const LifeLoss: Single; const AHurtDirection: TVector3; const AHurtStrength: Single = 0; const AnAttacker: TCastleAliveBehavior = nil); virtual; |
|
Hurt given creature, decreasing its Life by LifeLoss, also setting some additional properties that describe the damage. These additional properties do not do anything in this class – but they may be useful by other effects, e.g. "knockback", done by other behaviors. Note: If all you want to do is to decrease Life, you can also just set Life property directly.
) Parameters
|
Properties
property HurtDirection: TVector3 read FHurtDirection; |
|
Direction from where the last attack came, set by Hurt. Zero if there was no specific direction of last attack, otherwise a normalized (length 1) vector. |
property HurtStrength: Single read FHurtStrength; |
|
Strengh of the last attack, set by Hurt. What this "strengh" exactly means is not defined in this class. It may cause a "knockback" effect, in which case it may be a knockback distance, or a physical force strength, and is meaningful only when HurtDirection is non-zero. |
property Attacker: TCastleAliveBehavior read FAttacker write SetAttacker; |
|
Last |
property Life: Single read FLife write FLife default DefaultLife; |
|
Current Life. The object is considered "dead" when this is <= 0. |
property MaxLife: Single read FMaxLife write FMaxLife default DefaultLife; |
|
Maximum amount of life. Can be also used for information (to display on player HUDs and such). This is not a strict limit on Life, i.e. all the code allows the have Life > MaxLife to account for special game mechanisms, like "magic life boost to make health temporarily larger than normal". It is up to your game whether such situation will actually happen. |
Generated by PasDoc 0.16.0.