Exemple #1
0
 // Update is called once per frame
 public void OpenObject() //not a talking NPC, but can be used as this message is already being sent
 {
     //pc.talking = false;
     if (!opened)
     {
         opened    = true;
         sr.sprite = openedSprite;
         loot.DropLoot();// false, not from an enemy
     }
 }
Exemple #2
0
    public void TakeDamage(int amount, DamageType damageType, bool criticalHit, Vector3 pos)
    {
        if (damageType == DamageType.fire && frozen)
        {
            frozen = false;
        }
        if (damageType == DamageType.ice && onFire)
        {
            onFire = false;
        }
        // If the enemy is dead or immune...
        if (isDead || damageType == immuneToDamageType)
        {
            // ... no need to take damage so exit the function.
            return;
        }
        if (ai.currentState != EnemyState.aggro) //aggro the enemy if it waas previously not aggro'd
        {
            ai.currentState = EnemyState.aggro;
        }
        if (isStunnable)
        {
            stunnable.CallStun(damageType);
        }
        // Reduce the current health by the amount of damage sustained.
        previousHealth = currentHealth;
        if (weakToDamageType == damageType)
        {
            Debug.Log("Weak to type " + damageType + ", its super effective!");
            totalDamage = amount * 2;
            //Player SuperEffective Animation
            StartCoroutine(SuperEffectiveAnimation());
        }
        else
        {
            totalDamage = amount;
            Debug.Log("Base Damage = " + amount);
            //Play standard hit Animation
            StartCoroutine(HitAnimation());
        }
        if (criticalHit == true)
        {
            Debug.Log("Critical Hit!");
            totalDamage *= 2;
            //play Critical Hit animation
            StartCoroutine(CritAnimation(pos));
        }
        CheckStunType(damageType);

        currentHealth -= totalDamage;

        Debug.Log(gameObject.name + " takes " + totalDamage + " damage");
        currH          = (float)currentHealth / (float)startingHealth;
        prevH          = (float)previousHealth / (float)startingHealth;
        previousHealth = currentHealth;

        StartCoroutine("HealthSliderAnimation");


        // Set the position of the particle system to where the hit was sustained.
        //hitParticles.transform.position = hitPoint;

        // And play the particles.
        //hitParticles.Play();

        // If the current health is less than or equal to zero...
        if (currentHealth <= 0)
        {
            // ... the enemy is dead.
            Death();
            loot.DropLoot(); // true, loot is from an enemy
        }
    }