Exemplo n.º 1
0
    private void CreateSlidePath(ref GameObject pathObject, int length, NoteSlideWay slideWay, bool roundTrip, int index)
    {
        pathObject = Instantiate <GameObject>(PathPrefab);

        pathObject.transform.position = new Vector3(0.0f, 0.0f, -0.99f);
        if (slideWay == NoteSlideWay.CLOCKWISE)
        {
            pathObject.transform.eulerAngles = new Vector3(0.0f, 0.0f, (-45.0f * index) + 11.25f);
        }
        else
        {
            pathObject.transform.eulerAngles = new Vector3(0.0f, 180.0f, (45.0f * index) + 11.25f);
        }

        for (int i = 0; i <= length; i++)
        {
            GameObject roundTripObject = Instantiate <GameObject>(RoundTripNotePrefab);
            roundTripObject.transform.position = notePosition[i + 1].position;
            m_roundTripDictionary.Add(roundTripObject, pathObject);

            if (roundTrip)
            {
                if (slideWay == NoteSlideWay.CLOCKWISE && i == length)
                {
                    roundTripObject.transform.FindChild("Icon").GetComponent <Image>().enabled = true;
                }
                else if (slideWay == NoteSlideWay.ANTI_CLOCKWISE && i == 0)
                {
                    roundTripObject.transform.FindChild("Icon").GetComponent <Image>().enabled = true;
                }
            }
        }

        m_pathList.Add(pathObject);
    }
Exemplo n.º 2
0
    private void CreateNoteList()
    {
        int bpm     = NoteDataLoader.Instance.BPM;
        int maxBeat = NoteDataLoader.Instance.MaxBeat;

        JsonData jsonData = NoteDataLoader.Instance.NoteData;

        JsonData jsonBar = jsonData["Note"];

        for (int i = 0; i < jsonBar.Count; i++)
        {
            JsonData jsonBeat = jsonBar[i];
            for (int j = 0; j < jsonBeat.Count; j++)
            {
                JsonData jsonNote = jsonBeat[j];
                for (int k = 0; k < jsonNote.Count; k++)
                {
                    JsonData jsonNoteData = jsonNote[k];

                    NoteType     type      = (NoteType)(int)jsonNoteData["Type"];
                    int          length    = (int)jsonNoteData["Length"];
                    int          slideTime = (int)jsonNoteData["SlideTime"];
                    NoteSlideWay slideWay  = (NoteSlideWay)(int)jsonNoteData["SlideWay"];
                    bool         roundTrip = (bool)jsonNoteData["RoundTrip"];

                    Note note = null;

                    if (type == NoteType.TAP)
                    {
                        GameObject noteObject = Instantiate <GameObject>(TapNotePrefab);

                        note          = noteObject.GetComponent <TapNote>();
                        note.Type     = type;
                        note.TimeSeen = ((60.0f / bpm) / (maxBeat / 4)) * ((i * maxBeat) + j);
                    }
                    else if (type == NoteType.LONG)
                    {
                        GameObject noteObject = Instantiate <GameObject>(LongNotePrefab);

                        note          = noteObject.GetComponent <LongNote>();
                        note.Type     = type;
                        note.Length   = length;
                        note.TimeSeen = ((60.0f / bpm) / (maxBeat / 4)) * ((i * maxBeat) + j);
                    }
                    else if (type == NoteType.SLIDE)
                    {
                        GameObject noteObject = Instantiate <GameObject>(SlideNotePrefab);
                        GameObject pathObject = null;

                        CreateSlidePath(ref pathObject, length, slideWay, roundTrip, k);

                        SlideNote slideNote = noteObject.transform.FindChild("NoteImage").GetComponent <SlideNote>();
                        slideNote.maskImage = pathObject.GetComponent <Image>();
                        slideNote.pathImage = pathObject.transform.FindChild("PathImage").GetComponent <Image>();

                        note           = slideNote;
                        note.Type      = type;
                        note.Length    = length;
                        note.SlideTime = slideTime;
                        note.SlideWay  = slideWay;
                        note.RoundTrip = roundTrip;
                        note.TimeSeen  = ((60.0f / bpm) / (maxBeat / 4)) * ((i * maxBeat) + j);
                    }
                    else if (type == NoteType.SNAP)
                    {
                        GameObject noteObject = Instantiate <GameObject>(SnapNotePrefab);

                        note          = noteObject.GetComponent <SnapNote>();
                        note.Type     = type;
                        note.TimeSeen = ((60.0f / bpm) / (maxBeat / 4)) * ((i * maxBeat) + j);
                    }

                    if (note != null)
                    {
                        note.SetNoteActive(false);
                        if (type == NoteType.SLIDE)
                        {
                            note.transform.parent.position    = new Vector3(0.0f, 0.0f, -1.0f);
                            note.transform.parent.eulerAngles = new Vector3(0.0f, 0.0f, -45.0f * k);
                            note.transform.eulerAngles        = new Vector3(0.0f, 0.0f, 0.0f);
                        }
                        else if (type == NoteType.SNAP)
                        {
                            note.transform.position = new Vector3(0.0f, 0.0f, -1.0f);
                        }
                        else
                        {
                            note.transform.position = notePosition[k].position;
                        }

                        m_noteList.Add(note);

                        if (type == NoteType.SNAP)
                        {
                            break;
                        }
                    }
                }
            }
        }
    }
    private void CreateSlidePath(ref GameObject pathObject, int length, NoteSlideWay slideWay, bool roundTrip, int index)
    {
        pathObject = Instantiate<GameObject>(PathPrefab);

        pathObject.transform.position = new Vector3(0.0f, 0.0f, -0.99f);
        if (slideWay == NoteSlideWay.CLOCKWISE)
            pathObject.transform.eulerAngles = new Vector3(0.0f, 0.0f, (-45.0f * index) + 11.25f);
        else
            pathObject.transform.eulerAngles = new Vector3(0.0f, 180.0f, (45.0f * index) + 11.25f);

        for (int i = 0; i <= length; i++)
        {
            GameObject roundTripObject = Instantiate<GameObject>(RoundTripNotePrefab);
            roundTripObject.transform.position = notePosition[i + 1].position;
            m_roundTripDictionary.Add(roundTripObject, pathObject);

            if (roundTrip)
            {
                if (slideWay == NoteSlideWay.CLOCKWISE && i == length)
                    roundTripObject.transform.FindChild("Icon").GetComponent<Image>().enabled = true;
                else if (slideWay == NoteSlideWay.ANTI_CLOCKWISE && i == 0)
                    roundTripObject.transform.FindChild("Icon").GetComponent<Image>().enabled = true;
            }
        }

        m_pathList.Add(pathObject);
    }