Пример #1
0
        public void Launch(NotesManager notesManager, SoundManager soundManager, NoteData noteData)
        {
            this.manager      = notesManager;
            this.soundManager = soundManager;
            this.data         = noteData;
            this.y            = this.manager.from + (this.manager.to - this.manager.from) * (this.CalcTime() / this.manager.speed);
            this.angle        = this.manager.from_angle;

            this.transform.localPosition    = new Vector3(this.manager.lane_width * (this.data.lane - 3), this.y, this.transform.position.z);
            this.transform.localEulerAngles = new Vector3(this.angle, 0.0f, 0.0f);
        }
Пример #2
0
        public void Launch(int index, NotesManager notesManager, SoundManager soundManager, NoteData note1, NoteData note2)
        {
            this.index        = index;
            this.manager      = notesManager;
            this.soundManager = soundManager;
            this.note1        = note1;
            this.note2        = note2;

            float x      = this.manager.lane_width * ((float)(this.note1.lane + this.note2.lane) / 2f - 3f);
            float y      = this.manager.from + (this.manager.to - this.manager.from) * (this.CalcTime() / this.manager.speed);
            float scaleX = (this.manager.lane_width / 10) * Mathf.Abs(this.note1.lane - this.note2.lane);

            this.transform.position   = new Vector3(x, y, this.transform.position.z);
            this.transform.localScale = new Vector3(scaleX, this.transform.localScale.y, this.transform.localScale.z);
        }
Пример #3
0
        public void Launch(int index, NotesManager notesManager, SoundManager soundManager, NoteData fromNote, NoteData toNote)
        {
            this.index        = index;
            this.manager      = notesManager;
            this.soundManager = soundManager;
            this.fromNote     = fromNote;
            this.toNote       = toNote;
            this.y            = this.manager.from;

            Mesh mesh = GetComponent <MeshFilter>().mesh;

            Vector3[] vertices = mesh.vertices;

            float PPS = (this.manager.to - this.manager.from) / this.manager.speed;

            vertices[0] = new Vector3((this.toNote.lane - this.fromNote.lane) * this.manager.lane_width - this.manager.lane_width / 2,
                                      -(this.toNote.time - this.fromNote.time) * PPS, 0f);
            vertices[3] = new Vector3(-this.manager.lane_width / 2, 0f, 0f);
            vertices[1] = new Vector3((this.toNote.lane - this.fromNote.lane) * this.manager.lane_width + this.manager.lane_width / 2,
                                      -(this.toNote.time - this.fromNote.time) * PPS, 0f);
            vertices[2] = new Vector3(this.manager.lane_width / 2, 0f, 0f);

            mesh.vertices = vertices;
            mesh.RecalculateBounds();

            this.transform.localPosition = new Vector3(this.manager.lane_width * (this.fromNote.lane - 3), this.y, 0.0f);
        }
