Exemplo n.º 1
0
    /// <summary> Update function. </summary>
    void Update()
    {
        if (!playedStartSound && Time.time >= bossInstantiatedTime + DelayForStartSound)
        {
            playedStartSound = true;
            AudioSource.PlayOneShot(StartSound, 1f);
        }

        if (needsToPlayHalfSound && Time.time >= halfSoundScheduleTime + DelayForHalfSound)
        {
            needsToPlayHalfSound = false;
            AudioSource.PlayOneShot(HalfSound, 1f);
        }

        // Dissolve out if dead
        float dissolveProgress = (Time.time - mTimeOfDeath) / DissolveTime;

        if (dissolveProgress < 1 && dissolveProgress > 0)
        {
            Dissolve.SetDissolved(dissolveProgress);
        }

        // Turn to face target
        Vector3 toTarget = Target.position - transform.position;

        toTarget.y         = 0f;
        transform.rotation = Quaternion.LookRotation(toTarget);

        Fire();
        CheckPhase();
    }
Exemplo n.º 2
0
    void Update()
    {
        // Dissolve out if dead.
        float dissolveProgress = (Time.time - mTimeOfDeath) / DissolveTime;

        if (dissolveProgress > 0 && dissolveProgress < 1)
        {
            Dissolve.SetDissolved(dissolveProgress);
            return;
        }

        // Attack if within range
        TryStartAttack();
    }
Exemplo n.º 3
0
    // Update is called once per frame
    void Update()
    {
        if (mIsAlive && Time.time - mRetreatTimeout > 5)
        {
            agent.updateRotation = true;

            bool playerInSightRange  = Vector3.Distance(_Target.transform.position, transform.position) < SightRange;
            bool playerInAttackRange = Vector3.Distance(_Target.transform.position, transform.position) < AttackRange;

            if (!playerInSightRange && !playerInAttackRange && CanWander)
            {
                Wander();
            }

            if (playerInSightRange && CanChasePlayer)
            {
                ChasePlayer();
            }

            if (playerInAttackRange && playerInSightRange && CanAttackPlayer)
            {
                AttackPlayer();
            }

            if (mWasHitLastFrame && Random.value <= RetreatProbability && CanRetreat)
            {
                RetreatPlayer();
            }

            mWasHitLastFrame = false;
        }

        // Dissolve out if dead.
        float dissolveProgress = (Time.time - mTimeOfDeath) / DissolveTime;

        if (dissolveProgress > 0 && dissolveProgress < 1)
        {
            Dissolve.SetDissolved(dissolveProgress);
        }

        WalkingAnimation();
    }