Example #1
0
        private void Update()
        {
            switch (state)
            {
            case State.Normal:
                enemyTarget = enemyMain.EnemyTargeting.GetActiveTarget();
                if (enemyTarget != null)
                {
                    state        = State.AimingAtTarget;
                    bulletsFired = 0;
                    aimingShoot.StartAimingAtTarget(enemyTarget.GetPosition(), 20f, 0f, 10f, ShootTarget);
                }
                break;

            case State.AimingAtTarget:
                enemyTarget = enemyMain.EnemyTargeting.GetActiveTarget();
                if (enemyTarget != null)
                {
                    Vector3 targetPosition = enemyTarget.GetPosition();
                    aimAnims.SetAimTarget(targetPosition);
                    aimingShoot.UpdateAimShootAtTarget(targetPosition);
                }
                break;

            case State.Attacking:
                fireRate -= Time.deltaTime;
                if (fireRate <= 0f)
                {
                    TestContinueShooting();
                }
                break;

            case State.Busy:
                break;
            }
        }
        private void Update()
        {
            switch (state)
            {
            case State.Normal:
                enemyTarget = enemyMain.EnemyTargeting.GetActiveTarget();
                if (enemyTarget != null)
                {
                    state = State.AimingAtTarget;
                    aimingShoot.StartAimingAtTarget(enemyTarget.GetPosition(), START_AIM_ANGLE, 0f, 10f, ShootTarget);

                    /*
                     * float attackRange = 50f;
                     * Vector3 targetPosition = enemyTarget.GetPosition();
                     * if (Vector3.Distance(GetPosition(), targetPosition) < attackRange) {
                     *  // Shoot Target
                     *  enemyMain.EnemyMovement.StopMoving();
                     *  characterBase.SetAimTarget(targetPosition);
                     *
                     *  if (Time.time >= nextShootTime) {
                     *      // Can shoot
                     *      nextShootTime = Time.time + FIRE_RATE;
                     *      targetPosition += UtilsClass.GetRandomDir() * UnityEngine.Random.Range(0f, 20f);
                     *      SetStateAttacking();
                     *      characterBase.ShootTarget(targetPosition, SetStateNormal);
                     *  }
                     * } else {
                     *  // Move to Target
                     *  enemyMain.EnemyMovement.SetTargetPosition(targetPosition);
                     *  characterBase.SetAimTarget(targetPosition);
                     * }
                     */
                }
                break;

            case State.AimingAtTarget:
                enemyTarget = enemyMain.EnemyTargeting.GetActiveTarget();
                if (enemyTarget != null)
                {
                    Vector3 targetPosition = enemyTarget.GetPosition();
                    aimAnims.SetAimTarget(targetPosition);
                    aimingShoot.UpdateAimShootAtTarget(targetPosition);

                    /*
                     * aimingShoot.AimAtPosition(targetPosition);
                     * aimAnims.SetAimTarget(targetPosition);
                     *
                     * float aimSpeed = 10f;
                     * aimingShoot.SetAimAngle(aimAngle - aimSpeed * Time.deltaTime);
                     *
                     * aimingShoot.SetAimColor(Mathf.Lerp(.0f, 1.1f, 1 - aimAngle / START_AIM_ANGLE));
                     *
                     * float shootAngle = 0f;
                     * if (aimAngle <= shootAngle) {
                     *  // Shoot!
                     *  SetStateAttacking();
                     *  aimAnims.ShootTarget(targetPosition, SetStateNormal);
                     *  aimingShoot.HideAim();
                     * }
                     */
                }
                break;

            case State.Attacking:
                break;

            case State.Busy:
                break;
            }
        }