Esempio n. 1
0
    private void Update()
    {
        if (model != null && view != null)
        {
            //Check Health
            if (model.health <= 0)
            {
                if (model.isBoss)
                {
                    bossHealthScript.UpdateHealthBar();
                }
                Die();
            }

            //Move enemy
            if (model.movementEnabled)
            {
                CalculateMovement();
            }

            //If the enemy can attack and has line of sight and has a weapon, then attack
            if (Time.time >= model.NextAttackTime && PlayerInLineOfSight() && (model.meleeEnabled || model.rangedEnabled))
            {
                CalculateAttack();
            }
        }
    }