Пример #4
0
        // Update is called once per frame
        void Update()
        {
            List <int>      launchedNotes     = new List <int>();
            List <SyncLine> launchedSyncLines = new List <SyncLine>();

            Transform childTransform = this.notesParent.transform;

            foreach (Transform child in childTransform.transform)
            {
                NoteData data = child.gameObject.GetComponent <Notes>().GetNoteData();
                launchedNotes.Add(data.index);
            }

            childTransform = this.syncLinesParent.transform;
            foreach (Transform child in childTransform.transform)
            {
                SyncLine line = child.gameObject.GetComponent <SyncLine>();
                launchedSyncLines.Add(line);
            }

            for (int i = 0; i < this.notes.Count; i++)
            {
                NoteData note = this.notes[i];

                if (this.soundManager.time >= note.time - this.speed && this.soundManager.time <= note.time + this.afterTime)
                {
                    bool doDraw = true;
                    foreach (SyncLine launchedLine in launchedSyncLines)
                    {
                        if (launchedLine.GetNoteData(true).index == note.index || launchedLine.GetNoteData(false).index == note.index)
                        {
                            doDraw = false;
                            break;
                        }
                    }

                    if (doDraw)
                    {
                        foreach (NoteData noteData in this.notes)
                        {
                            if (noteData.index == note.index)
                            {
                                continue;
                            }
                            if (Mathf.Abs(noteData.time - note.time) * 1000 < 1)
                            {
                                foreach (SyncLine launchedLine in launchedSyncLines)
                                {
                                    if (launchedLine.GetNoteData(true).index == noteData.index || launchedLine.GetNoteData(false).index == noteData.index)
                                    {
                                        goto ExitProcess;
                                    }
                                }

                                SyncLine syncLine = Instantiate(syncLinesPrefab).gameObject.GetComponent <SyncLine>();
                                syncLine.transform.parent = syncLinesParent.transform;
                                syncLine.Launch(note.index, this, this.soundManager, note, noteData);

                                launchedSyncLines.Add(syncLine);
                            }
                        }
                        ExitProcess :;
                    }

                    for (int j = 0; j < launchedNotes.Count; j++)
                    {
                        if (note.index == launchedNotes[j])
                        {
                            launchedNotes.Remove(launchedNotes[j]);
                            goto ThroughProcess;
                        }
                    }

                    LaunchNotes(note);
                }

                ThroughProcess :;
            }

            childTransform = this.notesParent.transform;
            foreach (Transform child in childTransform.transform)
            {
                if (launchedNotes.Count == 0)
                {
                    break;
                }
                NoteData childData = child.gameObject.GetComponent <Notes>().GetNoteData();
                foreach (int index in launchedNotes)
                {
                    if (childData.index == index)
                    {
                        Destroy(child.gameObject);
                        launchedNotes.Remove(index);
                        break;
                    }
                }
            }

            childTransform = this.notesParent.transform;
            foreach (Transform child in childTransform.transform)
            {
                NoteData data = child.gameObject.GetComponent <Notes>().GetNoteData();
                launchedNotes.Add(data.index);
            }

            childTransform = this.slideLinesParent.transform;
            foreach (Transform child in childTransform.transform)
            {
                SlideLine line = child.gameObject.GetComponent <SlideLine>();
                foreach (int index in launchedNotes)
                {
                    if (line.GetNoteData(true).index == index || line.GetNoteData(false).index == index)
                    {
                        goto ThroughProcess;
                    }
                }

                Destroy(child.gameObject);

                ThroughProcess :;
            }

            childTransform = this.syncLinesParent.transform;
            foreach (Transform child in childTransform.transform)
            {
                SyncLine line = child.gameObject.GetComponent <SyncLine>();
                foreach (int index in launchedNotes)
                {
                    if (line.GetNoteData(true).index == index || line.GetNoteData(false).index == index)
                    {
                        goto ThroughProcess;
                    }
                }

                Destroy(child.gameObject);

                ThroughProcess :;
            }
        }
