Exemplo n.º 1
0
        ///////////////////////////////////////////////
        //// Basic Movement States ////////////////////

        public override void UpdatePatrolState()
        {
            agent.speed            = enemySpeed;
            agent.stoppingDistance = patrolStoppingDist;

            float dist = Utils.Distance2D(transform.position, nextPoint);

            if (Utils.Distance2D(transform.position, nextPoint) <= patrolStoppingDist)
            {
                FindNextPoint();
                agent.velocity = Vector3.zero;
                agent.SetDestination(nextPoint);
            }
            if (distToPlayer >= minDistToAttack && distToPlayer <= maxDistToAttack &&
                sight.InFOV(player.transform, "Player"))
            {
                // Player is in attacking radius
                lastTimeShot = Time.time - shootRate - 0.1f;
                attackHive   = false;
                currState    = SkunkState.Attacking;
            }
            else if (hiveFound &&
                     distToHive <= maxDistToAttackHive &&
                     sight.InFOV(hive.transform, "Hive") &&
                     (Time.time - hiveAttackTimer) >= hiveAttackCooldown)
            {
                // Hive is in attacking radius and hiveAttack has cooled down
                lastTimeShot    = Time.time - shootRate - 0.1f;
                hiveAttackTimer = Time.time;
                attackHive      = true;
                currState       = SkunkState.Attacking;
            }

            guiObject.SetActive(false);

            FaceTarget(nextPoint);
            anim.SetInteger(SkunkMovement, 4); // walking
        }