Example #1
0
 /// <summary>
 /// Called any time our character's health has changed. Makes it so that our dashg properly cancels if the character is hurt
 /// </summary>
 /// <param name="DamageData"></param>
 private void OnCharacterHealthChanged(FDamageData DamageData)
 {
     if (DamageData.DamageType != EHDamageableComponent.EDamageType.HEALING)
     {
         bIsPerformingDash = false;
     }
 }
Example #2
0
 private void OnCharacterHit(FDamageData DamageData)
 {
     if (bIsAnimParrying)
     {
         CharacterAnimator.SetTrigger(ANIM_PARRY_SUCCESS);
     }
 }
    /// <summary>
    /// This method will be called to apply damage to
    ///
    /// This will return true if damage was successfully given to the player
    /// </summary>
    /// <param name="AttackComponentThatHurtUs"></param>
    /// <param name="DamageToTake"></param>
    public bool TakeDamage(EHAttackComponent AttackComponentThatHurtUs, int DamageToTake)
    {
        FDamageData DamageData = new FDamageData();

        if (bIsInvincible)
        {
            DamageData.DamageType = EDamageType.NONE;
            OnCharacterHealthChanged?.Invoke(DamageData);
            return(false);
        }

        DamageData.AttackSource = AttackComponentThatHurtUs;
        DamageData.DamageAmount = DamageToTake;
        int PreviousHealth = Health;

        Health = Mathf.Clamp(Health - DamageToTake, 0, MaxHealth);

        if (Health <= 0 && PreviousHealth > 0)
        {
            DamageData.DamageType = EDamageType.DEATH;
        }
        else
        {
            DamageData.DamageType = EDamageType.DAMAGE;
        }
        OnCharacterHealthChanged?.Invoke(DamageData);
        return(true);
    }
    /// <summary>
    /// This method will be called when the health of our character in the Damageable Component has reached 0. Any cleanup shoud be done here
    /// </summary>
    public virtual void OnCharacterDied(FDamageData DamageData)
    {
        // If this is not a Death type attack, then we will skip this method
        if (DamageData.DamageType != EHDamageableComponent.EDamageType.DEATH)
        {
            return;
        }

        if (CharacterAnim)
        {
            CharacterAnim.SetTrigger(ANIM_CHARACTER_DIED);
        }
        this.gameObject.layer = LayerMask.NameToLayer(DEAD_LAYER);
        if (CharacterController)
        {
            CharacterController.enabled = false;
        }
        if (MovementComponent)
        {
            MovementComponent.enabled = false;
        }
        if (HitboxComponent)
        {
            HitboxComponent.enabled = false;
        }
        if (DamageableComponent)
        {
            DamageableComponent.enabled = false;
        }
        if (AttackComponent)
        {
            AttackComponent.enabled = false;
        }
    }
 public override void OnCharacterDied(FDamageData DamageData)
 {
     base.OnCharacterDied(DamageData);
     CharacterCollider.enabled = true;
     CharacterCollider.UpdateColliderBounds(false);
     CharacterCollider.UpdateColliderBounds(true);
     Physics2D.GravityScale = 1f;
 }
Example #6
0
    public void OnHealthUpdated(FDamageData DamageData)
    {
        int i = 0;

        foreach (Image HealthSegment in HealthBarImages)
        {
            if (CachedPlayerCharacter && CachedPlayerCharacter.DamageableComponent.Health > i)
            {
                HealthSegment.color = Color.white;
            }
            else
            {
                HealthSegment.color = DisabledColor;
            }
            ++i;
        }
    }