예제 #1
0
    void hideAll()
    {
        foreach (GameObject animalObj in animals)
        {
            MAAnimal animalScript = animalObj.GetComponent <MAAnimal>();
            animalScript.onlyEyes();
        }

        isTouchEnabled = true;
    }
예제 #2
0
    void nextQuestion()
    {
        attempts = 0;
        corrects = 0;

        dataManager.fetchNextQuestionData();
        totalSlots = dataManager.currentSlots;

        ArrayList animalsForLevel = new ArrayList();

        foreach (Hashtable animalStr in availableAnimals)
        {
            animalsForLevel.Add(animalStr);
        }
        animalsForLevel = MAConstants.ShuffleList(animalsForLevel);

        int animalRequired = totalSlots / 2;

        while (animalsForLevel.Count > animalRequired)
        {
            animalsForLevel.RemoveAt(0);
        }

        ArrayList tempAnimals = new ArrayList();

        string    slotStr          = string.Format("{0}", totalSlots);
        Hashtable currentPositions = (Hashtable)allPositions[slotStr];


        foreach (Hashtable animalData in animalsForLevel)
        {
            for (int i = 0; i < 2; i++)              //create two of every kind
            {
                GameObject animalObj    = Instantiate(Resources.Load("JWMemoryAnimals/Prefabs/Animal")) as GameObject;
                MAAnimal   animalScript = animalObj.GetComponent <MAAnimal>();
                animalScript.setAnimal(animalData);
                animalObj.transform.parent = allAnimalsObj.transform;
                tempAnimals.Add(animalObj);
            }
        }

        animals = MAConstants.ShuffleList(tempAnimals);

        foreach (GameObject animalObj in animals)
        {
            string    indexStr = string.Format("{0}", animals.IndexOf(animalObj));
            Hashtable pos      = (Hashtable)currentPositions[indexStr];
            Vector3   position = new Vector3(MAConstants.GetAsFloat(pos["x"]), MAConstants.GetAsFloat(pos["y"]));
            animalObj.transform.localPosition = position;
        }

        Invoke("hideAll", 1.0f);
    }
예제 #3
0
    void FingerGestures_OnFingerTap(int fingerIndex, Vector2 fingerPos, int tapCount)
    {
        if (!isTouchEnabled)
        {
            return;
        }

        GameObject selection = PickObject(fingerPos);

        if (selection.name.Equals(ickyModel.name))
        {
            ickyAnimations.animState = MAIckyAnimationState.giggle;
            return;
        }

        if (isAnimal(selection))
        {
            if (currentSelection == null)
            {
                currentSelection = selection;

                MAAnimal selectionScript = currentSelection.GetComponent <MAAnimal>();
                selectionScript.onlyBody();
            }
            else if (currentSelection != selection)
            {
                if (currentSelection.name.Equals(selection.name))
                {
                    //correct

                    corrects++;
                    attempts++;

                    MAAnimal curSelectionScript = currentSelection.GetComponent <MAAnimal>();
                    curSelectionScript.yesAnimation();

                    MAAnimal selectionScript = selection.GetComponent <MAAnimal>();
                    selectionScript.yesAnimation();

                    isTouchEnabled = false;

                    tempSelections = new ArrayList();
                    tempSelections.Add(selection);
                    tempSelections.Add(currentSelection);

                    Invoke("correctGuess", 1.0f);
                }
                else
                {
                    //incorrect

                    attempts++;

                    ickyAnimations.animState = MAIckyAnimationState.wrong;

                    MAAnimal curSelectionScript = currentSelection.GetComponent <MAAnimal>();
                    curSelectionScript.onlyBody();

                    MAAnimal selectionScript = selection.GetComponent <MAAnimal>();
                    selectionScript.onlyBody();

                    isTouchEnabled = false;
                    Invoke("hideAll", 0.5f);
                    currentSelection = null;
                }
            }
        }
    }