Exemplo n.º 1
0
    void Start()
    {
        if (GameGlobals.GlobalInstance != null)
        {
            GameGlobals temp = GameGlobals.GlobalInstance;
            isTextActive           = temp.isTextActive;
            TimeOnScreen           = temp.TimeOnScreen;
            NotesRange             = temp.NotesRange;
            BPM                    = temp.BPM;
            TransitionGracePeriod  = temp.TransitionGracePeriod;
            SustainedGracePeriod   = temp.SustainedGracePeriod;
            LeniencyRange          = temp.LeniencyRange;
            SongMode               = temp.SongMode;
            filename               = temp.selectedSong;
            speedMult              = temp.speedMult;
            scrollingInterpolation = temp.scrollingInterpolation;
            MaxTimeBetweenRests    = temp.MaxTimeBetweenRests;
            WritingOn              = temp.WritingOn;
            bassClefMode           = temp.bassClefMode;
            infiniteNoteDensity    = temp.NoteDensity;
            plrRed                 = temp.plrRed;
            plrGrn                 = temp.plrGrn;
            plrBlu                 = temp.plrBlu;
            volumeThreshold        = temp.volumeThreshold;
        }

        pt = GameObject.Find("Pitch Tester").GetComponent <PitchTester>();
        pt.volThreshold = volumeThreshold;
        audioPlayer     = GetComponent <AudioCuePlayer>();
        background      = GameObject.Find("Background");
        FillNotesAllowed();
        fg            = new FrequencyGuide();
        deathParticle = GameObject.Instantiate(deathParticlePrefab).GetComponent <ParticleSystem>();


        if (infiniteNoteDensity <= 1)
        {
            minNoteDuration = 2;
            maxNoteDuration = 4;
        }
        else if (infiniteNoteDensity == 2)
        {
            minNoteDuration = 1;
            maxNoteDuration = 3;
        }
        else if (infiniteNoteDensity == 3)
        {
            minNoteDuration = 1 / 8;
            maxNoteDuration = 2;
        }
        // If we're in Song mode, read in file information
        if (SongMode)
        {
            ReaderWriter.ReadSong(ref Song, filename, ref BPM, ref bassClefMode);
        }

        // Initialize tables
        if (bassClefMode)
        {
            BassClefTransformation();
        }
        fillGapsInPosColorLookup();
        fillNoteColorLookup();

        // Calculate conversion factors
        float screenWidthInWorldUnits = Camera.main.ScreenToWorldPoint(new Vector3(Camera.main.pixelWidth, 0, 10)).x
                                        - Camera.main.ScreenToWorldPoint(new Vector3(0, 0, 10)).x;

        worldUnitsPerSec  = screenWidthInWorldUnits / TimeOnScreen;
        worldUnitsPerBeat = worldUnitsPerSec * 60 / BPM;
        spawnPosOffset    = screenWidthInWorldUnits;

        // Add terminating rest to song mode
        if (SongMode)
        {
            for (int i = 1; i < Song.Count; i++)
            {
                if (Song[i].name == "REST")
                {
                    Song[i].yOffset = Song[i - 1].yOffset;
                }
                else
                {
                    Song[i].yOffset = notePosLookup[Song[i].name];
                }
            }

            Song.Add(new Note("REST", screenWidthInWorldUnits));
            Song[Song.Count - 1].yOffset = Song[Song.Count - 2].yOffset;
        }

        Player.GetComponent <SpriteRenderer>().color = new Color(plrRed, plrGrn, plrBlu, 1f);
        Bud.SetParticleBPM(BPM);

        if (warmupMode)
        {
            StartWarmup();
        }
        else
        {
            StartLevel();
        }
    }