Exemple #1
0
    void FingerGestures_OnFingerTap(int fingerIndex, Vector2 fingerPos, int tapCount)
    {
//		Debug.Log( "tapping");
        if (!touchEnabled)
        {
            return;
        }

        CancelInvoke("noInteraction");
        Invoke("noInteraction", BWConstants.idleTime);

        GameObject selection = PickObject(fingerPos);

        if (isSelectionFlower(selection))
        {
            playSoundEffect("Bee_flowertap_new_01");

            BWFlower flowerObj = selection.GetComponent <BWFlower>();

            attempts++;

            if (flowerObj.getFlowerNumber() == numberToFind)
            {
                AGGameState.incrementStarCount();

                CancelInvoke("noInteraction");
                touchEnabled = false;
                flowerObj.setSelected();
                beeToFlower(numberToFind);
                gameState = BWGameState.BWGameStateGuessed;
                //nextQuestion();
            }
            else
            {
                flowerObj.setSelected();
                playWrongSound(flowerObj.getFlowerNumber());
                BWBee beeObj = bee.GetComponent <BWBee>();
                beeObj.playNoAnimation();
            }
        }
        else
        {
            BWBee beeObj = bee.GetComponent <BWBee>();

            if (selection == beeObj.body || selection == bubbleNumber)
            {
                voiceOverSource.clip = null;
                voiceOverSource.Stop();

                currentClips = new List <AudioClip>();
                playInstructionSound();

                beeObj.playTapAnimation();
            }
        }
    }
    public void correctGuess()
    {
        foreach (GameObject anim in tempSelections)
        {
            animals.Remove(anim);
            Destroy(anim);
        }

        if (animals.Count == 0)
        {
            AGGameState.incrementStarCount();

            ickyAnimations.animState = MAIckyAnimationState.celebration;

            Invoke("celebrationAnimationFinished", 53F / 30F);
            return;
        }

        isTouchEnabled   = true;
        currentSelection = null;
        tempSelections   = null;
    }
Exemple #3
0
    // ----- Decide if tapped/dragged shape is correct?, play respective animations and decide to load next question or next level?

    private void decideForTappedDraggedShape(GameObject selection)
    {
        //Debug.Log("Decide for dragged shape");
        ArrayList responseList = new ArrayList();
        bool      allShapesOnCurrentScreenPlayed;


        if (selection != null)
        {
            //isUserPlayedTheQuestion = true;
            totalAttempts++;
            shapeStatController = selection.GetComponent <PG_ShapeStatController>();

            if (shapeStatController != null && shapeStatController.getAnswerShape())
            {
                hideShadow(selection);
                jumpCount++;
                if (jumpCount == 1)
                {
                    shapeStatController.isFirstShape = true;
                }
                else
                {
                    shapeStatController.isFirstShape = false;
                }
                cross_tick_sign.transform.renderer.material.mainTexture = Resources.Load(PG_Constants._correctTick) as Texture;
                cross_tick_sign.transform.renderer.enabled = true;
                enableTouchesFlag = false;

                totalCorrects++;
                shapesTappedIndex++;
                if (gameMode == (int)GameModes.mode_counting)
                {
                    responseList = islandControllerSR.ReplaceEmptyLandMassesWithFilledOne(shapesControllerSR.getQSpriteIndices().Count);
                }
                else
                {
                    responseList = islandControllerSR.ReplaceEmptyLandMassesWithFilledOne(pgDataManager.getAnswersListCount());
                }

                if (responseList.Count >= 2)
                {
                    allShapesOnCurrentScreenPlayed = (bool)responseList[1];
                }
                else
                {
                    allShapesOnCurrentScreenPlayed = false;
                }
                //shapesControllerSR.shapeCorrectTapAnimation(selection,(GameObject)responseList[0]);

                shapeStatController.isLastShape = allShapesOnCurrentScreenPlayed;
                shapeStatController.shapeCorrectTapAnimation((GameObject)responseList[0]);


                StartCoroutine(hideReferentBubble(0.2F));
                if (allShapesOnCurrentScreenPlayed)
                {
                    AGGameState.incrementStarCount();              // increment stars
                    enableTouchesFlag = false;
                    StartCoroutine(ollyPondCrossAnimation(1.8F));
                }
            }
        }

        isUserPlayedTheQuestion = false;
    }