Пример #5
0
        void LaunchNotes(NoteData note)
        {
            List <int> launchedSlideLines = new List <int>();

            Transform childTransform = this.slideLinesParent.transform;

            foreach (Transform child in childTransform.transform)
            {
                SlideLine line = child.gameObject.GetComponent <SlideLine>();
                launchedSlideLines.Add(line.index);
            }

            bool doDraw;

            switch (note.type)
            {
            case Common.NOTE.SINGLE:
                Notes fromNote = Instantiate(singlenotesPrefab).gameObject.GetComponent <Notes>();
                fromNote.transform.parent = notesParent.transform;
                fromNote.Launch(this, this.soundManager, note);
                break;

            case Common.NOTE.SLIDE_PRESS:
                fromNote = Instantiate(slidenotesPressPrefab).gameObject.GetComponent <Notes>();
                fromNote.transform.parent = notesParent.transform;
                fromNote.Launch(this, this.soundManager, note);

                doDraw = true;
                for (int k = 0; k < launchedSlideLines.Count; k++)
                {
                    if (note.index == launchedSlideLines[k])
                    {
                        doDraw = false;
                    }
                }

                if (doDraw)
                {
                    for (int j = 0; j < this.notes.Count; j++)
                    {
                        if (note.chainBehind == notes[j].index)
                        {
                            SlideLine slideLine = Instantiate(slidelinesPrefab).gameObject.GetComponent <SlideLine>();
                            slideLine.transform.parent = slideLinesParent.transform;
                            slideLine.Launch(note.index, this, this.soundManager, note, notes[j]);
                            note.slideLine = slideLine;

                            launchedSlideLines.Add(slideLine.index);
                            break;
                        }
                    }
                }

                break;

            case Common.NOTE.SLIDE_VIA:
                fromNote = Instantiate(slidenotesViaPrefab).gameObject.GetComponent <Notes>();
                fromNote.transform.parent = notesParent.transform;
                fromNote.Launch(this, this.soundManager, note);

                doDraw = true;
                for (int k = 0; k < launchedSlideLines.Count; k++)
                {
                    if (note.index == launchedSlideLines[k])
                    {
                        doDraw = false;
                    }
                }

                if (doDraw)
                {
                    for (int j = 0; j < this.notes.Count; j++)
                    {
                        if (note.chainBehind == notes[j].index)
                        {
                            SlideLine slideLine = Instantiate(slidelinesPrefab).gameObject.GetComponent <SlideLine>();
                            slideLine.transform.parent = slideLinesParent.transform;
                            slideLine.Launch(note.index, this, this.soundManager, note, notes[j]);
                            note.slideLine = slideLine;

                            launchedSlideLines.Add(slideLine.index);
                            break;
                        }
                    }
                }

                doDraw = true;
                for (int k = 0; k < launchedSlideLines.Count; k++)
                {
                    if (note.chainForward == launchedSlideLines[k])
                    {
                        doDraw = false;
                    }
                }

                if (doDraw)
                {
                    for (int j = 0; j < this.notes.Count; j++)
                    {
                        if (note.chainForward == notes[j].index)
                        {
                            SlideLine slideLine = Instantiate(slidelinesPrefab).gameObject.GetComponent <SlideLine>();
                            slideLine.transform.parent = slideLinesParent.transform;
                            slideLine.Launch(notes[j].index, this, this.soundManager, notes[j], note);

                            launchedSlideLines.Add(slideLine.index);
                            break;
                        }
                    }
                }

                break;

            case Common.NOTE.SLIDE_RELEASE:
                fromNote = Instantiate(slidenotesReleasePrefab).gameObject.GetComponent <Notes>();
                fromNote.transform.parent = notesParent.transform;
                fromNote.Launch(this, this.soundManager, note);

                doDraw = true;
                for (int k = 0; k < launchedSlideLines.Count; k++)
                {
                    if (note.chainForward == launchedSlideLines[k])
                    {
                        doDraw = false;
                    }
                }

                if (doDraw)
                {
                    for (int j = 0; j < this.notes.Count; j++)
                    {
                        if (note.chainForward == notes[j].index)
                        {
                            SlideLine slideLine = Instantiate(slidelinesPrefab).gameObject.GetComponent <SlideLine>();
                            slideLine.transform.parent = slideLinesParent.transform;
                            slideLine.Launch(notes[j].index, this, this.soundManager, notes[j], note);

                            launchedSlideLines.Add(slideLine.index);
                            break;
                        }
                    }
                }

                break;

            case Common.NOTE.FLICK:
                fromNote = Instantiate(flicknotesPrefab).gameObject.GetComponent <Notes>();
                fromNote.transform.parent = notesParent.transform;
                GameObject grandchild = fromNote.transform.Find("Wrap").transform.Find("Arrow").gameObject;
                grandchild.GetComponent <LookAtCamera>().targetCamera = mainCamera;
                fromNote.Launch(this, this.soundManager, note);

                if (note.chainForward != -1)
                {
                    doDraw = true;
                    for (int k = 0; k < launchedSlideLines.Count; k++)
                    {
                        if (note.chainForward == launchedSlideLines[k])
                        {
                            doDraw = false;
                        }
                    }

                    if (doDraw)
                    {
                        for (int j = 0; j < this.notes.Count; j++)
                        {
                            if (note.chainForward == notes[j].index)
                            {
                                SlideLine slideLine = Instantiate(slidelinesPrefab).gameObject.GetComponent <SlideLine>();
                                slideLine.transform.parent = slideLinesParent.transform;
                                slideLine.Launch(notes[j].index, this, this.soundManager, notes[j], note);

                                launchedSlideLines.Add(slideLine.index);
                                break;
                            }
                        }
                    }
                }
                break;
            }
        }
