Ejemplo n.º 1
0
 public void SetTarget(Transform target)
 {
     player = target;
     RearviewCameraBehaviour.RequestRearviewOff();
     if (target.CompareTag("Player"))
     {
         RearviewCameraBehaviour.RequestRearviewOn();
     }
 }
Ejemplo n.º 2
0
        ///////////////////////////////////////////////
        //// Basic Movement States ////////////////////

        public override void UpdatePatrolState()
        {
            // figure out if the player is in the circle
            if (distToPlayer <= circleRadius)
            {
                if (!playerInRange)
                {
                    RearviewCameraBehaviour.RequestRearviewOn();
                    playerInRange = true;
                    attackTimer   = Time.time; // time how long the player is in range
                }

                SetTimeSlider(true, (Time.time - attackTimer));
            }
            else
            {
                SetTimeSlider(false, 0);
                playerInRange = false;
            }

            // State Logic
            if (playerInRange && Time.time - attackTimer > attackDelay)
            {
                currState     = BirdFlyingState.Diving;
                attackTimer   = Time.time; // time how long the bird is diving
                playerInRange = false;
                attackHive    = false;
            }
            else if (distToHive <= attackHiveDist && Time.time - attackTimer > attackDelay)
            {
                currState     = BirdFlyingState.Diving;
                attackTimer   = Time.time;
                playerInRange = false;
                attackHive    = true;
            }

            currAngle += circleSpeed * Time.deltaTime;
            currAngle %= 360;

            MoveInCircle(currAngle);
        }
Ejemplo n.º 3
0
        ///////////////////////////////////////////////
        //// Basic Movement States ////////////////////

        public override void UpdatePatrolState()
        {
            anim.SetInteger(AnimState, 0);

            if (Utils.Distance2D(transform.position, nextPoint) <= edgeOfCharacter ||
                (Time.time - patrolStuckTimer) > 10f)
            {
                patrolStuckTimer = Time.time;
                FindNextPoint();
            }

            if (distToPlayer <= minPlayerDistance)
            {
                RearviewCameraBehaviour.RequestRearviewOn();
                currState        = WaspFlyingState.Attacking;
                patrolStuckTimer = Time.time;
            }

            if (distToHive <= minHiveDistance)
            {
                if (Time.time - hiveAttackTimer >= hiveAttackCooldown)
                {
                    hiveAttackTimer = Time.time;
                    currState       = WaspFlyingState.Attacking;
                    attackHive      = true;
                }
                else
                {
                    // patrolStuckTimer = Time.time;
                    // FindNextPoint();
                }
            }

            Vector3 toTarget = nextPoint - transform.position;

            MoveInDir(toTarget, patrolSpeed);
            FaceTarget(nextPoint, false);

            Debug.DrawLine(transform.position, nextPoint, Color.cyan);
        }