コード例 #1
0
 void Start()
 {
     health = GameObject.Find("Health");
     health.SetActive(false);
     coins = GameObject.Find("Coins");
     coins.SetActive(false);
     text         = GameObject.Find("Title");
     mySongString = PlayerPrefs.GetString("song", "");
     if (PlayerPrefs.GetInt("playList", 0) == 1)
     {
         text.GetComponent <Text>().text = mySongString;
         Debug.Log(mySongString);
         GetComponent <Camera>().GetComponent <AudioSource>().clip = (AudioClip)Resources.Load(mySongString);
     }
     if (GetComponent <Camera>().GetComponent <AudioSource>().clip == null)
     {
         GetComponent <Camera>().GetComponent <AudioSource>().clip = (AudioClip)Resources.Load("Tobu - Such Fun");
     }
     home = GameObject.Find("Home");
     home.SetActive(false);
     menu   = GameObject.Find("Menu");
     slider = GameObject.Find("LoadingSlider");
     slider.SetActive(false);
     Track.sphereRed    = sphereRed;
     Track.sphereOrange = sphereOrange;
     Track.sphereYellow = sphereYellow;
     Track.sphereGreen  = sphereGreen;
     Track.sphereBlue   = sphereBlue;
     Track.spherePurple = spherePurple;
     Track.laser        = laser;
     Track.ring         = ring;
     reInstantiate      = false;
     foundTrue          = false;
     executed           = false;
     isAnalyzed         = false;
     audio    = GetComponent <Camera>().GetComponent <AudioSource>();
     analyzer = new MusicAnalyzer(GetComponent <Camera>().GetComponent <AudioSource>().clip, sampleSize, soundFeed, beatSubbands, beatSensitivity,
                                  thresholdSize, thresholdMultiplier);
 }
コード例 #2
0
        void Update()
        {
            time += Time.deltaTime;
            if (MusicHandler.startLoad)
            {
                if (GetComponent <AudioSource>().clip.isReadyToPlay&& !GetComponent <AudioSource>().isPlaying)
                {
                    foundTrue = true;
                }
                MusicHandler.startLoad = false;
            }

            if (isAnalyzed)
            {
                if (!executed)
                {
                    home.SetActive(true);
                    Player3D.readyB    = true;
                    Score.ready        = true;
                    LightChanger.ready = true;
                    changer.ready      = true;
                    Touch3D.ready      = true;
                    executed           = true;
                }
                if (!audio.isPlaying)
                {
                    audio.Play();
                }
                UpdateTarget();
                UpdatePlayer();
                playerZ += PlayerMovingEasing * (targetPlayerZ - playerZ);
                UpdateCamera();
                return;
            }
            if (foundTrue)
            {
                if (!reInstantiate)
                {
                    slider.SetActive(true);
                    analyzer = new MusicAnalyzer(GetComponent <Camera>().GetComponent <AudioSource>().clip, sampleSize, soundFeed, beatSubbands, beatSensitivity,
                                                 thresholdSize, thresholdMultiplier);
                    reInstantiate = true;
                }
                try{
                    if (analyzer.Analyze())
                    {
                        if (PlayerPrefs.GetInt("way", 0) == 0)
                        {
                            Screen.orientation = ScreenOrientation.Landscape;
                        }
                        else if (PlayerPrefs.GetInt("way", 0) == 1)
                        {
                            Screen.orientation = ScreenOrientation.Portrait;
                        }
                        Destroy(menu);
                        health.SetActive(true);
                        coins.SetActive(true);
                        Track track = new Track(trackWidth, trackHeight, trackDepth, Color.black, analyzer.Thresholds);
                        GetComponent <Camera>().transform.position = new Vector3(-trackWidth / 2, (float)(analyzer.Thresholds[0] * trackDepth + 100), 0);
                        player.transform.position = new Vector3(-trackWidth / 2, (float)(analyzer.Thresholds[0] * trackDepth + 100), 0);
                        isAnalyzed = true;
                    }
                } catch (NullReferenceException) {
                }
            }
        }