Пример #6
0
        private void Update()
        {
            try
            {
                for (int j = 0; j < this.notesManager.notes.Count; j++)
                {
                    NoteData data = this.notesManager.notes[j];
                    if (!data.isJudged && this.soundManager.time + this.regulation >= data.time)
                    {
                        if (data.type == Common.NOTE.SLIDE_VIA)
                        {
                            List <NotesTouchManager.PressedLane> pressedLanes = this.notesTouchManager.GetPressedLanes();
                            bool isMiss = true;
                            foreach (NotesTouchManager.PressedLane pLane in pressedLanes)
                            {
                                if (data.lane == pLane.lane)
                                {
                                    Debug.Log(this.name + ": SlideViaHit lane=" + pLane.lane.ToString());
                                    this.judgeDisplay.Launch(Common.JUDGE.PERFECT);
                                    this.scoreManager.ScoreAdd(Common.JUDGE.PERFECT);
                                    this.comboManager.AddCombo();
                                    this.SEManager.Play(2);
                                    this.effectManager.GenerateEffect(data.type, pLane.lane);

                                    data.slideLine.isPressing      = true;//
                                    data.slideLine.effectTransform = this.effectManager.GenerateSlideEffect(pLane.lane).GetComponent <RectTransform>();

                                    bool isAimed = false;
                                    for (int i = 0; i < this.aimedRelease.Count; i++)
                                    {
                                        AimedRelease aim = this.aimedRelease[i];
                                        if (aim.pointerId != pLane.pointerId)
                                        {
                                            continue;
                                        }
                                        foreach (NoteData aimNote in this.notesManager.notes)
                                        {
                                            if (aimNote.index == data.chainBehind)
                                            {
                                                aim.note             = aimNote;
                                                this.aimedRelease[i] = aim;
                                                isAimed = true;
                                                Debug.Log(this.name + ": aimChange index=" + aim.note.index + " lane=" + aim.note.lane + " id=" + aim.pointerId + " ex=" + data.index);
                                                break;
                                            }
                                        }
                                    }
                                    if (!isAimed)
                                    {
                                        AimedRelease aim = new AimedRelease();
                                        aim.pointerId = pLane.pointerId;
                                        foreach (NoteData aimNote in this.notesManager.notes)
                                        {
                                            if (aimNote.index == data.chainBehind)
                                            {
                                                aim.note = aimNote;
                                                Debug.Log(this.name + ": aim lane=" + aim.note.lane + " id=" + aim.pointerId);
                                                break;
                                            }
                                        }
                                        if (aim.note == null)
                                        {
                                            int a = 0;
                                        }
                                        this.aimedRelease.Add(aim);
                                    }

                                    this.notesManager.DestroyNote(data);

                                    isMiss = false;
                                    break;
                                }
                            }

                            data.isJudged = true;

                            if (isMiss)
                            {
                                //Debug.Log(this.name + ": Miss");
                                this.judgeDisplay.Launch(Common.JUDGE.MISS);
                                this.scoreManager.ScoreAdd(Common.JUDGE.MISS);
                                this.hpManager.Damage(Common.JUDGE.MISS);
                                this.SEManager.Play(0);
                                this.comboManager.LoseCombo();

                                foreach (AimedRelease aim in this.aimedRelease)
                                {
                                    if (aim.note.index == data.index) //
                                    {
                                        this.aimedRelease.Remove(aim);
                                        Debug.Log(this.name + ": aimDelete lane=" + aim.note.lane + " id=" + aim.pointerId);
                                        break;
                                    }
                                }

                                this.notesManager.DestroyNote(data);
                            }
                        }
                        else
                        {
                            if (this.soundManager.time + this.regulation > data.time + this.badRangeAfter)
                            {
                                //Debug.Log(this.name + ": Miss");
                                this.judgeDisplay.Launch(Common.JUDGE.MISS);
                                this.scoreManager.ScoreAdd(Common.JUDGE.MISS);
                                this.hpManager.Damage(Common.JUDGE.MISS);
                                this.SEManager.Play(0);
                                this.comboManager.LoseCombo();
                                data.isJudged = true;

                                if (data.type == Common.NOTE.SLIDE_RELEASE)
                                {
                                    foreach (AimedRelease aim in this.aimedRelease)
                                    {
                                        if (aim.note.index == data.index)//
                                        {
                                            this.aimedRelease.Remove(aim);
                                            Debug.Log(this.name + ": aimDelete lane=" + aim.note.lane + " id=" + aim.pointerId);
                                            break;
                                        }
                                    }
                                }

                                this.notesManager.DestroyNote(data);
                            }
                        }
                    }
                }
            } catch (System.Exception e)
            {
                this.mockToast.Launch(e.ToString());
                Debug.Log(this.name + ": " + e.ToString());
            }
        }
