Example #1
0
        //Do some stuff after all the target's references have been filled in by the timeline.
        public void Init()
        {
            gridTargetIcon.OnTryRemoveEvent     += DeleteNote;
            timelineTargetIcon.OnTryRemoveEvent += DeleteNote;

            gridTargetIcon.IconEnterLoadedNotesEvent += TargetEnterLoadedNotes;
            gridTargetIcon.IconExitLoadedNotesEvent  += TargetExitLoadedNotes;

            timelineTargetIcon.TrySelectEvent += MakeTimelineSelectTarget;
            gridTargetIcon.TrySelectEvent     += MakeTimelineSelectTarget;

            timelineTargetIcon.TryDeselectEvent += MakeTimelineDeselectTarget;
            gridTargetIcon.TryDeselectEvent     += MakeTimelineDeselectTarget;

            SetOutlineColor(NRSettings.config.selectedHighlightColor);

            if (data.behavior == TargetBehavior.Hold)
            {
                var gridHoldTargetManager = gridTargetIcon.GetComponentInChildren <HoldTargetManager>();

                gridHoldTargetManager.sustainLength = data.beatLength;
                gridHoldTargetManager.LoadSustainController();

                gridHoldTargetManager.OnTryChangeSustainEvent += MakeTimelineUpdateSustainLength;
            }
        }
Example #2
0
        private void OnGridPositionChanged(float x, float y)
        {
            var pos = gridTargetIcon.transform.localPosition;

            pos.x = x;
            pos.y = y;
            gridTargetIcon.transform.localPosition = pos;

            if (data.behavior == TargetBehavior.Hold)
            {
                var holdEnd = gridTargetIcon.GetComponentInChildren <HoldTargetManager>().endMarker;
                if (holdEnd)
                {
                    holdEnd.transform.localPosition = new Vector3(x, y, holdEnd.transform.localPosition.z);
                }
            }

            if (data.behavior == TargetBehavior.NR_Pathbuilder && data.pathBuilderData.generatedNotes.Count > 0)
            {
                var firstNote = data.pathBuilderData.generatedNotes[0];
                var delta     = firstNote.position - new Vector2(x, y);

                foreach (TargetData note in data.pathBuilderData.generatedNotes)
                {
                    note.position -= delta;
                }

                gridTargetIcon.UpdatePath();
            }
        }
Example #3
0
        private void OnBehaviorChanged(TargetBehavior oldBehavior, TargetBehavior newBehavior)
        {
            if (data.supportsBeatLength)
            {
                if (!TargetData.BehaviorSupportsBeatLength(oldBehavior))
                {
                    var gridHoldTargetManager = gridTargetIcon.GetComponentInChildren <HoldTargetManager>();

                    if (gridHoldTargetManager != null)
                    {
                        gridHoldTargetManager.sustainLength = data.beatLength;
                        gridHoldTargetManager.LoadSustainController();

                        gridHoldTargetManager.OnTryChangeSustainEvent += MakeTimelineUpdateSustainLength;
                    }
                }

                gridTargetIcon.UpdatePath();
            }
            else
            {
                DisableSustainButtons();

                if (TargetData.BehaviorSupportsBeatLength(oldBehavior))
                {
                    var gridHoldTargetManager = gridTargetIcon.GetComponentInChildren <HoldTargetManager>(true);
                    if (gridHoldTargetManager != null)
                    {
                        gridHoldTargetManager.UnloadSustainController();
                        gridHoldTargetManager.OnTryChangeSustainEvent -= MakeTimelineUpdateSustainLength;
                    }
                }
            }

            if (data.behavior == TargetBehavior.NR_Pathbuilder)
            {
                data.pathBuilderData.InitialAngleChangedEvent += UpdatePathInitialAngle;
                data.pathBuilderData.RecalculateEvent         += RecalculatePathbuilderData;
                data.pathBuilderData.RecalculateFinishedEvent += UpdatePath;
            }

            if (oldBehavior == TargetBehavior.NR_Pathbuilder)
            {
                data.pathBuilderData.InitialAngleChangedEvent -= UpdatePathInitialAngle;
                data.pathBuilderData.RecalculateEvent         -= RecalculatePathbuilderData;
                data.pathBuilderData.RecalculateFinishedEvent -= UpdatePath;
            }

            if (data.behavior != TargetBehavior.NR_Pathbuilder && oldBehavior == TargetBehavior.NR_Pathbuilder)
            {
                data.pathBuilderData.parentNotes.Remove(data);
            }
            else if (data.behavior == TargetBehavior.NR_Pathbuilder)
            {
                data.pathBuilderData.parentNotes.Add(data);
            }
        }