示例#1
0
 public void BackToMenu()
 {
     fadedImage.StartCoroutine(fadedImage.FadeImage(false, "Main Menu"));
     click.Play();
 }
示例#2
0
 public void BackToMenu()
 {
     fadedImage.StartCoroutine(fadedImage.FadeImage(false, "Song Selection"));
     click.Play();
 }
示例#3
0
    // Update is called once per frame
    void Update()
    {
        if (health > 100)
        {
            health = 100;
        }
        else if (health < 0 && relax)
        {
        }

        if (!hasStarted && !hasEnded)
        {
            hasStarted = true;
            StartCoroutine("Offset");
        }
        else if (!hasEnded)
        {
            hpbar.transform.localScale = new Vector3(health * 0.06f, 0.1f, 1);
            if (Input.GetKeyDown(restart))
            {
                SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
            }

            if (Input.GetKeyDown(back))
            {
                music.Pause();
                hasEnded = true;
                fadedImage.StartCoroutine(fadedImage.FadeImage(false, "Song Selection"));
            }

            if (offsetting)
            {
                songPosition = 0;
            }

            else
            {
                songPosition = (float)(AudioSettings.dspTime - dsptimesong);
            }

            if (songPosition > music.clip.length || (health <= 0 && !relax))
            {
                hasEnded = true;
                DateTime epochStart = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
                int      cur_time   = (int)(DateTime.UtcNow - epochStart).TotalSeconds;
                writer = new StreamWriter("Scores/" + music.name + "_" + cur_time + ".txt", true);
                float accuracy = (float)(score.notecount / (float)(score.notecount + score.misses) * 100);
                writer.WriteLine("Name: " + music.name);
                if (health <= 0)
                {
                    writer.WriteLine("Rank: F");
                }
                else
                {
                    writer.WriteLine("Rank: " + score.rank);
                }
                writer.WriteLine("Title: " + songTitle);
                writer.WriteLine("Player: " + PlayerPrefs.GetString("name"));
                writer.WriteLine("Score: " + score.score.ToString());
                writer.WriteLine("Accuracy: " + accuracy.ToString("F2") + "%");
                writer.WriteLine("MaxCombo: " + score.maxcombo.ToString());
                writer.WriteLine("Hits: " + score.notecount);
                writer.WriteLine("Misses: " + score.misses);

                writer.Close();
                fadedImage.StartCoroutine(fadedImage.FadeImage(false, "Score Screen"));
            }

            if (nextIndex < notes.Length && notes[nextIndex].timestamp < songPosition + beatsShownInAdvance)
            {
                var clone = Instantiate(note, new Vector3(xCords[notes[nextIndex].xIndex], 10f, 0f), new Quaternion(0f, 0f, 0f, 0f));
                clone.name = notes[nextIndex].timestamp.ToString();
                clones.Add(clone);
                nextIndex++;
            }
        }
    }
示例#4
0
    // Update is called once per frame
    void Update()
    {
        //Set up the new Pointer Event
        PointerEventData     pointerData = new PointerEventData(EventSystem.current);
        List <RaycastResult> results     = new List <RaycastResult>();

        //Raycast using the Graphics Raycaster and mouse click position
        pointerData.position = Input.mousePosition;

        this.raycaster.Raycast(pointerData, results);
        if (results.Count != 0)
        {
            currentlySelected = false;

            foreach (RaycastResult result in results)
            {
                if (Input.GetMouseButtonDown(0) && result.gameObject.name == "play")
                {
                    click.Play();
                    fadedImage.StartCoroutine(fadedImage.FadeImage(false, "Song Selection"));
                }
                else if (Input.GetMouseButtonDown(0) && result.gameObject.name == "opt")
                {
                    click.Play();
                    fadedImage.StartCoroutine(fadedImage.FadeImage(false, "Options"));
                }
                else if (Input.GetMouseButtonDown(0) && result.gameObject.name == "quit")
                {
                    click.Play();
                    Application.Quit();
                }

                for (int i = 0; i <= 2; i++)
                {
                    if (result.gameObject.name == buttons[i].name && result.gameObject.name != selectedButton.name)
                    {
                        hover.Play();
                        selectedButton = result.gameObject;
                        selectedState  = selectedButtons[i];
                        selectedImage  = selectedState.GetComponent <Image>();
                        selectedText   = selectedTexts[i];
                        selectedPos    = i;
                        StartCoroutine(FadeImage(false, selectedImage));
                        selectedText.color = selectedColor;
                    }
                }

                if (result.gameObject.name == selectedButton.name)
                {
                    currentlySelected = true;
                }
            }
        }

        if (!currentlySelected)
        {
            selectedButton     = selectedFail;
            selectedState      = selectedFail;
            selectedText.color = unselectedColor;
            StartCoroutine(FadeImage(true, selectedImage));
            selectedImage = selectedState.GetComponent <Image>();
        }
    }
