Inheritance: MonoBehaviour
        public void SequentialGetChildrenTest()
        {
            MusicObject[] testObjects = new MusicObject[5];
            testObjects[0] = new Keystroke(Tone.A, 2);
            testObjects[1] = new Pause(1);
            testObjects[2] = new Keystroke(Tone.B, 3);
            testObjects[3] = new Pause(1);
            testObjects[4] = new Keystroke(Tone.D, 5);
            List <SingleBeat> sSBList = new List <SingleBeat>();

            SequentialMusicList sTestList = new SequentialMusicList(testObjects);
            IOrchestra          testOrc   = Substitute.For <IOrchestra>();
            Instrument          i         = new Instrument(testOrc, InstrumentType.AcousticBass, new Scale());

            sSBList.AddRange(sTestList.GetChildren(i, 1));


            double testDouble = 0;

            foreach (SingleBeat sb in sSBList)
            {
                if (!(sb.ToneStartTime >= testDouble))
                {
                    Assert.Fail();
                }
                testDouble = sb.ToneStartTime;
            }
        }
        public void SequentialGetChildrenTest2()
        {
            MusicObject[] testObjects = new MusicObject[5];
            testObjects[0] = new Keystroke(Tone.A, 2);
            testObjects[1] = new Pause(1);
            testObjects[2] = new ChordVariety(1, 4, 7).WithBaseTone(Tone.E, 2);
            testObjects[3] = new Pause(1);
            testObjects[4] = new Keystroke(Tone.D, 2);
            List <SingleBeat> sSBList = new List <SingleBeat>();

            SequentialMusicList sTestList = new SequentialMusicList(testObjects);
            IOrchestra          testOrc   = Substitute.For <IOrchestra>();
            Instrument          i         = new Instrument(testOrc, InstrumentType.AcousticBass, new Scale());

            sSBList.AddRange(sTestList.GetChildren(i, 1));

            int    testInt    = 0;
            double testDouble = 0;

            foreach (SingleBeat sb in sSBList)
            {
                if ((sb.ToneStartTime > testDouble))
                {
                    testInt++;
                }
                testDouble = sb.ToneStartTime;
            }

            Assert.IsTrue(testInt == 3);
        }
    static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths)
    {
        foreach (string asset in importedAssets)
        {
            if (!filePath.Equals(asset))
            {
                continue;
            }

            MusicObject data = (MusicObject)AssetDatabase.LoadAssetAtPath(assetFilePath, typeof(MusicObject));
            if (data == null)
            {
                data               = ScriptableObject.CreateInstance <MusicObject> ();
                data.sheetName     = filePath;
                data.worksheetName = sheetName;
                AssetDatabase.CreateAsset((ScriptableObject)data, assetFilePath);
                //data.hideFlags = HideFlags.NotEditable;
            }

            //data.dataArray = new ExcelQuery(filePath, sheetName).Deserialize<MusicObjectData>().ToArray();

            //ScriptableObject obj = AssetDatabase.LoadAssetAtPath (assetFilePath, typeof(ScriptableObject)) as ScriptableObject;
            //EditorUtility.SetDirty (obj);

            ExcelQuery query = new ExcelQuery(filePath, sheetName);
            if (query != null && query.IsValid())
            {
                data.dataArray = query.Deserialize <MusicObjectData>().ToArray();

                ScriptableObject obj = AssetDatabase.LoadAssetAtPath(assetFilePath, typeof(ScriptableObject)) as ScriptableObject;
                EditorUtility.SetDirty(obj);
            }
        }
    }
        public void ParallelGetChildrenTest()
        {
            MusicObject[] testObjects = new MusicObject[5];
            testObjects[0] = new Keystroke(Tone.A, 2);
            testObjects[1] = new Pause(1);
            testObjects[2] = new Keystroke(Tone.B, 3);
            testObjects[3] = new Pause(1);
            testObjects[4] = new Keystroke(Tone.D, 5);
            List <SingleBeat> sTestList = new List <SingleBeat>();

            ParallelMusicCollection sTestCollection = new ParallelMusicCollection(testObjects);
            IOrchestra testOrc = Substitute.For <IOrchestra>();
            Instrument i       = new Instrument(testOrc, InstrumentType.AcousticBass, new Scale());

            sTestList.AddRange(sTestCollection.GetChildren(i, 1));


            double testDouble = 1;

            foreach (SingleBeat sb in sTestList)
            {
                if (sb.ToneStartTime != testDouble && (sb.ToneVelocity != 0xff && sb.Tone != 0xff))
                {
                    Assert.Fail();
                }
            }
        }
    public void PlayMusicPrevious()
    {
        if (curMusicIndex <= 0)
        {
            musicObjectList [curMusicIndex + 1].StopMusic();
            Debug.LogWarning("Trying to play invalid sound in array, replay tracks");
            curMusicIndex = musicObjectList.Count - 1;

            if (isMusicOn)
            {
                musicObjectList [0].StopMusic();
                musicObjectList [curMusicIndex].source.Play();
            }
            return;
        }

        curMusicIndex--;

        if (isMusicOn)
        {
            musicObjectList [curMusicIndex + 1].StopMusic();
            tempMusicObj = musicObjectList [curMusicIndex];
            tempMusicObj.PlayMusic();
        }
    }
    // Update is called once per frame
    void Update()
    {
        if (FindingMatch)
        {
            fakeMatchmakingCount++;

            if (MusicObject)
            {
                if (MusicObject.GetComponent <AudioSource>().volume > 0)
                {
                    MusicObject.GetComponent <AudioSource>().volume -= 0.001f;
                }
            }
        }

        if (FoundMatch)
        {
            HeadingText.GetComponent <TextMeshProUGUI>().text = "Match Found, Prepare for Battle";
        }

        if (FoundMatch && fakeMatchmakingCount > 1150)
        {
            FadeoutPaneltoGame.SetActive(true);
        }
    }
 public void CancelMatchmaking()
 {
     QuickPlayButton.SetActive(true);
     ProfileButton.SetActive(true);
     BackButton.SetActive(true);
     HeadingText.GetComponent <TextMeshProUGUI>().text = "Choose Operation";
     FindingMatch = false;
     MusicObject.GetComponent <AudioSource>().volume = 1.0f;
 }
