Esempio n. 1
0
        /// <summary>
        /// INPUT_VALUE: mTargetBlockView
        /// NEXT_STATEMENT: the last block view of the target statement block views chain
        /// </summary>
        public BlockView GetChildLastBlockView()
        {
            if (ConnectionType == Define.EConnection.InputValue)
            {
                return(mTargetBlockView);
            }

            BlockView nextView = mTargetBlockView;

            while (nextView != null)
            {
                ConnectionView nextCon = nextView.GetConnectionView(Define.EConnection.NextStatement);
                if (nextCon == null)
                {
                    break;
                }
                nextView = nextCon.TargetBlockView;
            }
            return(nextView);
        }
Esempio n. 2
0
        protected override Vector2 CalculateSize()
        {
            switch (m_ConnectionInputViewType)
            {
            case ConnectionInputViewType.Value:
            {
                //width is not concerned
                Vector2 size = new Vector2(BlockViewSettings.Get().ValueConnectPointRect.width, 0);
                if (mTargetBlockView == null)
                {
                    size.y = BlockViewSettings.Get().ContentHeight;
                }
                else
                {
                    size.y = mTargetBlockView.Height;
                }
                return(size);
            }

            case ConnectionInputViewType.ValueSlot:
            {
                if (mTargetBlockView == null)
                {
                    return(new Vector2(BlockViewSettings.Get().MinUnitWidth, BlockViewSettings.Get().ContentHeight));
                }
                Vector2 size = new Vector2(BlockViewSettings.Get().ValueConnectPointRect.width + mTargetBlockView.Width, mTargetBlockView.Height);
                return(size);
            }

            case ConnectionInputViewType.Statement:
            {
                if (mTargetBlockView == null)
                {
                    return(new Vector2(70, BlockViewSettings.Get().ContentHeight + BlockViewSettings.Get().ContentMargin.bottom));
                }

                // calculate the height by adding all child statement blocks' height
                Vector2 size = new Vector2(70, 0);

                bool      addConnectPointSpace = true;
                BlockView nextView             = mTargetBlockView;
                while (nextView != null)
                {
                    size.y += nextView.Height;

                    ConnectionView nextCon = nextView.GetConnectionView(Define.EConnection.NextStatement);
                    if (nextCon == null)
                    {
                        addConnectPointSpace = false;
                        break;
                    }

                    nextView = nextCon.TargetBlockView;
                }
                if (addConnectPointSpace)
                {
                    size.y += BlockViewSettings.Get().StatementConnectPointRect.height;
                }

                size.y += BlockViewSettings.Get().ContentMargin.bottom;
                return(size);
            }
            }
            return(Vector2.zero);
        }