コード例 #1
0
    private void OnTriggerEnter(Collider other)
    {
        if (other.tag == UtilSort.SORTING_ELEMENT_TAG)
        {
            BucketSortElement sortingElement = other.GetComponent <BucketSortElement>();

            // Check for bug(same sorting element got added twice)
            //if (prevSortingElementID == sortingElement.SortingElementID)
            //    return;

            if (enterTrigger.enabled)
            {
                if (parent.SortSettings.IsDemo())
                {
                    if (ValidateSortingElement(sortingElement)) // !displayElements &&
                    {
                        // Do animation (color -> green -> color)
                        AddSortingElementToBucket(sortingElement);
                        prevSortingElementID = sortingElement.SortingElementID;
                    }
                    else
                    {
                        // Can't be put into this bucket
                        StartCoroutine(Animation(ERROR, 2));
                    }
                }
                else // User test
                {
                    if (sortingElement.Instruction is BucketSortInstruction)
                    {
                        BucketSortInstruction inst = (BucketSortInstruction)sortingElement.Instruction;

                        if (instruction == sortingElement.Instruction && instruction.Instruction == UtilSort.MOVE_TO_BUCKET_INST) // inst.Instruction == UtilSort.MOVE_TO_BUCKET_INST && inst.BucketID == bucketID
                        {
                            AddSortingElementToBucket(sortingElement);
                            prevSortingElementID = sortingElement.SortingElementID;

                            // Score
                            parent.GetComponent <UserTestManager>().IncrementTotalCorrect();

                            // Progress user test
                            parent.GetComponent <UserTestManager>().ReadyForNext += 1;
                        }
                        else if (ValidateSortingElement(sortingElement))
                        {
                        }
                        else
                        {
                            // Can't be put into this bucket
                            StartCoroutine(Animation(ERROR, 2));
                            parent.GetComponent <UserTestManager>().Mistake();
                        }
                    }
                }
            }
            else if (onTopOfBucketTrigger.enabled)
            {
            }
        }
    }
コード例 #2
0
    // --------------------------------------- User test validation ---------------------------------------

    public void PerformUserMove(HolderBase holder)
    {
        // Check if the user moved the element to a new holder,         TODO: in case of mistake -> avoid new error when fixing the mistake
        if (holder.HolderID != prevHolderID)
        {
            //CurrentStandingOn = holder; // already set
            userMove++;
            holder.HasPermission = true;

            if (validatedUserMove < userMove)
            {
                string validation = IsCorrectlyPlaced();
                switch (validation)
                {
                case Util.INIT_OK:
                    standingInCorrectHolder = true;
                    break;

                case UtilSort.CORRECT_HOLDER:
                case UtilSort.CORRECT_BUCKET:
                    standingInCorrectHolder = true;
                    break;

                case Util.INIT_ERROR:
                case UtilSort.WRONG_HOLDER:
                case UtilSort.WRONG_BUCKET:
                    standingInCorrectHolder = false;
                    parent.GetComponent <UserTestManager>().Mistake();
                    break;

                default: Debug.Log("Add '" + validation + "' case, or ignore"); break;
                }

                // Mark instruction as executed if correct
                if (standingInCorrectHolder && !IntermediateMove)
                {
                    Instruction.Status = Util.EXECUTED_INST;
                    status             = Util.EXECUTED_INST;

                    // Check if ready for next round
                    if (NextMove)
                    {
                        parent.GetComponent <UserTestManager>().IncrementTotalCorrect();
                        parent.GetComponent <UserTestManager>().ReadyForNext += 1;
                        NextMove = false;
                    }
                }

                validatedUserMove++;
                elementInteraction.PickedUp = false; // Reset (comparison pick up added)
            }
        }
        else
        {
            CurrentStandingOn = holder; // Back to the same
        }
        //standingInCorrectHolder = true;
    }