Heroic Engine
  • Welcome
  • Getting Started
    • Quickstart
    • Example Games
      • Tic Tac Toe
      • Turn based duel
  • Basics
    • Injection Manager
    • Engine Systems
      • Core Systems
        • Events Manager
        • Input Manager
        • Localization Manager
          • LangText component
        • Music Player
        • Sounds Manager
        • Time Manager
        • Scenes Loader
        • Day Time Controller
        • Weather Controller
      • Gameplay Systems
        • Currencies Manager
        • Player Progression Manager
        • Quest Manager
        • Random Events Manager
        • Hittables Manager
        • Dungeon Generator
      • UI Systems
        • UI Controller
        • Countdown Controller
    • Editor Tools
      • Clear Saves
      • Mobile Build Optimizer
      • Create System
      • Icon from Prefab Generator
    • Engine Utilities
      • PoolSystem
      • DataSaver
      • ComponentExtensions
      • MaterialExtensions
      • SpriteUtils
      • SlowUpdate
      • StringUtils
      • TypeUtility
      • MathHelper
      • VectorUtils
      • TransformUtils
      • MeshUtils
    • Useful Components
      • Floating Item
      • Fly Up Text
      • Label Scaler
      • Ragdoll
      • Rotate To Camera
      • Orbital Camera
      • Rotator
      • Texture Mover
      • Hittable
      • Projectile
      • Projectile2D
      • LifetimeObject
      • Spawner
      • Colorized Particles
      • Draggable2D
      • SaveableTransform
    • Useful Attributes
Powered by GitBook
On this page
  • Protected fields (can be used from inherited class)
  • Available methods
  1. Basics
  2. Useful Components

Hittable

This component represents basic class of hittable entity (entity with HP, which can get damage, can be healed and killed).

We recommend to use it as base class for your characters in case if that characters should be able to get damage.

Protected fields (can be used from inherited class)

protected float currHealth;

Current health of hittable entity.

protected float maxHealth;

Max health of hittable entity.

protected TeamType teamType;

Team of this hittable object. TeamType.None by default.


Available methods

public void SetTeam(TeamType teamType)

This method assigns hittable object to certain team.


public virtual Transform GetHitTransform()

This method returns hit transform if this hittable. By default, its own transform is returned. Can be used for targeting enemy projectiles to this hittable entity.


public void GetDamage(float damage)

This method inflicts certain amount of damage to this hittable entity.


public void Heal(float amount)

This method applies certain amount of healing to this hittable entity.


public void Kill()

Instantly kills hittable entity.


public void ResetHealth()

Resets current health to max value.


public bool IsDead()

Returns true in case if entity is dead, otherwise false.


public float GetHPPercentage()

Returns current percentage of HP.


public float GetHP()

Returns current amount of HP.


public float GetMaxHP()

Returns max amount of HP.


public void SubscribeToDamageGot(UnityAction<float> onDamageGot)

This method adds listener to damage got event. If entity gets damage, given listener will be invoked.

Example:

character.SubscribeToDamageGot(damage =>
{
    FlyUpText ft = PoolSystem.GetInstanceAtPosition(combatTextPrefab, combatTextPrefab.GetName(), canvasTransform.position, canvasTransform);
    ft.SetColor(Color.red);
    ft.SetText($"-{Mathf.CeilToInt(damage)}");
    RefreshHPBar();
});

public void SubscribeToHealingGot(UnityAction<float> onHealingGot)

This method adds listener to healing got event. If entity gets healing, given listener will be invoked.


public void SubscribeToDeath(UnityAction onDeath)

This method adds listener to death event. If entity dies, given listener will be invoked.

PreviousTexture MoverNextProjectile

Last updated 4 months ago