示例#1
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();
    }
示例#2
0
        void OnTriggerEnter2D(Collider2D other)
        {
            CleanUp();

            if (mUnits.IsFull)
            {
                Debug.LogWarning(name + ": Unit Capacity is full.");
                return;
            }

            if (UnitVerify(other) && !mUnits.Exists(other))
            {
                mUnits.Add(other);
                UnitAdded(other);
            }
        }
示例#3
0
    void OnTriggerEnter2D(Collider2D collision)
    {
        if (!string.IsNullOrEmpty(tagActionFilter) && !collision.CompareTag(tagActionFilter))
        {
            return;
        }

        var action = collision.GetComponent <PlayerAction>();

        if (action)
        {
            if (!mActInvokes.Exists(action))
            {
                mActInvokes.Add(action);
            }
        }
    }
示例#4
0
        void OnTriggerEnter2D(Collider2D other)
        {
            CleanUp();

            if (mUnits.IsFull)
            {
                Debug.LogWarning(name + ": Unit Capacity is full.");
                return;
            }

            if (ColliderVerify(other))
            {
                T unit = other.GetComponent <T>();
                if (unit != null && UnitVerify(unit) && !mUnits.Exists(unit))
                {
                    mUnits.Add(unit);
                    UnitAdded(unit);
                }
            }
        }
示例#5
0
        protected virtual void OnTriggerEnter2D(Collider2D col)
        {
            if (mForceFields.IsFull)
            {
                return;
            }

            if (fieldTagFilter.Length > 0)
            {
                bool isTagFound = false;
                for (int i = 0; i < fieldTagFilter.Length; i++)
                {
                    if (col.CompareTag(fieldTagFilter[i]))
                    {
                        isTagFound = true;
                        break;
                    }
                }

                if (!isTagFound)
                {
                    return;
                }
            }

            var forceField = col.GetComponent <ForceFieldBase2D>();

            if (!forceField)
            {
                return;
            }

            if (!mForceFields.Exists(forceField))
            {
                mForceFields.Add(forceField);
            }
        }
示例#6
0
    IEnumerator DoActive()
    {
        float curTime  = 0f;
        float duration = GameData.instance.bonusRoundDuration;

        mIsCorrect = false;

        while (curTime < duration)
        {
            yield return(null);

            //check slots
            int filledSlotCount  = 0;
            int correctSlotCount = 0;
            int moveCount        = 0;
            for (int i = 0; i < mItemActives.Count; i++)
            {
                var item = mItemActives[i];

                if (item.isMoving)
                {
                    moveCount++;
                }

                if (item.isSlotCorrect)
                {
                    correctSlotCount++;
                    filledSlotCount++;
                }
                else if (!mItemSlotActives.Exists(item.slotCurrent))
                {
                    filledSlotCount++;
                }
            }

            //all slots correctly filled?
            if (correctSlotCount == fillSlots.Length)
            {
                mIsCorrect = true;
                break;
            }
            //wait for item slots to finish moving
            else if (moveCount > 0)
            {
                continue;
            }
            //incorrectly filled?
            else if (filledSlotCount == fillSlots.Length)
            {
                //return all items
                for (int i = 0; i < mItemActives.Count; i++)
                {
                    var item = mItemActives[i];
                    item.RevertSlotToOrigin();
                }

                if (mIncorrectRout != null)
                {
                    StopCoroutine(mIncorrectRout);
                }
                mIncorrectRout = StartCoroutine(DoIncorrect());

                continue;
            }

            curTime += Time.deltaTime;

            float t = Mathf.Clamp01(curTime / duration);

            //update time display
            var timeSize = timeWidget.sizeDelta;
            timeSize.x           = mTimeDefaultWidth * (1f - t);
            timeWidget.sizeDelta = timeSize;

            var timeColor = M8.ColorUtil.Lerp(timeColors, t);

            if (t >= timeNearExpireScale)
            {
                var a = Mathf.Sin(Mathf.PI * curTime * timeNearExpirePulse);
                a          *= a;
                timeColor.a = a;
            }

            timeColorGroup.ApplyColor(timeColor);
            //
        }

        mRout = null;

        //cancel incorrect
        if (mIncorrectRout != null)
        {
            StopCoroutine(mIncorrectRout);
            mIncorrectRout = null;
        }

        incorrectGO.SetActive(false);

        LockItemInputs();

        //all correct?
        if (mIsCorrect)
        {
            if (!string.IsNullOrEmpty(soundCorrect))
            {
                M8.SoundPlaylist.instance.Play(soundCorrect, false);
            }

            //bonus achieved
            bonusScoreGO.SetActive(true);
        }
        else
        {
            if (!string.IsNullOrEmpty(soundIncorrect))
            {
                M8.SoundPlaylist.instance.Play(soundIncorrect, false);
            }

            //time expired
            timeExpireGO.SetActive(true);

            //move items to correct slots
            for (int i = 0; i < mItemActives.Count; i++)
            {
                var item = mItemActives[i];
                item.SetCurrentSlot(item.slotCorrect);
            }
        }

        finishGO.SetActive(true);
    }
