Esempio n. 1
0
        public void CreateNote(TWxNote note)
        {
            GameObject newObj = null;

            if (note.Flick.Equals(0))
            {
                if (note.Mode.Equals(0))
                {
                    newObj = Instantiate(NormalNoteTemplate);
                }
                else if (note.Mode.Equals(1))
                {
                    newObj = Instantiate(LongNoteTemplate);
                }
                else if (note.Mode.Equals(2))
                {
                    newObj = Instantiate(SlideNoteTemplate);
                }
                else if (note.Mode.Equals(3))
                {
                    newObj = Instantiate(DamageNoteTemplate);
                }
                else if (note.Mode.Equals(4))
                {
                    newObj = Instantiate(HiddenNoteTemplate);
                }
            }
            else if (note.Flick.Equals(1))
            {
                newObj = Instantiate(FlickLeftTemplate);
            }
            else if (note.Flick.Equals(2))
            {
                newObj = Instantiate(FlickRightTemplate);
            }
            else if (note.Flick.Equals(3))
            {
                newObj = Instantiate(FlickUpTemplate);
            }
            else if (note.Flick.Equals(4))
            {
                newObj = Instantiate(FlickDownTemplate);
            }

            CreatorNote newNote = newObj.GetComponent <CreatorNote>();

            newNote.StartPoint = (float)note.StartLine;
            newNote.EndPoint   = (float)note.EndLine;
            newNote.YPos       = note.YPos % 192;
            newNote.Size       = note.Size;
            newNote.Type       = note.Mode;
            newNote.Flick      = note.Flick;
            newNote.Speed      = (float)note.Speed;
            newNote.NoteColor  = new Color32(note.Color[0], note.Color[1], note.Color[2], 255);
            newNote.ApplyColor();
            newNote.UpdateInfoToUI();
            newNote.SwitchViewMode();
            Notes.Add(newNote);
            Table.SelectedNote.Add(newNote);

            newObj.transform.SetParent(NoteBody);
            newObj.transform.localPosition = new Vector3((newNote.EndPoint - ((MaxLine + 1) / 2f)) * LineGap, Body.sizeDelta.y * (newNote.YPos / 192f), newNote.YPos / 192f);
            newObj.transform.localScale    = new Vector3(1, 1, 1);

            newObj.SetActive(true);
            Table.UpdateNoteCount(1);

            if (note.PrevIDs.Length > 0)
            {
                for (int i = 0; i < note.PrevIDs.Length; i++)
                {
                    if (note.PrevIDs[i] > 0)
                    {
                        if (Table.SelectedNote[note.PrevIDs[i] - 1].Type.Equals(1) && newNote.Type.Equals(1))
                        {
                            newNote.PreviousNotes.Add(Table.SelectedNote[note.PrevIDs[i] - 1]);
                            Table.SelectedNote[note.PrevIDs[i] - 1].NextNote = newNote;
                            CreateTail(Table.SelectedNote[note.PrevIDs[i] - 1].gameObject, newObj, 50);
                        }
                        else if (Table.SelectedNote[note.PrevIDs[i] - 1].Type.Equals(2) && newNote.Type.Equals(2))
                        {
                            newNote.PreviousNotes.Add(Table.SelectedNote[note.PrevIDs[i] - 1]);
                            Table.SelectedNote[note.PrevIDs[i] - 1].NextNote = newNote;
                            CreateTail(Table.SelectedNote[note.PrevIDs[i] - 1].gameObject, newObj, 50);
                        }
                        else if (!Table.SelectedNote[note.PrevIDs[i] - 1].Flick.Equals(0) && !newNote.Flick.Equals(0))
                        {
                            newNote.PreviousNotes.Add(Table.SelectedNote[note.PrevIDs[i] - 1]);
                            Table.SelectedNote[note.PrevIDs[i] - 1].NextNote = newNote;
                            CreateTail(Table.SelectedNote[note.PrevIDs[i] - 1].gameObject, newObj, 30);
                        }
                    }
                }
            }

            Table.NoteColorR = newNote.NoteColor.r;
            Table.NoteColorG = newNote.NoteColor.g;
            Table.NoteColorB = newNote.NoteColor.b;
            Table.RText.text = Table.NoteColorR.ToString();
            Table.GText.text = Table.NoteColorG.ToString();
            Table.BText.text = Table.NoteColorB.ToString();
        }