Exemplo n.º 8
0
 /// <summary>
 /// 分享音乐
 /// </summary>
 /// <param name="musicObject">音乐信息</param>
 /// <param name="thumbnail">缩略图</param>
 /// <param name="url">点击链接 URI</param>
 /// <param name="title">标题</param>
 /// <param name="description">描述</param>
 /// <returns>是否发送成功,不等于分享成功</returns>
 public bool ShareMusic(MusicObject musicObject, Bitmap thumbnail = null, string url = null, string title = null, string description = null)
 {
     if (thumbnail != null)
     {
         musicObject.SetThumbImage(thumbnail);
     }
     set(musicObject, url, title, description);
     return(Share(musicObject));
 }
Exemplo n.º 9
0
 /// <summary>
 /// Recursively links children of the specified Music Object.
 /// </summary>
 /// <param name="o">The Music Object to link children for.</param>
 private void LinkChildren(MusicObject o)
 {
     if (_subtrees.Contains(o.Id))
     {
         foreach (var child in _subtrees[o.Id])
         {
             child.SetParent(o);
             LinkChildren(child);
         }
     }
 }
Exemplo n.º 10
0
 private void Awake()
 {
     if (_instance != null && _instance != this)
     {
         Destroy(this.gameObject);
     }
     else
     {
         _instance = this;
         DontDestroyOnLoad(this.gameObject);
     }
 }
        public void SequentialMusicCollectionTest()
        {
            MusicObject[] testObjects = new MusicObject[5];
            testObjects[0] = new Keystroke(Tone.A, 2);
            testObjects[1] = new Keystroke(Tone.C, 4);
            testObjects[2] = new Keystroke(Tone.B, 3);
            testObjects[3] = new Keystroke(Tone.E, 1);
            testObjects[4] = new Keystroke(Tone.D, 5);

            SequentialMusicList sTest = new SequentialMusicList(testObjects);

            Assert.IsTrue(sTest.Contains(testObjects[0]) && sTest.Contains(testObjects[1]) && sTest.Contains(testObjects[2]) && sTest.Contains(testObjects[3]) && sTest.Contains(testObjects[4]));
        }
        public void ParallelMusicCollectionTest()
        {
            MusicObject[] testObjects = new MusicObject[5];
            testObjects[0] = new Keystroke(Tone.A, 2);
            testObjects[1] = new Keystroke(Tone.C, 4);
            testObjects[2] = new Keystroke(Tone.B, 3);
            testObjects[3] = new Keystroke(Tone.E, 1);
            testObjects[4] = new Keystroke(Tone.D, 5);

            ParallelMusicCollection pM = new ParallelMusicCollection(testObjects);

            Assert.IsTrue(pM.Contains(testObjects[0]) && pM.Contains(testObjects[1]) && pM.Contains(testObjects[2]) && pM.Contains(testObjects[3]) && pM.Contains(testObjects[4]));
        }
    void Start()
    {
        musicObjectList = new List <MusicObject>();

        foreach (AudioClip theMusic in musicList)
        {
            tempMusicObj = new MusicObject(theMusic, theMusic.name, volume);
            musicObjectList.Add(tempMusicObj);


            totalMusic++;
        }
    }