示例#7
0
 public bool IsLogTypeAllowed(LogType logType)
 {
     return(mLogTypeFilters.Exists(logType));
 }
示例#8
0
    IEnumerator DoScore()
    {
        //lock inputs, enabled clicks on placed
        for (int i = 0; i < mShapeCategoryWidgetActivePicks.Count; i++)
        {
            mShapeCategoryWidgetActivePicks[i].isDragEnabled = false;
        }

        for (int i = 0; i < mShapeCategoryWidgetActivePlaced.Count; i++)
        {
            mShapeCategoryWidgetActivePlaced[i].isDragEnabled  = false;
            mShapeCategoryWidgetActivePlaced[i].isClickEnabled = true;
        }

        //hide next
        yield return(nextBase.PlayExitWait());

        nextBase.gameObject.SetActive(false);

        //hide pick category
        yield return(categoryPickBase.PlayExitWait());

        categoryPickBase.gameObject.SetActive(false);

        //clear out picks
        ClearCategoryPicks();

        //ClearMeasureDisplays();

        bool showCategoryDetailInstruct = false;

        int correctCount = 0;
        int wrongCount   = 0;

        var wait = new WaitForSeconds(evaluateDelay);

        mShapeCategoriesPlaced.Clear();

        //evaluate placed categories
        for (int i = 0; i < mShapeCategoryWidgetActivePlaced.Count; i++)
        {
            var widget   = mShapeCategoryWidgetActivePlaced[i];
            var category = widget.data;

            //check if matched
            if (mShapeCategories.Exists(category))
            {
                widget.correctGO.SetActive(true);
                correctCount++;

                mShapeCategoriesPlaced.Add(category);

                M8.SoundPlaylist.instance.Play(sfxCorrect, false);
            }
            else
            {
                widget.errorGO.SetActive(true);
                wrongCount++;

                M8.SoundPlaylist.instance.Play(sfxWrong, false);

                showCategoryDetailInstruct = true;
            }

            yield return(wait);
        }

        //add missed categories
        for (int i = 0; i < mShapeCategories.Count; i++)
        {
            var category = mShapeCategories[i];
            if (!mShapeCategoriesPlaced.Exists(category))
            {
                if (mShapeCategoryWidgetCache.Count > 0)
                {
                    var widget = mShapeCategoryWidgetCache.RemoveLast();

                    widget.Setup(category);
                    widget.isClickEnabled = true;
                    widget.missGO.SetActive(true);

                    widget.transform.SetParent(categoryContainer, false);

                    mShapeCategoryWidgetActivePlaced.Add(widget);

                    M8.SoundPlaylist.instance.Play(sfxMiss, false);

                    showCategoryDetailInstruct = true;

                    yield return(wait);
                }
            }
        }

        if (showCategoryDetailInstruct)
        {
            categoryInstructGO.SetActive(true);
        }

        //compute score
        float score = Mathf.Clamp01((float)correctCount / mShapeCategories.Count) * GameData.instance.scoreShape;

        score -= wrongCount * GameData.instance.scorePenalty;
        if (score < 0f)
        {
            score = 0f;
        }

        if (mShapeProfile)
        {
            mShapeProfile.score = Mathf.RoundToInt(score);

            scoreCounter.count = mShapeProfile.score;
        }

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

        //show score
        scoreBase.gameObject.SetActive(true);
        yield return(scoreBase.PlayEnterWait());

        //show next
        nextBase.gameObject.SetActive(true);
        nextBase.PlayEnter();

        mRout = null;
    }
示例#9
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);
    }
示例#10
0
 public bool IsGroupActive(Group grp)
 {
     return(mGroupActives.Exists(grp));
 }
示例#11
0
    void OnDetectTriggerEnter(Collider2D coll)
    {
        EntityCommon ent = coll.GetComponent <EntityCommon>();

        //make sure it's alive and is't already added
        if (ent.stats.isAlive && ent.stats.data.type == StatEntity.Type.Biological && !mTargetPotentialEntities.IsFull && !mTargetPotentialEntities.Exists(ent))
        {
            mTargetPotentialEntities.Add(ent);

            if (mLaunchRout == null)
            {
                mLaunchRout = StartCoroutine(DoLaunch());
            }
        }
    }