Gorilla.Utils.SkillSystem
Unit Gorilla.Utils.SkillSystem.pasClasses
- TGorillaCustomSkillEntity = class ( TCollectionItem )
- TGorillaCustomSkillCollection = class ( TOwnedCollection )
- TGorillaSkill = class ( TGorillaCustomSkillEntity )
- TGorillaSkillProcess = class ( TObject )
- TGorillaSkillProcessThread = class ( TThread )
- TGorillaSkillCollection = class ( TGorillaCustomSkillCollection )
- TGorillaSkillGroup = class ( TGorillaCustomSkillEntity )
- TGorillaSkillGroupCollection = class ( TGorillaCustomSkillCollection )
- TGorillaSkillSystem = class ( TComponent )
Enumerations
- enum TGorillaSkillLevelInterpolation = ( LinearInterpolation, LogarithmicInterpolation, ExponentialInterpolation, ExponentialMinus1Interpolation ) ;
Constants
TGorillaCustomSkillEntity
A custom entity of the skill system. This is the basis for TGorillaSkill and TGorillaSkillGroup.
Ancestors
Members
Fields
- protected FGUID :
TGUID
- protected FEnabled :
Boolean
- protected FName :
TGorillaLanguageMap
- protected FIcon :
Integer
- protected FPosition :
TPointF
Methods
- public constructor Create ( ACollection : TCollection ) ;
- public destructor Destroy ( ) ;
- protected function GetName ( ) : string ; virtual;
- protected procedure SetName ( const AValue : string ) ; virtual;
- protected function GetSkillSystem ( ) : TGorillaSkillSystem ; virtual;
- protected procedure DoOnFromXmlProperty
(
const
ANode :
TMz_XmlElement
)
;
virtual;
Used to react on property nodes of a parent xml element.
- public function GetIdentifier ( ) : string ; class abstract virtual;
- public procedure FromXml
(
const
ANode :
TMz_XmlElement
)
;
virtual;
Read entity properties and attributes from a specific xml element.
- public function ToXml
(
const
AParent :
TMz_XmlElement
)
: TMz_XmlElement
;
virtual;
Write entity properties and attributes to a specific xml element.
Properties
- public GUID : TGUID
Defines a unique identifier for this entity. This guid is useful to find an entity in global context.
read FGUID - public Name : string
- public SkillSystem : TGorillaSkillSystem
- published Enabled : Boolean
- published Icon : Integer
- published Position : TPointF
TGorillaCustomSkillCollection
A custom skill collection. This collection is used as basis for the TGorillaSkillCollection and TGorillaSkillGroupCollection.
Ancestors
Members
TGorillaSkill
Represents a single skill entity.
Ancestors
Members
Fields
- protected FActivated :
Boolean
- protected FValue :
Single
- protected FFactor :
Single
- protected FInterpolation :
TGorillaSkillLevelInterpolation
- protected FLevel :
Integer
- protected FMaxLevel :
Integer
- protected FLevelingTime :
Integer
- protected FNextSkill :
TGUID
- protected FNextSkillObj :
TGorillaSkill
- protected FData :
TValue
Methods
- public constructor Create ( ACollection : TCollection ) ;
- public destructor Destroy ( ) ;
- protected function GetSkillGroup ( ) : TGorillaSkillGroup ; virtual;
- protected function GetNextSkillObject ( ) : TGorillaSkill ; virtual;
- protected procedure DoLevelUp ( const AProcess : TGorillaSkillProcess ) ; virtual;
- protected function DoInterpolateValue ( const ALevel : Integer; const ACurrentValue : Single; const AFactor : Single ) : Single ; virtual;
- protected procedure DoOnFromXmlProperty ( const ANode : TMz_XmlElement ) ; override;
- public function GetIdentifier ( ) : string ; class override;
- public function ToXml ( const AParent : TMz_XmlElement ) : TMz_XmlElement ; override;
- public function StartLevelingUp
(
)
: TGorillaSkillProcess
;
virtual;
Starts an up-leveling async process.
- public function GetLastActivatedSkill
(
)
: TGorillaSkill
;
virtual;
Iterates through the complete chain of skill links and returns the last activated skill.
- public function GetLastSkill
(
)
: TGorillaSkill
;
virtual;
Iterates through the complete chain of skill links and returns the last skill.
Properties
- public Group : TGorillaSkillGroup
- public NextSkillObj : TGorillaSkillread GetNextSkillObject
- published Activated : Boolean
Defines if the skill is activated for use. It is different to "Enabled" which only unlocks the skill for activation.
read FActivated
write FActivated - published Value : Single
- published Factor : Single
- published Interpolation : TGorillaSkillLevelInterpolation
Defines an interpolation function by which a new value is computed, in dependency to the level.
read FInterpolation
write FInterpolation - published Level : Integer
- published MaxLevel : Integer
- published LevelingTime : Integer
Defines the time for leveling up this skill. By default this value is set to 1000ms.
read FLevelingTime
write FLevelingTime - published NextSkill : TGUID
Defines a linked skill which will be enabled on leveling up. Use this property instead of interpolation mechanism.
read FNextSkill
write FNextSkill - published Data : TValue
TGorillaSkillProcess
Represents a asynchronous development process. This component is used to simulate leveling up in a specific time.
Ancestors
Members
Fields
- protected FSkill :
TGorillaSkill
- protected FToLevel :
Integer
- protected FNewValue :
Single
- protected FStartTime :
Int64
- protected FTotalTime :
Integer
Methods
- public constructor Create ( const ASkill : TGorillaSkill; const ATotalTime : Integer; const AToLevel : Integer; const ANewValue : Single ) ;
- protected function GetIsStarted ( ) : Boolean ;
- protected function GetIsElapsed ( ) : Boolean ;
- public procedure Start
(
)
;
virtual;
Explicitly starts the leveling process. If a process was already started this method ignores the action.
- public procedure FromXml ( const ASkillSystem : TGorillaSkillSystem; const ANode : TMz_XmlElement ) ; virtual;
- public procedure ToXml ( const AParent : TMz_XmlElement ) ; virtual;
Properties
- public Skill : TGorillaSkill
- public ToLevel : Integer
- public NewValue : Single
- public StartTime : Int64
Returns the starting time of the process. The start time is only set by a call of Start() method.
read FStartTime - public TotalTime : Integer
- public IsStarted : Boolean
- public IsElapsed : Boolean
TGorillaSkillProcessThread
Manages skill leveling process asynchronously. Processes will be added by the <TGorillaSkill>.StartLevelUp() method automatically. On execution process will be started, if they were not already. The thread checks every 500ms if processes need to be started or are finished. On completion processes will be destroyed and the skill will be updated.
Ancestors
Members
Fields
Methods
- public constructor Create ( ASuspended : Boolean ) ;
- public destructor Destroy ( ) ;
- protected procedure Execute ( ) ; override;
- protected procedure DoOnProcessListNotify ( ASender : TObject; const AItem : TGorillaSkillProcess; AAction : TCollectionNotification ) ; virtual;
- public procedure AddProcess
(
const
AProcess :
TGorillaSkillProcess
)
;
virtual;
Adds a leveling process to the thread.
- public procedure ClearProcesses
(
)
;
virtual;
Clears all available process.
Properties
TGorillaSkillCollection
Represents a collection of skill entities.
Ancestors
Members
Properties
TGorillaSkillGroup
Representing a skill group or category. It's possible to add skill entities to this collection.
Ancestors
Members
Fields
Methods
- public constructor Create ( ACollection : TCollection ) ;
- public destructor Destroy ( ) ;
- protected procedure DoOnFromXmlProperty ( const ANode : TMz_XmlElement ) ; override;
- public function GetIdentifier ( ) : string ; class override;
- public function ToXml ( const AParent : TMz_XmlElement ) : TMz_XmlElement ; override;
- public function AddSkill
(
)
: TGorillaSkill
;
virtual;
Adds a new and empty skill instance to the specific group and returns the newly created instance.
- public function FindSkillByName
(
const
ASkillName :
string
)
: TGorillaSkill
;
virtual;
Tries to find a specific skill by its display name. If the method cannot find a skill, it returns nil.
- public function FindSkillByGUID
(
const
AGUID :
TGUID
)
: TGorillaSkill
;
virtual;
Tries to find a specific skill by its GUID. If the method cannot find a skill, it returns nil.
- public function GetActivatedSkills
(
)
: TGorillaSkillMap
;
virtual;
Searches and returns all activated skills. Each skill will be iterated to get the latest skill in row (if skills are linked).
Properties
TGorillaSkillGroupCollection
Represents a skilling group to organize skill in categories.
Ancestors
TGorillaSkillSystem
Defines a skilling system with categorization in groups. Each group contains a variable number of skill entities.
Ancestors
Members
Fields
- protected FLanguage :
Integer
- protected FGroups :
TGorillaSkillGroupCollection
- protected FPosition :
TPointF
- protected FLeveling :
TGorillaSkillProcessThread
Methods
- public constructor Create ( AOwner : TComponent ) ;
- public destructor Destroy ( ) ;
- public procedure SaveToStream
(
const
AStream :
TStream
)
;
virtual;
Stores the current skill system to stream as xml-format. Including all groups with skills and currently active leveling processes.
- public procedure SaveToFile
(
const
AFilename :
string
)
;
virtual;
Stores the current skill system to file as xml-format. Including all groups with skills and currently active leveling processes.
- public procedure LoadFromStream
(
const
AStream :
TStream
)
;
virtual;
Loads the skill system from xml formatted stream. Including all groups with skills and currently active leveling processes.
- public procedure LoadFromFile
(
const
AFilename :
string
)
;
virtual;
Loads the skill system from xml file. Including all groups with skills and currently active leveling processes.
- public function GetCurrentLanguageId
(
)
: string
;
virtual;
Returns the current language id depending on the set language value.
- public function AddGroup
(
)
: TGorillaSkillGroup
;
virtual;
Adds and returns a new skill group to the system.
- public procedure RemoveGroup
(
const
AGroup :
TGorillaSkillGroup
)
;
virtual;
Removes an existing skill group from system.
- public function FindSkillByGUID
(
const
AGUID :
TGUID
)
: TGorillaSkill
;
virtual;
Tries to find a specific skill by its unique guid. If no skill with this guid could be found, the method returns null.