Exemple #1
0
    // Update is called once per frame
    void Update()
    {
        //TODO: REFACTOR
        if (Rend.isVisible && !CanSeePlayer) //since we do this before CanSeePlayer is set
        //this will be the first frame the enemy is visible
        {
            GlobalData.AddIntesinty(IntensityValue);
        }
        if (!Rend.isVisible && CanSeePlayer)
        {
            GlobalData.SubtractIntesinty(IntensityValue);
        }
        CanSeePlayer = Rend.isVisible;


        if (CanSeePlayer)
        {
            AttackTimer += Time.deltaTime;
            if (AttackTimer >= AttackChargeTimeInSeconds)
            {
                AttackPlayer();
                AttackTimer = 0;
            }
        }
        else
        {
            AttackTimer = 0;
        }
    }