예제 #1
0
    //Deals with removing health, activating damage animations, and checking if dead then trigger death
    private void TakeDamage(Damage damage, bool triggerAnimation)
    {
        if (damage.DamageValue < 0)
        {
            damage.DamageValue = 0;
        }

        characterStats.decreaseHealth(damage.DamageValue);

        //Create a UI Damage Pop up
        DamagePopUpController.CreateDamagePopUp(damage.DamageValue.ToString(), new Vector2(transform.position.x + ThisCollider.bounds.size.x / 4.0f, transform.position.y + ThisCollider.bounds.size.y / 2.0f), damage.IsCrit, damage.damageType);

        if (triggerAnimation)
        {
            if (ThisAnimator != null)
            {
                ThisAnimator.SetTrigger("damage");
                // play hit audio
                if (gameObject.tag == "Player")
                {
                    gameObject.GetComponent <PlayerControllerScript> ().playHitSound();
                }
                else if (gameObject.tag == "Enemy")
                {
                    gameObject.GetComponent <Enemy> ().playHitSound();
                }
            }
        }

        if (IsDead())
        {
            Die();
        }
    }
예제 #2
0
    /* Damage */

    //Deals with removing health, activating damage animations, and checking if dead then trigger death
    private void TakeDamage(Damage damage)
    {
        if (damage.DamageValue > 0)
        {
            removeHealth(damage.DamageValue);

            //Create a UI Damage Pop up
            DamagePopUpController.CreateDamagePopUp(damage.DamageValue.ToString(), new Vector3(transform.position.x, transform.position.y + ThisCollider.bounds.size.y, transform.position.z), damage.damageType);

            if (IsDead())
            {
                Die();
            }
        }
    }
예제 #3
0
 private void InitializeVariables()
 {
     DamagePopUpController.Initialize();
 }
예제 #4
0
 private void InitializeControllers()
 {
     DamagePopUpController.Initialize();
     ressourcesController.Initialize();
 }