Example #1
0
    public void Load(MusicNames MusicName, Levels level)
    {
        NotesManager notesManager = (NotesManager)FindObjectOfType(typeof(NotesManager));
        MoveManager  moveManager  = (MoveManager)FindObjectOfType(typeof(MoveManager));
        JudgeScript  judgeScript  = (JudgeScript)FindObjectOfType(typeof(JudgeScript));

        string folderName = "Data/" + MusicName.ToString() + "/";

        TextAsset    musicData = Resources.Load <TextAsset>(folderName + tuneData);
        StringReader sr        = new StringReader(musicData.text);

        while (sr.Peek() != -1)
        {
            string        _str = sr.ReadLine();
            string[]      str  = _str.Split(',');
            TuneDataIndex tuneDataIndex;
            Enum.TryParse <TuneDataIndex>(str[0], out tuneDataIndex);
            switch (tuneDataIndex)
            {
            case TuneDataIndex.NAME:
                musicName = str[1];
                break;

            case TuneDataIndex.BPM:
                bpm = float.Parse(str[1]);
                break;

            case TuneDataIndex.OFFSET:
                offset = float.Parse(str[1]);
                break;
            }
        }
        notesManager.SetBPM(bpm);
        notesManager.SetOffset(offset);

        TextAsset notesData = Resources.Load <TextAsset>(folderName + level.ToString() + "NotesData");

        notesManager.Load(notesData);
        AudioClip clip = Resources.Load <AudioClip>(folderName + clipName);

        moveManager.Init();
        moveManager.SetClip(clip);
        judgeScript.Init();

        moveManager.MusicStart();
    }
Example #2
0
    void Start()
    {
        style = new GUIStyle();
        style.normal.textColor = Color.black;

        int count = MoveManager.GetNumConnected();

        for (int i = 0; i < count; i++)
        {
            MoveManager move = gameObject.AddComponent <MoveManager>();

            if (!move.Init(i))
            {
                Destroy(move);
                continue;
            }

            PSMoveConnectionType conn = move.ConnectionType;

            if (conn == PSMoveConnectionType.Unknown || conn == PSMoveConnectionType.USB)
            {
                Destroy(move);
            }
            else
            {
                moves.Add(move);
                move.OnControllerDisconnected += HandleControllerDisconnected;
                move.SetLED(Color.cyan);

                DisplayedPosition = new Vector3(0.0f, 1.0f, 0.0f);
                TransformMatrix   = Matrix4x4.TRS(Vector3.zero, Quaternion.identity, Vector3.one);

                // The proposed algorithm’s adjustable parameter, ß, was set to 0.033 for the MARG
                // implementation and 0.041 for the IMU implementation.
                //AHRS = new AHRS.MadgwickAHRS(1f / 75f, 0.1f);
                AHRS = new AHRS.MadgwickAHRS(1f / 75f, 0.033f);
            }
        }
    }