Exemple #4
0
    void FingerGestures_OnFingerDragEnd(int fingerIndex, Vector2 fingerPos)
    {
        if (!touchEnabled)
        {
            return;
        }

        CancelInvoke("noInteraction");
        Invoke("noInteraction", BWConstants.idleTime);


        if (fingerIndex == dragFingerIndex)
        {
            dragFingerIndex = -1;
            isDragging      = false;


            if (isSwiping)
            {
                //Swiping

                isSwiping = false;

                GameObject selection = PickObject(fingerPos);

                if (selection != null && (selection.name.StartsWith("Flower") || selection.name.StartsWith("Hive")))
                {
                    BWFlower flowerObj = selection.GetComponent <BWFlower>();
                    if (expectedNumbers.Count > 0 && flowerObj.getFlowerNumber() == (int)expectedNumbers[0] && swipingWentOut)
                    {
                        beeToFlower((int)expectedNumbers[0]);
                        expectedNumbers.RemoveAt(0);
                        addTracingLine(prevFlower, selection);
                        prevFlower = selection;
                    }
                    else if (expectedNumbers.Count == 0 && swipingWentOut)
                    {
                        incorrectSwipingBeyondTarget(prevFlower, selection);
                    }
                }
            }

            if (expectedNumbers.Count == 0)
            {
                if (currentAnswer == true)
                {
                    prevFlower = null;

                    CancelInvoke("noInteraction");

                    AGGameState.incrementStarCount();

                    attempts++;
                    playSucess();
                    BWBee beeObj = bee.GetComponent <BWBee>();
                    beeObj.playYesAnimation();

                    if (dataManager.calculateResult(attempts, 1))
                    {
                        beeObj.shouldPlayCelebration = true;
                        dataManager.fetchLevelData();
                    }
                    touchEnabled = false;

                    BWFlowersLayer layerObj  = flowersLayer.GetComponent <BWFlowersLayer>();
                    GameObject     flower    = layerObj.flowerWithNumber(beeStartingPoint + numberToFind);
                    BWFlower       flowerObj = flower.GetComponent <BWFlower>();
                    flowerObj.setPollinated();
                }
                else
                {
                    touchEnabled = false;
                    attempts++;
                    playWrongSound(0);
                    BWBee beeObj = bee.GetComponent <BWBee>();
                    beeObj.playNoAnimation();
                    prevFlower = null;

                    CancelInvoke("noInteraction");
                    Invoke("noInteraction", BWConstants.idleTime + 5.0f);
                }
            }
            else
            {
                if (prevFlower != null)
                {
                    BWFlower flowerObj   = prevFlower.GetComponent <BWFlower>();
                    int      newStarting = flowerObj.getFlowerNumber();
                    setExpectedNumbers(newStarting, numberToFind - (newStarting - beeStartingPoint));
                }
            }
        }

        if (prevFlower != null)
        {
            CancelInvoke("deduceResult");
            Invoke("deduceResult", 3.0f);
        }
    }
    public void loadNextQuestion(float timeToLoad)
    {
        float restartLevelTime = 0;

        //restartLevelTime= timeToLoad;
        Debug.Log("Load Next Question");
        int questionAttempts = 0;
        int wrongAttempts    = 0;


        if (isResetInProgress)
        {
            inputController.isTouchEnabled = false;
            return;
        }
        isResetInProgress = true;
        questionAttempts  = inputController.qAttemptsCount();
        wrongAttempts     = inputController.wrongAttempts;
        if (questionAttempts > 0)
        {
#if (MAC_PLATFORM)
            AGGameState.incrementStarCount();
            if (AGGameState.currentGameIndex == (int)AGGameIndex.k_NamingFruits)
            {
                if (dataManager.currentLevel == 17 || dataManager.currentLevel == 8)
                {
                    dataManager.currentLevel = 1;
                }
                else
                {
                    dataManager.currentLevel++;
                }
            }
            else if (AGGameState.currentGameIndex == (int)AGGameIndex.k_2DShapesColors)
            {
                if (dataManager.currentLevel == 17 || dataManager.currentLevel == 20)
                {
                    dataManager.currentLevel = 1;
                }
                else
                {
                    dataManager.currentLevel++;
                }
            }

            if (wrongAttempts >= 5)
            {
                restartLevelTime = 1.5f;
            }
            else if (wrongAttempts < 5)
            {
                inputController.setCelebrationStatus(true);
                restartLevelTime = 3.0f;
            }
            dataManager.fetchLevelData();
            questionAttempts = 0;
            wrongAttempts    = 0;
            CancelInvoke("createOllyModel");
            Invoke("resetAllLevelState", restartLevelTime);
#else
            AGGameState.incrementStarCount();
            bool isLevelDone = dataManager.calculateResult(questionAttempts, answersListCount);
            if (isLevelDone)
            {
                restartLevelTime = 3.0f;
                inputController.setCelebrationStatus(true);
                dataManager.fetchLevelData();
            }
            else if (!isLevelDone)
            {
                if (wrongAttempts == 5)
                {
                    restartLevelTime = 1.25f;
                }
                else
                {
                    restartLevelTime = 2.0f;
                }
            }

            wrongAttempts    = 0;
            questionAttempts = 0;
            CancelInvoke("createOllyModel");
            Invoke("resetAllLevelState", restartLevelTime);
#endif
        }
    }