Esempio n. 2
0
        public void CreateNote(Vector2 pos)
        {
            Vector2 localPoint;

            RectTransformUtility.ScreenPointToLocalPointInRectangle(Body, pos, Camera.main, out localPoint);
            Debug.Log(localPoint);

            int xpos = Mathf.RoundToInt((localPoint.x / LineGap) + ((MaxLine + 1) / 2f));

            if (xpos < 1 || xpos > MaxLine)
            {
                return;
            }
            int ypos = CalculateNoteYPos(localPoint.y);

            if (ypos < 192)
            {
                CreatorNote sameNote   = null;
                bool        sameExists = false;
                foreach (CreatorNote note in Notes)
                {
                    if (xpos.Equals((int)note.EndPoint) && ypos.Equals(note.YPos))
                    {
                        sameExists = true; sameNote = note;
                    }
                }
                if (sameExists)
                {
                    DeleteNote(sameNote.gameObject); return;
                }

                GameObject newObj = null;
                if (Table.FlickType.Equals(0))
                {
                    if (Table.NoteType.Equals(0))
                    {
                        newObj = Instantiate(NormalNoteTemplate);
                    }
                    else if (Table.NoteType.Equals(1))
                    {
                        newObj = Instantiate(LongNoteTemplate);
                    }
                    else if (Table.NoteType.Equals(2))
                    {
                        newObj = Instantiate(SlideNoteTemplate);
                    }
                    else if (Table.NoteType.Equals(3))
                    {
                        newObj = Instantiate(DamageNoteTemplate);
                    }
                    else if (Table.NoteType.Equals(4))
                    {
                        newObj = Instantiate(HiddenNoteTemplate);
                    }
                }
                else if (Table.FlickType.Equals(1))
                {
                    newObj = Instantiate(FlickLeftTemplate);
                }
                else if (Table.FlickType.Equals(2))
                {
                    newObj = Instantiate(FlickRightTemplate);
                }
                else if (Table.FlickType.Equals(3))
                {
                    newObj = Instantiate(FlickUpTemplate);
                }
                else if (Table.FlickType.Equals(4))
                {
                    newObj = Instantiate(FlickDownTemplate);
                }

                CreatorNote newNote = newObj.GetComponent <CreatorNote>();
                newNote.StartPoint = Table.StartPoint;
                newNote.EndPoint   = xpos;
                if (Table.StartPoint.Equals(0))
                {
                    newNote.StartPoint = newNote.EndPoint;
                }
                newNote.YPos      = ypos;
                newNote.Size      = Table.SizeVal;
                newNote.Type      = Table.NoteType;
                newNote.Flick     = Table.FlickType;
                newNote.Speed     = Table.NoteSpeed;
                newNote.NoteColor = new Color32(Table.NoteColorR, Table.NoteColorG, Table.NoteColorB, 255);
                newNote.ApplyColor();
                newNote.UpdateInfoToUI();
                newNote.SwitchViewMode();
                Notes.Add(newNote);

                newObj.transform.SetParent(NoteBody);
                newObj.transform.localPosition = new Vector3((newNote.EndPoint - ((MaxLine + 1) / 2f)) * LineGap, Body.sizeDelta.y * (newNote.YPos / 192f), newNote.YPos / 192f);
                newObj.transform.localScale    = new Vector3(1, 1, 1);

                newObj.SetActive(true);
                Table.UpdateNoteCount(1);

                if (newNote.Flick != 0)
                {
                    if (Table.NotePlaceMode.Equals(3))
                    {
                        newNote.PreviousNotes.Add(Table.LastFlickNote);
                        Table.LastFlickNote.NextNote = newNote;
                        CreateTail(Table.LastFlickNote.gameObject, newObj, 30);
                        Table.LastFlickNote = newNote;
                    }
                }

                if (newNote.Type.Equals(1))
                {
                    if (Table.NotePlaceMode.Equals(1))
                    {
                        newNote.PreviousNotes.Add(Table.LastLongNote);
                        Table.LastLongNote.NextNote = newNote;
                        CreateTail(Table.LastLongNote.gameObject, newObj, 50);
                        if (newNote.Flick.Equals(0))
                        {
                            Table.NotePlaceMode = 0;
                            Table.PlaceModeChanged(0);
                        }
                    }
                    else
                    {
                        Table.NotePlaceMode = 1;
                        Table.LastLongNote  = newNote;
                        Table.PlaceModeChanged(1);
                    }
                }
                else if (newNote.Type.Equals(2))
                {
                    if (Table.NotePlaceMode.Equals(2))
                    {
                        newNote.PreviousNotes.Add(Table.LastSlideNote);
                        Table.LastSlideNote.NextNote = newNote;
                        CreateTail(Table.LastSlideNote.gameObject, newObj, 50);
                        Table.LastSlideNote = newNote;
                    }
                    else
                    {
                        Table.NotePlaceMode = 2;
                        Table.LastSlideNote = newNote;
                        Table.PlaceModeChanged(2);
                    }
                }

                if (newNote.Flick != 0)
                {
                    if (Table.NotePlaceMode != 3)
                    {
                        Table.NotePlaceMode = 3;
                        Table.LastFlickNote = newNote;
                        Table.PlaceModeChanged(3);
                    }
                }

                SortNotes();
            }
            else
            {
                if (NextBlock != null)
                {
                    NextBlock.CreateNote(pos);
                }
            }
        }