Example #1
0
    void Update()
    {
        if (ingame_)
        {
            // Move plane
            moveHorizontal = Input.GetAxis("Horizontal");
            moveVertical   = Input.GetAxis("Vertical");
            Vector3 movement = new Vector3(moveHorizontal * sensitivity, 0.0f, 0.0f);
            // Boost the plane
            if (kAudioIn.GetInputVolume(AudioInputAdapter.GetDevice()) >= threshold)
            {
                time_stamp_ = Time.time;
                inBoostMode = true;
            }
            if (Time.time - time_stamp_ > boostDuration && inBoostMode)
            {
                inBoostMode = false;
            }
            if (inBoostMode)
            {
                movement.z += kBack.GetRollingSpeed() * maxspeed;
            }
            else
            {
                movement.z += kBack.GetRollingSpeed() - 0.05f;
            }
            //movement.x += Random.Range(-0.01f * GameController.birdHitCounter, 0.01f * GameController.birdHitCounter);
            //movement.z += Random.Range(-0.01f * GameController.birdHitCounter, 0.01f * GameController.birdHitCounter);

            MoveTarget(movement);

            // Wobble plane unless middle connection exists
            if (!Input.GetKey(KeyCode.F) && moveHorizontal == 0)
            {
                //Plane fall
                if (Time.time - crash_ > crashthreshold)
                {
                    player_.useGravity = true;
                    kSound.fallingSound();
                    ingame_ = false;
                    StartCoroutine(PlaneDestruct());
                }
                Vector3 randmove = new Vector3(Random.Range(-0.1f * (Time.time - crash_), 0.1f * (Time.time - crash_)), 0, 0);
                MoveTarget(randmove);
            }
            else
            {
                crash_ = Time.time;
            }

            //Plane fall
            if (GameController.birdHitCounter >= GameController.planeLife)
            {
                player_.useGravity = true;
                kSound.fallingSound();
                ingame_ = false;
                StartCoroutine(PlaneDestruct());
            }
        }
    }
Example #2
0
    void Update()
    {
        // rig.position += new Vector3(0, 0, -3 * back.GetRollingSpeed());

        if (Vector3.Distance(gameObject.transform.position, airplane_.transform.position) < birdPanicThreshold &&
            sound_manager_ != null &&
            airplane_.transform.position.z + 1 <= transform.position.z)
        {
            sound_manager_.playBirdTenseSound();
            // Trigger animation
            anim_.SetBool(hash_frenzy_, true);
            sound_manager_ = null;
            qtarget_       = Quaternion.LookRotation(gameObject.transform.position - airplane_.transform.position).eulerAngles;
            //transform.GetChild(0).localRotation = Quaternion.Euler(45f, 0f, 0f);
        }
        else
        {
            anim_.SetBool(hash_frenzy_, false);
            rig_.velocity = transform.forward * (speed + 500 * speed * kBack.GetRollingSpeed());
        }
        transform.rotation = Quaternion.Euler(Vector3.SmoothDamp(transform.rotation.eulerAngles, qtarget_, ref current_angular_, 1.0f));
    }
Example #3
0
 // Update is called once per frame
 void FixedUpdate()
 {
     trot = 150 - Mathf.Clamp(kBack.GetRollingSpeed() * 50000, 0, 150);
     rot  = Mathf.SmoothDamp(rot, trot, ref current, 1.0f);
     transform.localRotation = Quaternion.Euler(new Vector3(0, rot, 0));
 }