Exemplo n.º 1
0
        protected override void Update()
        {
            base.Update();
            if (!LevelManager.gamePaused)
            {
                switch (currState)
                {
                case WaspFlyingState.Patrolling: UpdatePatrolState(); break;

                case WaspFlyingState.Attacking: UpdateAttackState(); break;

                case WaspFlyingState.Recoiling: UpdateRecoilState(); break;

                case WaspFlyingState.Dying: UpdateDieState(); break;
                }
            }

            if (enemyHealth <= 0)
            {
                currState = WaspFlyingState.Dying;
            }

            // Debug.DrawLine(transform.position, nextPoint, Color.blue);
            Vector3 target = transform.position + transform.forward.normalized * (edgeOfCharacter);

            Debug.DrawLine(transform.position, target, Color.red);
            Debug.DrawRay(transform.position, ctrl.velocity, Color.magenta);
        }
Exemplo n.º 2
0
        void FinishAttackRecoil()
        {
            currState        = attackHive ? WaspFlyingState.Patrolling : WaspFlyingState.Attacking;
            patrolStuckTimer = Time.time;

            currentRecoil = Vector3.zero;
            ctrl.Move(Vector3.zero);
        }
Exemplo n.º 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);
            }
        }
Exemplo n.º 4
0
        public override void ApplyDamage(float damage)
        {
            enemyHealth -= damage;

            currState   = WaspFlyingState.Recoiling;
            recoilTimer = Time.time;

            Vector3 dir = (transform.position - player.transform.position);

            if (attackHive)
            {
                dir = (transform.position - hive.transform.position);
            }
            dir.y         = 0;
            currentRecoil = dir.normalized * recoilImpactSpeed;

            ctrl.Move(currentRecoil * Time.deltaTime);
        }
Exemplo n.º 5
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);
        }
Exemplo n.º 6
0
 //Defeated/Dying
 public override void EnemyDefeated()
 {
     currState = WaspFlyingState.Dying;
     UpdateDieState();
 }