Exemplo n.º 14
0
 /// <summary>
 /// Serializes the specified object and its children.
 /// </summary>
 /// <param name="sb">The result <see cref="StringBuilder"/>.</param>
 /// <param name="depth">The indentation level.</param>
 /// <param name="o">The object to serialize.</param>
 private static void SerializeActor(StringBuilder sb, int depth, MusicObject o)
 {
     // Serialize current object
     sb.AppendLine(o.Serialize().IndentLines(depth));
     if (o.ChildCount > 0)
     {
         foreach (var child in o.Children)
         {
             // Serialize every child recursively
             SerializeActor(sb, depth + 4, child);
         }
     }
 }
Exemplo n.º 15
0
    // Called once at the start of the scene
    void Awake()
    {
        if (instance != null && instance != this)
        {
            Destroy(this.gameObject);
            return;
        }
        else
        {
            instance = this;

            // Get a reference to the Audio Source component
            audioSource = GetComponent <AudioSource>();
        }
        // Keep this object from being destroyed
        DontDestroyOnLoad(this.gameObject);
    }
Exemplo n.º 16
0
    public void NewMusic(AudioClip clip)
    {
        if (currentClip != null && currentClip == clip)
        {
            return;
        }

        for (int i = 0; i < musicObjects.Count; i++)
        {
            musicObjects[i].StartFadeOut();
        }


        GameObject obj = new GameObject();

        MusicObject temp = obj.AddComponent <MusicObject>();

        temp.StartFadeIn(clip);
        musicObjects.Add(temp);
    }
Exemplo n.º 17
0
        void wc_DownloadStringCompleted(object sender, System.Net.DownloadStringCompletedEventArgs e)
        {
            if (e.Error != null)
            {
                return;
            }
            var type = JObject.Parse(e.Result).SelectToken("type").ToString();
            var id   = JObject.Parse(e.Result).SelectToken("id").ToString();

            postAnswer.Add("access_token", App.AccessToken);
            postAnswer.Add("id", id);
            switch (type)
            {
            case "hometown":
                hometown = JsonConvert.DeserializeObject <HometownObject>(e.Result);
                setHometown();
                break;

            case "music":
                music = JsonConvert.DeserializeObject <MusicObject>(e.Result);
                setMusic();
                break;

            case "book":
                book = JsonConvert.DeserializeObject <BookObject>(e.Result);
                setBook();
                break;

            case "movie":
                movie = JsonConvert.DeserializeObject <MovieObject>(e.Result);
                setMovie();
                break;

            case "photo":
                photo = JsonConvert.DeserializeObject <PhotoObject>(e.Result);
                setPhoto();
                break;
            }
        }
    public void PlayMusicNext()
    {
        if (curMusicIndex >= musicObjectList.Count - 1)
        {
            musicObjectList [musicObjectList.Count - 1].StopMusic();
            Debug.LogWarning("Trying to play invalid sound in array, replay tracks");
            curMusicIndex = 0;

            if (isMusicOn)
            {
                musicObjectList [curMusicIndex].source.Play();
            }
            return;
        }

        curMusicIndex++;

        if (isMusicOn)
        {
            musicObjectList [curMusicIndex - 1].StopMusic();
            tempMusicObj = musicObjectList [curMusicIndex];
            tempMusicObj.PlayMusic();
        }
    }
