Ejemplo n.º 1
0
    private IEnumerator UpdateCoroutine()
    {
        float zbuffer = -0.000001f;
        float bufferS = 0.0001f;

        _musicPlayer.PlayDelayed(musicOffset / 1000);
        while (_currentObject != _osuObjects.Count - 1 && _currentHealth > 0f)
        {
            CircleClass current = _osuObjects[_currentObject];
            double      timer   = _musicPlayer.time;
            double      delay   = (current.Time - Preemt) / 1000f;

            if (timer >= delay)
            {
                zbuffer += bufferS;
                GameObject temp = Instantiate(circle, new Vector3(current.X, current.Y, zbuffer), Quaternion.identity);
                var        comp = temp.GetComponent <HitCircle>();
                comp.Dead     += NoteMiss;
                comp.dieOffset = dieOffset;
                _currentObject++;
            }
            yield return(null);
        }

        while (_musicPlayer.isPlaying && _currentHealth > 0)
        {
            yield return(null);
        }

        returnButton.gameObject.SetActive(true);
        restartButton.gameObject.SetActive(true);
    }
Ejemplo n.º 2
0
        [TestCase(0, -5, 5)]//btw III-IV
        public void TestPointArea2(double x, double y, double R)
        {
            bool        expected = false;
            CircleClass c        = new CircleClass();
            bool        actual   = c.Coordinate(x, y, R);

            Assert.AreEqual(expected, actual);
        }
Ejemplo n.º 3
0
    public List <CircleClass> Parse(string path, out AudioClip music, out float approachRate)
    {
        music        = null;
        approachRate = 4;

        StreamReader  reader     = new StreamReader(path);
        List <string> hitObjects = new List <string>();

        // Getting song file
        // Skip to [General] section
        while (reader.ReadLine() != "[General]")
        {
        }
        string filename = reader.ReadLine();

        filename = filename.Substring(15, filename.Length - 15);

        string songpath = path.Replace('\\', '/');

        Debug.Log(songpath);
        for (int i = songpath.Length - 1; i > 0; --i)
        {
            if (songpath[i] == '/')
            {
                break;
            }
            songpath = songpath.Remove(i);
        }

        string[] files = Directory.GetFiles(songpath, "*.mp3");

        foreach (var song in files)
        {
            if (song.Contains(filename))
            {
                music = LoadSong(song);
            }
        }


        // Skip to [Difficulty] section
        while (reader.ReadLine() != "[Difficulty]")
        {
        }
        string approachRateString = "4";

        while (true)
        {
            if (approachRateString.Contains("ApproachRate"))
            {
                break;
            }

            approachRateString = reader.ReadLine();
        }

        approachRateString = approachRateString.Substring(13, approachRateString.Length - 13);
        approachRate       = float.Parse(approachRateString.Replace('.', ','));

        // Skip to [HitObjects] section
        while (reader.ReadLine() != "[HitObjects]")
        {
        }

        while (true)
        {
            string line = reader.ReadLine();

            if (line == null)
            {
                break;
            }

            hitObjects.Add(line);
        }

        List <CircleClass> objects = new List <CircleClass>();

        for (int i = 0; i < hitObjects.Count - 1; i++)
        {
            string[] circleParams = hitObjects[i].Split(',');

            int desiredX = Mathf.RoundToInt(int.Parse(circleParams[0]) / 512f * Screen.width);
            int desiredY = Mathf.RoundToInt((384 - int.Parse(circleParams[1])) / 384f * Screen.height);

            Vector3 screenPos = new Vector3(desiredX, desiredY, 0);
            Vector3 worldPos  = Camera.main.ScreenToWorldPoint(screenPos);

            CircleClass newCircleClass = new CircleClass(
                worldPos.x,
                worldPos.y,
                int.Parse(circleParams[2])
                );

            objects.Add(newCircleClass);
        }

        reader.Close();
        return(objects);
    }