Example #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();
            }
        }
    }
Example #2
0
    public void deduceResult()
    {
        touchEnabled = false;
        attempts++;
        playWrongSound(0);
        BWBee beeObj = bee.GetComponent <BWBee>();

        beeObj.playNoAnimation();
        prevFlower = null;

        CancelInvoke("noInteraction");
        Invoke("noInteraction", BWConstants.idleTime + 5.0f);
    }
Example #3
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);
        }
    }