Exemplo n.º 19
0
        static void Main(string[] args)
        {
            #region Orchestra
            const int midiDeviceId   = 0;           //Most computers will only have this one.
            const int beatsPerSecond = 60;          //Tempo of the music. 60 beats per second 1 one beat equals 1 second.
            IMidiOut  output         = new WinmmOut(midiDeviceId, beatsPerSecond);
            Orchestra orchestra      = new Orchestra(output);

            Instrument piano = orchestra.AddInstrument(InstrumentType.BrightAcousticPiano);
            #endregion

            #region SingleSound

            //Play a single sound
            piano.Play(Tone.C, 1);
            orchestra.WaitForFinished();

            #endregion

            #region MusicObjects
            MusicObject longF  = new Note(Tone.F, 1);
            MusicObject shortF = new Note(Tone.F, 0.5);
            MusicObject longA  = new Note(Tone.A, 1);
            MusicObject shortA = new Note(Tone.A, 0.5);
            MusicObject longG  = new Note(Tone.G, 1);
            MusicObject shortG = new Note(Tone.G, 0.5);


            Console.WriteLine("Press enter to play a single sound");
            Console.ReadLine();
            //We can play any of those on an instrument if we wish
            piano.Play(shortG);
            orchestra.WaitForFinished();

            #endregion

            #region LargeMusicObject

            //Create 2 smaller MusicObjects made out of the base pieces
            MusicObject sequence1 = new SequentialMusicList(longF, shortA, longG, shortA);
            MusicObject sequence2 = new SequentialMusicList(shortA, shortA, shortA, longA, shortF);

            //Now create a bigger MusicObject made of those 2 smaller ones and one new
            SequentialMusicList bigMusicObject = new SequentialMusicList(sequence1, sequence1, sequence2, new Note(Tone.D, 2));

            //We can play this too
            //We can play any of those on an instrument if we wish
            Console.WriteLine("Press enter to play a longer sequence of sound");
            Console.ReadLine();
            piano.Play(bigMusicObject);
            orchestra.WaitForFinished();

            #endregion

            #region Transformation
            //Make the 1st object a little lower on the scale, using a transform
            int[] offsets = { 0, -3, -3, -2 };
            bigMusicObject[1] = bigMusicObject[1].Select <Note>((x, y) => x.OffsetBy(Scale.MajorScale, offsets[y]));

            //Play our final piece.
            Console.WriteLine("Press enter to play \"Drømte mig en drøm i nat\", ");
            Console.ReadLine();
            piano.Play(bigMusicObject);
            orchestra.WaitForFinished();

            //You have just heard https://en.wikipedia.org/wiki/Dr%C3%B8mde_mik_en_dr%C3%B8m_i_nat
            #endregion

            #region OtherInstrument
            //Create a flute
            Instrument flute = orchestra.AddInstrument(InstrumentType.Flute);



            Console.WriteLine("Press enter to play \"Drømte mig en drøm i nat\" on a flute");
            Console.ReadLine();
            flute.Play(bigMusicObject);
            orchestra.WaitForFinished();
            #endregion

            #region TransformToChords
            //Using Select<>() it's also possible to change the type of a MusicObject.
            ChordVariety minor    = ChordVariety.Minor;
            MusicObject  asChords = bigMusicObject.Select <Note>(n => minor.WithBaseTone(n.Keystroke.Tone, n.Pause.Duration));

            Console.WriteLine("Press enter to play \"Drømte mig en drøm i nat\" as minor.");
            Console.ReadLine();

            piano.Play(asChords);

            orchestra.WaitForFinished();
            #endregion
        }
