Example #1
0
 public void SetTarget(Transform target)
 {
     player = target;
     RearviewCameraBehaviour.RequestRearviewOff();
     if (target.CompareTag("Player"))
     {
         RearviewCameraBehaviour.RequestRearviewOn();
     }
 }
Example #2
0
        // bird has been diving for set amount of time or hit the player
        private void ExitDive()
        {
            if (!attackHive)
            {
                RearviewCameraBehaviour.RequestRearviewOff();
            }

            attackDelay = Random.Range(attackDelayMin, attackDelayMax);

            // back to timing how long the player is in range
            attackTimer = Time.time;
            attackDelay = Random.Range(attackDelayMin, attackDelayMax);

            attackHive = false;
            currState  = BirdFlyingState.Returning;
        }
Example #3
0
        ///////////////////////////////////////////////
        //// Attacking State //////////////////////////

        private void UpdateAttackState()
        {
            if (attackHive)
            {
                Debug.DrawLine(transform.position, hive.transform.position, Color.green);
            }
            else
            {
                Debug.DrawLine(transform.position, player.transform.position, Color.blue);
            }

            bool attackingPlayer = !attackHive && (distToPlayer <= minPlayerDistance);
            bool attackingHive   = attackHive && (distToHive <= minHiveDistance);

            if (!attackingPlayer && !attackingHive ||
                (Time.time - patrolStuckTimer) > 10f)
            {
                RearviewCameraBehaviour.RequestRearviewOff(); // attacking is done
                currState        = WaspFlyingState.Patrolling;
                patrolStuckTimer = Time.time;
            }

            anim.SetInteger(AnimState, 1);

            Vector3   toTarget = (player.transform.position - transform.position);
            Transform lookAt   = null;

            if (attackingPlayer)
            {
                toTarget   = player.transform.position - transform.position;
                lookAt     = player.transform;
                attackHive = false;
            }
            else if (attackingHive)
            {
                toTarget   = hive.transform.position - transform.position;
                lookAt     = hive.transform;
                attackHive = true;
            }

            if (lookAt != null)
            {
                MoveInDir(toTarget, attackSpeed);
                transform.LookAt(lookAt);
            }
        }
Example #4
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);
        }
Example #5
0
        // This can be more fleshed out in future iterations of our game
        public void FinishSting(int score, int maxScore, GameObject target)
        {
            LevelManager   lm       = FindObjectOfType <LevelManager>();
            EnemyBehaviour targetEB = target.GetComponent <EnemyBehaviour>();

            if (targetEB == null)
            {
                targetEB = target.GetComponentInParent <EnemyBehaviour>();
            }

            stinging = false;
            // killing the wasps can definitely be improved upon
            if (score > maxScore * .9)
            {
                Debug.Log("Option1");
                lm.IncrementHealth(-minDamage);
                targetEB.EnemyDefeated();
            }
            else if (score > maxScore * .6)
            {
                Debug.Log("Option2");
                lm.IncrementHealth(-averageDamage);
                targetEB.EnemyDefeated();
            }
            else if (score > maxScore * .4)
            {
                Debug.Log("Option3");
                lm.IncrementHealth(-maxDamage);
                targetEB.EnemyDefeated();
            }
            else
            {
                Debug.Log("Option4");
                lm.IncrementHealth(-maxDamage);
            }

            stingIndicator.SetActive(false);
            RearviewCameraBehaviour.RequestRearviewOff();
            FindObjectOfType <PlayerControl>().StartBuzzSFX();
        }
Example #6
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);
        }
Example #7
0
 private void OnDestroy()
 {
     RearviewCameraBehaviour.RequestRearviewOff();
 }