예제 #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());
            }
        }
    }
예제 #2
0
 void Update()
 {
     if (buffer_.Count <= kSampleLength)
     {
         IsActive = false;
         StartCoroutine(BufferSetup());
     }
     if (IsActive)
     {
         StreamIn(kAudioIn.GetInputVolume(AudioInputAdapter.GetDevice()));
         if (!IsInput)
         {
             if (EdgeDetect() == Edge.kRising || Input.GetKey(KeyCode.P))
             {
                 riscount_++;
                 Debug.Log("Rising Count: " + riscount_);
                 if (riscount_ >= 3)
                 {
                     IsInput = true;
                     StopDetect();
                     kGameCtrl.OnGameStart();
                 }
             }
         }
     }
 }
예제 #3
0
    void Update()
    {
        tspeed_ = Mathf.Abs(kAudioIn.GetInputVolume(AudioInputAdapter.GetDevice()) * _scrollSpeed);
        if (!ingame_)
        {
            tspeed_ = 0;
        }
        speed_        = Mathf.SmoothDamp(speed_, tspeed_, ref current_acc_, 3.0f);
        actual_speed_ = Mathf.Clamp(speed_ * Time.deltaTime, 0f, 0.003f) + 0.0003f;
        if (!ingame_)
        {
            actual_speed_ -= 0.0003f;
        }
        saved_y_ += actual_speed_;
        if (saved_y_ >= 1)
        {
            loopcount++;
        }
        //plane.SetFloat(blend_hash_, actual_speed_ * 500);
        saved_y_  = Mathf.Repeat(saved_y_, 1f);
        loopcount = saved_y_ + Mathf.Floor(loopcount);
        Vector2 offset = new Vector2(saved_offset_.x, saved_y_);

        GetComponent <Renderer>().sharedMaterial.SetTextureOffset("_MainTex", offset);
    }
예제 #4
0
    IEnumerator BufferSetup()
    {
        while (buffer_.Count <= kSampleLength)
        {
            buffer_.Enqueue(kAudioIn.GetInputVolume(AudioInputAdapter.GetDevice()));
            yield return(null);

            IsActive = true;
        }
    }
예제 #5
0
 // Update is called once per frame
 void Update()
 {
     rot = Mathf.Clamp(kAudioIn.GetInputVolume(AudioInputAdapter.GetDevice()), 0, 5f);
     rot = 220 + rot * 28;
     transform.localRotation = Quaternion.Euler(new Vector3(0, rot, 0));
 }