Ejemplo n.º 1
0
    void Attack(EnemyBehavior target)
    {
        combatCounter = combatIsActive;
        inCombat      = true;
        int roll = Mathf.RoundToInt(Random.Range(1, 20 + 1));

        roll += attack - target.defense;
        int crit = 5 + attack - target.defense;

        if (roll >= 8)   // 65% baseline chance to hit, missing sucks.
        {
            int dmg = Random.Range(mindmg, maxdmg + 1);
            if (Random.Range(0, 100) < crit)
            {
                for (int i = 0; i < (weapon.crit - 1); i++)
                {
                    dmg += Random.Range(mindmg, maxdmg + 1);
                }
                target.Damage(dmg, "crit");
            }
            else
            {
                target.Damage(dmg, "dmg");
            }
        }
        else
        {
            target.Damage(0, "miss");
        }
    }
    void OnTriggerEnter2D(Collider2D col)
    {
        if (col.gameObject.tag != "Projectile")
        {
            return;
        }

        ProjectileBehavior projectile = col.GetComponent <ProjectileBehavior>();

        enemy.Damage(projectile.damage);
        GameObject.Destroy(col.gameObject);

        // TODO: ANIMATE ENEMY? (TAKEN DAMAGE)

        if (enemy.IsDead())
        {
            GameObject.FindObjectOfType <Player>().AddGold(enemy.gold);
            GameObject.Destroy(enemy.gameObject);
            // TODO: ANIMATE +X GOLD!
        }
    }
Ejemplo n.º 3
0
 private void HitEnemy(EnemyBehavior enemy)
 {
     switch (enemy.enemytype)
     {
     case EnemyBehavior.type.basic:
         enemy.Damage(1);
         soundContainer.PlayAudio(SoundContainerScript.audioClips.hit);
         break;
     case EnemyBehavior.type.puukko:
         if(enemy.staggering)
         {
             enemy.Damage(1);
             soundContainer.PlayAudio(SoundContainerScript.audioClips.hit);
         }
         break;
     case EnemyBehavior.type.shield:
         if(enemy.staggering)
         {
             enemy.Damage(1);
             soundContainer.PlayAudio(SoundContainerScript.audioClips.hit);
         }
         else { enemy.staggering = true; }
         break;
     default:
         break;
     }
 }