Esempio n. 1
0
        /// <summary>
        /// </summary>
        /// <param name="buttonTemplate"> </param>
        /// <param name="lineTemplate"> </param>
        /// <param name="pos"> </param>
        /// <param name="prevComponent"> </param>
        /// <param name="nextComponent"> </param>
        public CurveHandle(ButtonGenerator buttonTemplate, LineGenerator lineTemplate, Vector2 pos, Vector2 prevComponent, Vector2 nextComponent)
        {
            buttonTemplate = new ButtonGenerator("HullEditorHandle.json");
            buttonTemplate.Identifier = (int) HandleType.Center;
            buttonTemplate.X = pos.X;
            buttonTemplate.Y = pos.Y;

            _centerButton = buttonTemplate.GenerateButton();
            _centerButton.GetComponent<DraggableComponent>().DragMovementDispatcher += TranslateToLinks;
            _centerButton.GetComponent<DraggableComponent>().DragMovementClamp += ClampHandleMovement;

            buttonTemplate.Identifier = (int) HandleType.Prev;
            buttonTemplate.X = prevComponent.X + pos.X;
            buttonTemplate.Y = prevComponent.Y + pos.Y;
            _prevButton = buttonTemplate.GenerateButton();
            _prevButton.GetComponent<DraggableComponent>().DragMovementDispatcher += TranslateToLinks;
            _prevButton.GetComponent<DraggableComponent>().DragMovementClamp += ClampHandleMovement;

            buttonTemplate.Identifier = (int) HandleType.Next;
            buttonTemplate.X = nextComponent.X + pos.X;
            buttonTemplate.Y = nextComponent.Y + pos.Y;
            _nextButton = buttonTemplate.GenerateButton();
            _nextButton.GetComponent<DraggableComponent>().DragMovementDispatcher += TranslateToLinks;
            _nextButton.GetComponent<DraggableComponent>().DragMovementClamp += ClampHandleMovement;

            _prevLine = lineTemplate.GenerateLine();
            _nextLine = lineTemplate.GenerateLine();

            _prevLine.OriginPoint = _centerButton.CentPosition;
            _prevLine.DestPoint = _prevButton.CentPosition;

            _nextLine.OriginPoint = _centerButton.CentPosition;
            _nextLine.DestPoint = _nextButton.CentPosition;

            _nextButton.GetComponent<FadeComponent>().ForceFadeout();
            _prevButton.GetComponent<FadeComponent>().ForceFadeout();
            _centerButton.GetComponent<FadeComponent>().ForceFadeout();

            _prevLine.GetComponent<FadeComponent>().ForceFadeout();
            _nextLine.GetComponent<FadeComponent>().ForceFadeout();

            _nextButton.GetComponent<FadeComponent>().ForceFadeout();
            _prevButton.GetComponent<FadeComponent>().ForceFadeout();
            _centerButton.GetComponent<FadeComponent>().ForceFadeout();

            _prevLine.GetComponent<FadeComponent>().ForceFadeout();
            _nextLine.GetComponent<FadeComponent>().ForceFadeout();

            InterlinkButtonEvents();
        }