Exemplo n.º 20
0
        static void Main()
        {
            int bpm = 30; //Tempo of the music. Beats per minute.

            //Like most old western music, this is played in the A minor scale.
            //Note that as the tone enum starts at C, tones A and B are part of the lower octave.
            Tone[] majorScaleTones = { Tone.A - 12, Tone.B - 12, Tone.C, Tone.D, Tone.E, Tone.F, Tone.G };
            Scale  majorScale      = new Scale(majorScaleTones);
            //The left hand is lowered by 1 octave.
            Scale loweredMajorScale = new Scale(majorScaleTones.Select(x => x - 12).ToArray());

            //We will be using these constants a lot.
            double eigth        = 1 / 8.0;
            byte   baseVelocity = 50;

            //To play music, first we need an orchestra with access to an output.
            Orchestra o = new Orchestra(new WinmmOut(0, bpm));
            //The piece should be played on a grand piano. Let's just get one.
            Instrument piano = o.AddInstrument(InstrumentType.AccousticGrandPiano, majorScale, 0);

            //----------------------------
            //   Creating the right hand:
            //----------------------------

            //The treble clef shows the position of the G
            //(which has index 6 in majorScale)
            // so by counting a note's offset from the G
            // and adding the value corresponding to G in the scale
            // you get the tone you want.
            int trebleClef = majorScale.Interval(Tone.G);

            //Making all six bars:

            MusicObject rBar0 = //It seems, the first bar is only two eigths long.
                                //The two notes have the same duration and velocity, so we are using a helper class.(The zero means the sustain pedal is not used.)
                                SimilarNotes(eigth, baseVelocity, 0,
                                             majorScale[5 + trebleClef],
                                             majorScale[4 + trebleClef] + 1); //The ♯ elevates all tones on the line with 1 until cancelled by a ♮ or the bar ends.

            MusicObject rBar1And5 =
                SimilarNotes(eigth, baseVelocity, 0,
                             majorScale[5 + trebleClef],
                             majorScale[4 + trebleClef] + 1,
                             majorScale[5 + trebleClef],
                             majorScale[2 + trebleClef],
                             majorScale[4 + trebleClef],
                             majorScale[3 + trebleClef]);

            MusicObject rBar2 = new SequentialMusicList
                                (
                new Note(majorScale[1 + trebleClef], eigth * 2, baseVelocity),
                new Pause(eigth),
                SimilarNotes(eigth, baseVelocity, 0,
                             majorScale[-4 + trebleClef],
                             majorScale[-2 + trebleClef],
                             majorScale[1 + trebleClef])
                                );

            MusicObject rBar3 = new SequentialMusicList
                                (
                new Note(majorScale[2 + trebleClef], eigth * 2, baseVelocity),
                new Pause(eigth),
                SimilarNotes(eigth, baseVelocity, 0,
                             majorScale[-2 + trebleClef],
                             majorScale[0 + trebleClef] + 1,
                             majorScale[2 + trebleClef])
                                );

            MusicObject rBar4 = new SequentialMusicList
                                (
                new Note(majorScale[3 + trebleClef], eigth * 2, baseVelocity),
                new Pause(eigth),
                SimilarNotes(eigth, baseVelocity, 0,
                             majorScale[-2 + trebleClef],
                             majorScale[5 + trebleClef],
                             majorScale[4 + trebleClef] + 1)
                                );

            //rBar5 is already accounted for

            //The whole right hand.
            MusicObject rightHand = new SequentialMusicList(rBar0, rBar1And5, rBar2, rBar3, rBar4, rBar1And5);

            //----------------------------
            //   Creating the left hand:
            //----------------------------

            //The bass clef shows the position of the F
            //(which has index 5 in majorScale)
            // so by counting a note's offset from the F
            // and adding the value corresponding to F in the scale
            // you get the tone you want.
            int bassClef = loweredMajorScale.Interval(Tone.F);

            //Making all six bars:

            MusicObject lBar0 = new Pause(eigth * 2);

            MusicObject lBar1And5 = new Pause(eigth * 6);

            MusicObject lBar2And4 = new SequentialMusicList
                                    (
                SimilarNotes(eigth, baseVelocity, 6,    //These notes should be sustained for the rest of the bar.
                             loweredMajorScale[-5 + bassClef],
                             loweredMajorScale[-1 + bassClef],
                             loweredMajorScale[2 + bassClef]),
                new Pause(eigth),
                new Pause(eigth * 2)
                                    );

            MusicObject lBar3 = new SequentialMusicList
                                (
                SimilarNotes(eigth, baseVelocity, 6,    //These notes should be sustained for the rest of the bar.
                             loweredMajorScale[-8 + bassClef],
                             loweredMajorScale[-1 + bassClef],
                             loweredMajorScale[1 + bassClef] + 1),
                new Pause(eigth),
                new Pause(eigth * 2)
                                );


            //lBar4 is already accounted for.

            //lBar5 is already accounted for.

            //The whole left hand.
            MusicObject leftHand = new SequentialMusicList(lBar0, lBar1And5, lBar2And4, lBar3, lBar2And4, lBar1And5);

            //----------------------------
            //   Ready to play:
            //----------------------------

            //The two hands should start playing at the same time:
            ParallelMusicCollection FurEliseIntro = new ParallelMusicCollection(leftHand, rightHand);

            //And then we just start it.
            piano.Play(FurEliseIntro);

            o.WaitForFinished();
            Console.ReadLine();
        }
