Example #1
0
    void OnCategoryDrag(ShapeAnalyzeCategoryWidget widget, PointerEventData eventData)
    {
        //check if widget is within category panel
        bool isInCategoryPanel = IsInCategoryPanel(widget.dragRoot);

        categoryHighlightGO.SetActive(isInCategoryPanel);
    }
Example #2
0
    void OnCategoryDragCancel(ShapeAnalyzeCategoryWidget widget)
    {
        categoryHighlightGO.SetActive(false);

        if (mDragInstructTarget == widget)
        {
            ApplyDragInstruct();
        }
    }
Example #3
0
    void OnCategoryDragEnd(ShapeAnalyzeCategoryWidget widget, PointerEventData eventData)
    {
        categoryHighlightGO.SetActive(false);

        bool isInCategoryPanel = IsInCategoryPanel(widget.dragRoot);

        if (isInCategoryPanel)
        {
            //add to placed
            if (!mShapeCategoryWidgetActivePlaced.Exists(widget))
            {
                mShapeCategoryWidgetActivePicks.Remove(widget);

                widget.transform.SetParent(categoryContainer, false);

                mShapeCategoryWidgetActivePlaced.Add(widget);

                //show next if first time
                if (mShapeCategoryWidgetActivePlaced.Count == 1)
                {
                    if (!nextBase.gameObject.activeSelf || !nextBase.isEntering)
                    {
                        CancelRout();
                        nextBase.gameObject.SetActive(true);
                        nextBase.PlayEnter();
                    }
                }
            }
        }
        else
        {
            //add to picks
            if (!mShapeCategoryWidgetActivePicks.Exists(widget))
            {
                mShapeCategoryWidgetActivePlaced.Remove(widget);

                widget.transform.SetParent(categoryPickContainer, false);

                mShapeCategoryWidgetActivePicks.Add(widget);

                //hide next if no categories picked
                if (mShapeCategoryWidgetActivePlaced.Count == 0)
                {
                    if (nextBase.gameObject.activeSelf && !nextBase.isExiting)
                    {
                        CancelRout();
                        mRout = StartCoroutine(DoNextHide());
                    }
                }
            }
        }

        ApplyDragInstruct();
    }
Example #4
0
    void M8.IModalPush.Push(M8.GenericParams parms)
    {
        mShapeUseSolid       = false;
        mMeasureDisplayFlags = MeasureDisplayFlag.None;
        mShapeProfile        = null;

        mIsDragInstruct = false;

        bool showHierarchy = false;

        mShapeCategories.Clear();
        mShapeAttributes.Clear();

        //clear placements
        ClearCategoryPicks();
        ClearMeasureDisplays();
        ClearCategoryPlaced();

        ShapeCategoryData[] shapes = null;

        if (parms != null)
        {
            if (parms.ContainsKey(parmUseSolid))
            {
                mShapeUseSolid = parms.GetValue <bool>(parmUseSolid);
            }

            if (parms.ContainsKey(parmMeasureDisplayFlags))
            {
                mMeasureDisplayFlags = parms.GetValue <MeasureDisplayFlag>(parmMeasureDisplayFlags);
            }

            if (!mIsDragInstructApplied)  //only show drag instruction once
            {
                if (parms.ContainsKey(parmIsDragInstruct))
                {
                    mIsDragInstruct = parms.GetValue <bool>(parmIsDragInstruct);
                }
            }

            if (parms.ContainsKey(parmShapeProfile))
            {
                mShapeProfile = parms.GetValue <ShapeProfile>(parmShapeProfile);
            }

            if (parms.ContainsKey(parmShapes))
            {
                shapes = parms.GetValue <ShapeCategoryData[]>(parmShapes);
            }

            if (parms.ContainsKey(parmShowHierarchy))
            {
                showHierarchy = parms.GetValue <bool>(parmShowHierarchy);
            }
        }

        //determine which categories fit the shape profile
        if (mShapeProfile != null && shapes != null)
        {
            for (int i = 0; i < shapes.Length; i++)
            {
                if (shapes[i].Evaluate(mShapeProfile))
                {
                    mShapeCategories.Add(shapes[i]);
                }
            }
        }

        //generate categories
        if (shapes != null)
        {
            for (int i = 0; i < shapes.Length; i++)
            {
                var category = shapes[i];

                //add category to pick area
                if (mShapeCategoryWidgetCache.Count > 0)
                {
                    var widget = mShapeCategoryWidgetCache.RemoveLast();

                    widget.Setup(category);
                    widget.isDragEnabled = true;

                    widget.transform.SetParent(categoryPickContainer, false);

                    mShapeCategoryWidgetActivePicks.Add(widget);

                    //pick a target for drag instruct
                    if (mIsDragInstruct && !mDragInstructTarget)
                    {
                        if (mShapeCategories.Exists(category))
                        {
                            mDragInstructTarget = widget;
                        }
                    }
                }
            }
        }

        //fill up attributes
        for (int i = 0; i < mShapeCategories.Count; i++)
        {
            var category = mShapeCategories[i];

            for (int j = 0; j < category.attributes.Length; j++)
            {
                var attr = category.attributes[j];

                if (!mShapeAttributes.Exists(attr))
                {
                    mShapeAttributes.Add(attr);
                }
            }
        }

        //generate description
        mDescStrBuff.Clear();

        for (int i = 0; i < mShapeAttributes.Count; i++)
        {
            var attr = mShapeAttributes[i];

            mDescStrBuff.Append("ยท ");
            mDescStrBuff.Append(M8.Localize.Get(attr.textRef));

            if (i < mShapeAttributes.Count - 1)
            {
                mDescStrBuff.Append('\n');
            }
        }

        descText.text = mDescStrBuff.ToString();

        DefaultActiveDisplay();

        ApplyShape();

        categoryPickBase.gameObject.SetActive(true);
        categoryPickBase.PlayEnter();

        hierarchyGO.SetActive(showHierarchy);

        mCurMode = Mode.PickCategories;

        M8.SoundPlaylist.instance.Play(sfxEnter, false);
    }