Пример #7
0
        public void EventJudge(byte eventLane, Common.EVENT eventTyoe, int pointerId)
        {
            List <byte> judgeLanes = new List <byte>();
            byte        trueLane   = 0;

            if (eventLane == 0)
            {
                judgeLanes.Add(0);
                trueLane = 0;
            }
            else if (1 <= eventLane && eventLane <= 12)
            {
                if (eventLane % 2 == 0)
                {
                    judgeLanes.Add((byte)(Mathf.Floor(eventLane / 2) - 1));
                }
                else
                {
                    judgeLanes.Add((byte)(Mathf.Floor(eventLane / 2) + 1));
                }
                judgeLanes.Add((byte)Mathf.Floor(eventLane / 2));
                trueLane = (byte)Mathf.Floor(eventLane / 2);
            }
            else if (eventLane == 13)
            {
                judgeLanes.Add(6);
                trueLane = 6;
            }

            NoteData nearestNote = null;
            float    time        = this.soundManager.time + this.regulation;

            foreach (NoteData note in this.notesManager.notes)
            {
                bool isLaneMatch = false;
                foreach (byte lane in judgeLanes)
                {
                    if (note.lane == lane)
                    {
                        isLaneMatch = true;
                    }
                }
                if (!isLaneMatch)
                {
                    continue;
                }

                switch (eventTyoe)
                {
                case Common.EVENT.PRESS:
                    if (note.type != Common.NOTE.SINGLE && note.type != Common.NOTE.SLIDE_PRESS)
                    {
                        continue;
                    }
                    break;

                case Common.EVENT.RELEASE:
                    if (note.type != Common.NOTE.SLIDE_RELEASE)
                    {
                        continue;
                    }
                    break;

                case Common.EVENT.FLICK:
                    if (note.type != Common.NOTE.FLICK)
                    {
                        continue;
                    }
                    break;
                }

                if (note.time - this.badRangeBefore < time && time < note.time + this.badRangeAfter)
                {
                    if (note.type == Common.NOTE.SLIDE_RELEASE)
                    {
                        bool isForwardExists = false;
                        foreach (NoteData nd in this.notesManager.notes)
                        {
                            if (note.chainForward == nd.index)
                            {
                                isForwardExists = true;
                            }
                        }
                        if (isForwardExists)
                        {
                            continue;
                        }
                    }

                    if (nearestNote == null)
                    {
                        nearestNote = note;
                    }
                    else if (Mathf.Abs(nearestNote.time - time) > Mathf.Abs(note.time - time))
                    {
                        nearestNote = note;
                    }
                }
            }

            if (nearestNote != null)
            {
                Debug.Log(this.name + ": JudgeEnter index=" + nearestNote.index + " type=" + nearestNote.type + " lane=" + nearestNote.lane);
                if (time < nearestNote.time - this.goodRangeBefore || nearestNote.time + this.goodRangeAfter < time)
                {
                    //Debug.Log(this.name + ": Bad");
                    judgeDisplay.Launch(Common.JUDGE.BAD);
                    this.scoreManager.ScoreAdd(Common.JUDGE.BAD);
                    this.hpManager.Damage(Common.JUDGE.BAD);
                    this.comboManager.LoseCombo();
                    this.SEManager.Play(0);
                }
                else if (time < nearestNote.time - this.greatRangeBefore || nearestNote.time + this.greatRangeAfter < time)
                {
                    //Debug.Log(this.name + ": Good");
                    judgeDisplay.Launch(Common.JUDGE.GOOD);
                    this.scoreManager.ScoreAdd(Common.JUDGE.GOOD);
                    this.comboManager.LoseCombo();
                    this.SEManager.Play(1);
                }
                else if (time < nearestNote.time - this.perfectRangeBefore || nearestNote.time + this.perfectRangeAfter < time)
                {
                    //Debug.Log(this.name + ": Great");
                    judgeDisplay.Launch(Common.JUDGE.GREAT);
                    this.scoreManager.ScoreAdd(Common.JUDGE.GREAT);
                    this.comboManager.AddCombo();
                    this.SEManager.Play(1);
                }
                else
                {
                    //Debug.Log(this.name + ": Perfect");
                    judgeDisplay.Launch(Common.JUDGE.PERFECT);
                    this.scoreManager.ScoreAdd(Common.JUDGE.PERFECT);
                    this.comboManager.AddCombo();
                    this.SEManager.Play(2);
                }

                notesManager.DestroyNote(nearestNote);
                this.effectManager.GenerateEffect(nearestNote.type, nearestNote.lane);

                if (nearestNote.type == Common.NOTE.SLIDE_PRESS)
                {
                    nearestNote.slideLine.isPressing      = true;
                    nearestNote.slideLine.effectTransform = this.effectManager.GenerateSlideEffect(nearestNote.lane).GetComponent <RectTransform>();
                    this.SEManager.PlayLoop(3);

                    AimedRelease aim = new AimedRelease();
                    aim.pointerId = pointerId;
                    foreach (NoteData aimNote in this.notesManager.notes)
                    {
                        if (aimNote.index == nearestNote.chainBehind)
                        {
                            aim.note = aimNote;
                            Debug.Log(this.name + ": aim lane=" + aim.note.lane + " id=" + aim.pointerId);
                            break;
                        }
                    }
                    this.aimedRelease.Add(aim);
                }
                else if (nearestNote.type == Common.NOTE.SLIDE_RELEASE || nearestNote.type == Common.NOTE.FLICK)
                {
                    this.SEManager.StopLoop();

                    foreach (AimedRelease aim in this.aimedRelease)
                    {
                        if (aim.pointerId != pointerId)
                        {
                            continue;
                        }
                        this.aimedRelease.Remove(aim);
                        Debug.Log(this.name + ": aimRelease lane=" + aim.note.lane + " id=" + aim.pointerId);
                        return;
                    }
                }
            }
            else
            {
                if (eventTyoe == Common.EVENT.PRESS)
                {
                    //Debug.Log("pressed");
                    this.effectManager.GenerateEffect(Common.NOTE.NONE, trueLane);
                }

                if (eventTyoe == Common.EVENT.RELEASE && this.aimedRelease.Count != 0)
                {
                    foreach (AimedRelease aim in this.aimedRelease)
                    {
                        if (aim.pointerId != pointerId)
                        {
                            continue;
                        }
                        Debug.Log(this.name + ": aimDelete lane=" + aim.note.lane + " id=" + aim.pointerId);
                        this.notesManager.DestroyNote(aim.note);//
                        this.aimedRelease.Remove(aim);

                        //Debug.Log(this.name + ": Miss");
                        this.judgeDisplay.Launch(Common.JUDGE.MISS);
                        this.scoreManager.ScoreAdd(Common.JUDGE.MISS);
                        this.hpManager.Damage(Common.JUDGE.MISS);
                        this.SEManager.Play(0);
                        this.SEManager.StopLoop();
                        this.comboManager.LoseCombo();
                        return;
                    }
                }
            }
        }