Exemplo n.º 21
0
    public void UpdateLevelEnd(GameManager gm)
    {
        gameManager = gm;
        audioObject = GameObject.Find("LevelMapMusic").GetComponent <MusicObject>();
        moneyText   = GameObject.Find("TextMoney").GetComponent <MoneyUIUpdate>();

        star1Text      = star1.GetComponentInChildren <Text>();
        star2Text      = star2.GetComponentInChildren <Text>();
        star3Text      = star3.GetComponentInChildren <Text>();
        targetTime     = GameObject.Find("TargetTime").GetComponent <Text>();
        playerTime     = GameObject.Find("YourTime").GetComponent <Text>();
        bonusObjective = GameObject.Find("BonusObjective").GetComponent <Text>();
        personalBest   = GameObject.Find("PersonalBest").GetComponent <Image>();
        personalBest.gameObject.SetActive(false);

        CreateFaceDictionary();

        levelEnd = gameManager.levelEnd;
        if (levelEnd == null)
        {
            Debug.LogError("Level end is null");
        }
        level = levelEnd.level;

        if (level == null)
        {
            Debug.LogError("Level end is null");
        }

        starsEarned = 0;

        alsFace.sprite = endFaces[levelEnd.endCondition];

        if (levelEnd.obj1Passed)
        {
            starsEarned++;
        }
        if (levelEnd.obj2Passed)
        {
            starsEarned++;
        }
        if (levelEnd.obj3Passed)
        {
            starsEarned++;
        }

        //Save the amount of stars and rubies the player has earned from all levels
        int playerStars = PlayerPrefs.GetInt(SaveStrings.sPlayerStars, 0);

        moneyText.setOldMoney(gameManager.wallet.Coins);
        moneyText.setLevelEnd(true);

        string levelNumber = "";

        switch (level.setName)
        {
        case "Tutorial0":
            levelNumber = "0-1";
            break;

        case "Tutorial1":
            levelNumber = "0-2";
            break;

        case "Tutorial2":
            levelNumber = "0-3";
            break;

        case "Cat":
            levelNumber = "1-";
            levelNumber = levelNumber + (level.id + 1).ToString();
            break;

        case "Crate":
            levelNumber = "2-";
            levelNumber = levelNumber + (level.id + 1).ToString();
            break;

        case "Swim":
            levelNumber = "3-";
            levelNumber = levelNumber + (level.id + 1).ToString();
            break;

        case "fisherman":
            levelNumber = "4-";
            levelNumber = levelNumber + (level.id + 1).ToString();
            break;

        case "iceberg":
            levelNumber = "5-";
            levelNumber = levelNumber + (level.id + 1).ToString();
            break;

        case "Mountain":
            levelNumber = "6-";
            levelNumber = levelNumber + (level.id + 1).ToString();
            break;
        }

        clearText.text = "Level " + levelNumber + (levelEnd.passedLevel ? " cleared" : " failed");

        if (level.star1 == false && levelEnd.obj1Passed == true)
        {
            gameManager.wallet.AddMoney(10 + 10 * level.id);
            StartCoroutine(CoinFlow(10 + 10 * level.id, GameObject.Find("Star1")));
            playerStars++;
        }
        if (level.star2 == false && levelEnd.obj2Passed == true)
        {
            gameManager.wallet.AddMoney(10 + 10 * level.id);
            StartCoroutine(CoinFlow(10 + 10 * level.id, GameObject.Find("Star2")));
            playerStars++;
        }
        if (level.star3 == false && levelEnd.obj3Passed == true)
        {
            gameManager.wallet.AddMoney(10 + 10 * level.id);
            StartCoroutine(CoinFlow(10 + 10 * level.id, GameObject.Find("Star3")));
            playerStars++;
        }

        PlayerPrefs.SetInt(SaveStrings.sPlayerStars, playerStars);

        if (level.rubyFound == false && levelEnd.rubyFound == true)
        {
            int rubies = PlayerPrefs.GetInt(SaveStrings.sPlayerRubies) + 1;
            PlayerPrefs.SetInt(SaveStrings.sPlayerRubies, rubies);
        }

        star1Text.text      = levelEnd.itemsSaved.ToString() + "/" + levelEnd.maxItems.ToString();
        star2Text.text      = levelEnd.obj2Passed || level.star2 ? "Bonus" : "Bonus";
        bonusObjective.text = "Bonus: " + LevelHandler.GetLevelSet(level.setName).challenge2;

        float timeDifference = (level.bestTime < level.levelTimeChallenge && level.star3) ? (levelEnd.levelTime - level.bestTime) : (levelEnd.levelTime - level.levelTimeChallenge);

        star3Text.text = (timeDifference.CompareTo(0f) >= 0 ? "+ " : "- ") + (Mathf.Abs(timeDifference / 60f) >= 1f ? Mathf.Floor(Mathf.Abs(timeDifference / 60f)).ToString("##:") : "") + Mathf.Abs(timeDifference % 60f).ToString("00.00");

        playerTime.text = levelEnd.passedLevel ? ("Time: " + (levelEnd.levelTime / 60f >= 1f ? Mathf.Floor(levelEnd.levelTime / 60f).ToString("##:") : "") + (levelEnd.levelTime % 60f).ToString("00.00")) : "Time: 0.00";

        if (!level.star3)
        {
            targetTime.text = "Target: " + (level.levelTimeChallenge / 60f >= 1f ? Mathf.Floor(level.levelTimeChallenge / 60f).ToString("##:"): "") + (level.levelTimeChallenge % 60f).ToString("00.00");
            if (levelEnd.levelTime < level.levelTimeChallenge && levelEnd.passedLevel)
            {
                level.bestTime = levelEnd.levelTime;
                //personalBest.gameObject.SetActive(true);
                //PlayerPrefs.SetFloat(level.name + "BestTime", level.bestTime);
            }
            else
            {
                level.bestTime = 999f;
            }
        }
        else
        {
            targetTime.text = "Best: " + (level.bestTime / 60f >= 1f ? Mathf.Floor(level.bestTime / 60f).ToString("##:") : "") + (level.bestTime % 60f).ToString("00.00");
            if (levelEnd.levelTime < level.bestTime && levelEnd.passedLevel)
            {
                level.bestTime = levelEnd.levelTime;
                //personalBest.gameObject.SetActive(true);
                //PlayerPrefs.SetFloat(level.name + "BestTime", level.bestTime);
            }
        }

        // Musiikin määritys
        if (levelEnd.passedLevel)
        {
            if (levelEnd.obj1Passed && levelEnd.obj2Passed && levelEnd.obj3Passed)
            {
                audioObject.clips = threeStarMusic;
            }
            else if (levelEnd.obj1Passed || levelEnd.obj2Passed || levelEnd.obj3Passed)
            {
                audioObject.clips = threeStarMusic;
            }
        }
        else
        {
            audioObject.clips = loseMusic;
        }
        audioObject.PlayMusic();

        level.rubyFound = levelEnd.rubyFound || level.rubyFound;
        level.star1     = levelEnd.obj1Passed || level.star1;
        level.star2     = levelEnd.obj2Passed || level.star2;
        level.star3     = levelEnd.obj3Passed || level.star3;

        // Grafiikoiden määritys
        if (levelEnd.passedLevel == true)
        {
            PassedLevel();
            Level.Save(level);
        }
        else
        {
            FailedLevel();
            Level.Save(level);
        }

        if (levelEnd.rubyFound == true)
        {
            rubyImage.sprite = levelEnd.sapphireFound ? unlockedSapphire : unlockedRuby;
        }
        else
        {
            rubyImage.enabled = false;
        }

        //debugTime.text = "Time spent: " + levelEnd.levelTime;

        //StartCoroutine(Animations(levelEnd.rubyFound));
    }
Exemplo n.º 22
0
 public void RemoveMusic(MusicObject o)
 {
     musicObjects.Remove(o);
 }
Exemplo n.º 23
0
 public static void f_InitPool()
 {
     MusicObjectDT = UnityEngine.Resources.Load <MusicObject>("ExcelData/MusicObject");
     SpawnListDT   = UnityEngine.Resources.Load <SpawnList>("ExcelData/SpawnList");
 }