示例#1
0
    void CleanupAndReset()
    {
        /*  for(int i=0; i< choiceInstances.Length; i++)
         * {
         *    Destroy(choiceInstances[i], 0.5f);
         * }*/


        Vector3[] destinations;
        animator.GetDestinations(out destinations);
        GameObject[] clickableObjects;
        animator.GetClickables(out clickableObjects);

        animator.ClearPreviousSelections();
        timeStamp  = Time.time;
        matchStage = MatchStages.Begin;
        isRunning  = false;

        /*  choiceInstances = new GameObject[destinations.Length];
         * matchOptions = new int[destinations.Length];*/

        /*   for (int i = 0; i < destinations.Length; i++)
         * {
         *     int option = matchOptions[i] ;
         *     Vector3 pos = destinations[i];
         *     pos.y += 1;
         *     GameObject archetype = clickableObjects[matchOptions[i]];
         *     choiceInstances[i] = Instantiate(archetype, pos, archetype.transform.rotation);
         *     //choiceInstances[i].transform.position = pos;
         *     //choiceInstances[i].transform.rotation =
         * }*/
    }
示例#2
0
    public void BeginPressed()
    {
        if (isRunning == true)
        {
            return;
        }

        if (startButton != null)
        {
            //startButton.GetComponent<GameObject>().SetActive(false);
            startButton.SetActive(false);
        }

        isRunning = true;
        ChooseRandomObjectsForPlacement();

        timeStamp  = Time.time;
        matchStage = MatchStages.Begin;
    }
示例#3
0
    // Update is called once per frame
    void Update()
    {
        if (isRunning)
        {
            switch (matchStage)
            {
            case MatchStages.Begin:
            {
                float timeElapsed = Time.time - timeStamp;
                if (timeElapsed > 1)
                {
                    matchStage = MatchStages.FlashingMode;
                    timeStamp  = subTimeStamp = Time.time;
                }
            }
            break;

            case MatchStages.FlashingMode:
            {
                if (Time.time - timeStamp > 1)
                {
                    matchStage = MatchStages.Hidden;
                    timeStamp  = subTimeStamp = Time.time;
                    ShowTheChoicesAboveTheBoxes(false);
                    // should be a transition state
                    animator.EnableAllClickables();
                }
                else
                {
                    int  subTime = (int)((Time.time - subTimeStamp) * 10.0f);
                    bool isOn    = (subTime % 2 != 0) ? true : false;
                    ShowTheChoicesAboveTheBoxes(isOn);
                }
            }
            break;

            case MatchStages.Hidden:
            {
                if (animator.GetChoicesMade().Count == 3)
                {
                    timeStamp  = Time.time;
                    matchStage = MatchStages.FinishAndCompare;
                    animator.EnableAllClickables(false);
                }
            }
            break;

            case MatchStages.FinishAndCompare:
            {
                if (Time.time - timeStamp > animator.timeToWaitForFruitAnim / 2)
                {
                    //ga.EnableAllClickables(false);
                    if (DoChoicesMatch() == true)
                    {
                        animator.PlaySuccessAnimation();
                        matchStage = MatchStages.NavigateToNextScene;
                        timeStamp  = subTimeStamp = Time.time;
                    }
                    else
                    {
                        animator.PlayFailureAnimation();
                        CleanupAndReset();
                        //animator.EnableAllClickables();
                        isRunning  = true;
                        matchStage = MatchStages.Begin;
                        timeStamp  = subTimeStamp = Time.time;
                    }
                }
            }
            break;

            case MatchStages.NavigateToNextScene:
            {
                if (Time.time - timeStamp > animator.timeToWaitForFruitAnim)
                {
                    nextScreenButton.SetActive(true);
                }
            }
            break;
            }
            //timeStamp
        }
    }