示例#5
0
    // Update is called once per frame
    void Update()
    {
        //Set up the new Pointer Event
        PointerEventData     pointerData = new PointerEventData(EventSystem.current);
        List <RaycastResult> results     = new List <RaycastResult>();

        //Raycast using the Graphics Raycaster and mouse click position
        pointerData.position = Input.mousePosition;

        if (Input.GetKeyDown(back))
        {
            fadedImage.StartCoroutine(fadedImage.FadeImage(false, "Main Menu"));
        }

        this.raycaster.Raycast(pointerData, results);
        if (results.Count != 0)
        {
            foreach (RaycastResult result in results)
            {
                if (Input.GetMouseButtonDown(0) && result.gameObject.tag == "songbox")
                {
                    click.Play();
                    PlayerPrefs.SetString("songChoice", result.gameObject.name);
                    fadedImage.StartCoroutine(fadedImage.FadeImage(false, "Gameplay"));
                }

                if (result.gameObject.tag == "songbox" && result.gameObject.name != selected.name)
                {
                    hover.Play();
                    selected     = result.gameObject;
                    selectedtext = selected.GetComponent <songtext>();
                    title.text   = selectedtext.title + " - " + selectedtext.artist;
                    od.text      = "Overall Difficulty: " + selectedtext.difficulty.ToString("F2");
                    length.text  = "Length: " + selectedtext.length;

                    if (selectedtext.difficulty > 55)
                    {
                        backgroundImage.sprite = diffs[PlayerPrefs.GetInt("colour")][2];
                        circleImage.sprite     = circs[PlayerPrefs.GetInt("colour")][2];
                    }
                    else if (selectedtext.difficulty > 35)
                    {
                        backgroundImage.sprite = diffs[PlayerPrefs.GetInt("colour")][1];
                        circleImage.sprite     = circs[PlayerPrefs.GetInt("colour")][1];
                    }
                    else
                    {
                        backgroundImage.sprite = diffs[PlayerPrefs.GetInt("colour")][0];
                        circleImage.sprite     = circs[PlayerPrefs.GetInt("colour")][0];
                    }


                    foreach (Sprite cover in coverList)
                    {
                        if (cover.name == selected.name)
                        {
                            albumImage.sprite = cover;
                        }
                    }

                    if (PlayerPrefs.HasKey(selected.name))
                    {
                        var topscorestring = PlayerPrefs.GetString(selected.name).Split(',');
                        topscore.text = "Top Score: " + topscorestring[6];
                        score.text    = "Score: " + topscorestring[0];
                        topacc.text   = "Accuracy: " + topscorestring[3];
                        topcomb.text  = "Combo: " + topscorestring[4] + "x";
                    }
                    else
                    {
                        topscore.text = "Top Score: None";
                        score.text    = "Score: 0";
                        topacc.text   = "Accuracy: 0.00%";
                        topcomb.text  = "Combo: 0x";
                    }
                }
            }
        }
    }