Beispiel #1
0
 protected void UnitIsAlive(UnitMovement unit)
 {
     if (unit.GetComponent <BaseStats>().HP <= 0)
     {
         if (unit.tag == "Player")
         {
             unit.GetComponentInChildren <CharacterAnimatorController>().lateDeathAnimation = true;
         }
         if (unit.tag == "NPC")
         {
             unit.GetComponentInChildren <ZombieAnimatorController>().lateDeathAnimation = true;
         }
         TurnManager.RemoveUnit(unit);
     }
 }
Beispiel #2
0
    private void AttackEnemy(RaycastHit hit)
    {
        Vector3 distance = new Vector3();

        distance = hit.collider.transform.position - transform.position;
        if (Mathf.Abs(distance.magnitude) <= this.GetComponent <FieldOfView>().viewRadius)
        {
            if (Mathf.Abs(distance.magnitude) >= 3)
            {
                Weapon.setGunVisible(true);
                hit.collider.GetComponent <BaseStats>().HP -= this.GetComponent <BaseStats>().RangeAtack;
                CharacterAnimController.isShooting          = true;
            }
            else if (Mathf.Abs(distance.magnitude) < 3)
            {
                hit.collider.GetComponent <BaseStats>().HP -= this.GetComponent <BaseStats>().MeleAtack;
                CharacterAnimController.isPunching          = true;
            }

            alredyAttack = true;
        }

        UnitMovement unit = hit.collider.GetComponent <UnitMovement>();

        if (unit.GetComponent <BaseStats>().HP <= 0)
        {
            RingSelectedEnemy.SetDeactiveRing();
            UnitIsAlive(unit);
        }
        else if (alredyAttack)
        {
            unit.GetComponentInChildren <ZombieAnimatorController>().lateHitAnimation = true;
        }
    }