Exemplo n.º 1
0
    public void beeMoveFinished()
    {
        if (gameState == BWGameState.BWGameStateGuessed)
        {
            BWBee beeObj = bee.GetComponent <BWBee>();
            beeObj.playYesAnimation();

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

            playSucess();

            BWFlowersLayer layerObj  = flowersLayer.GetComponent <BWFlowersLayer>();
            GameObject     flower    = layerObj.flowerWithNumber(numberToFind);
            BWFlower       flowerObj = flower.GetComponent <BWFlower>();
            flowerObj.setPollinated();
        }
    }
Exemplo n.º 2
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);
        }
    }