Exemplo n.º 1
0
    public void resetCurrentQuestion()
    {
        touchEnabled = true;
        flowersLayer.transform.position = new Vector3(BWConstants.flowersLayerMinX, -350, -200);

        BWFlowersLayer layer = flowersLayer.GetComponent <BWFlowersLayer>();

        layer.resetFlowersLayer();

        if ((numberLineMax - numberLineMin) > BWConstants.numbersOnScreen)
        {
            enableScrolling = true;
            xvel            = 0;
            lasty           = 0;
            direction       = BounceDirection.BounceDirectionStayingStill;
        }

        BWBee beeObj = bee.GetComponent <BWBee>();

        beeObj.flipBee(dataManager.shouldFlipBee);

        flowerLayerToInitialNumber(initialNumber);
        beeToFlower(beeStartingPoint);
        setExpectedNumbers(beeStartingPoint, numberToFind);
    }
Exemplo n.º 2
0
    public void nextQuestion()
    {
        gameState       = BWGameState.BWGameStateResetting;
        enableScrolling = false;

        if (attempts > 0)
        {
        }

        attempts = 0;
        dataManager.fetchNextQuestionData();

        numberLineMin = dataManager.numberLineMin;
        numberLineMax = dataManager.numberLineMax;
        initialNumber = dataManager.initialNumber;
        numberToFind  = dataManager.numberToFind;

        string numberimg = string.Format("BW_NumberLine/Sprites/Referent/Referant_numbers{0}", AGGameState.modInt(numberToFind));

        bubbleNumber.renderer.material.mainTexture = (Texture2D)Resources.Load(numberimg);

        if (numberToFind < 0)
        {
            bubbleSymbol.SetActive(true);
        }
        else
        {
            bubbleSymbol.SetActive(false);
        }
        //bubbleNumber.text = string.Format("{0}", numberToFind);

        //flowersLayer.transform.position = new Vector3(-640, -300, -200);

        BWFlowersLayer layer = flowersLayer.GetComponent <BWFlowersLayer>();

        layer.setFlowersLayer(numberLineMin, numberLineMax, initialNumber);

        if ((numberLineMax - numberLineMin) > 7)
        {
            enableScrolling = true;
            xvel            = 0;
            lasty           = 0;
            direction       = BounceDirection.BounceDirectionStayingStill;
        }

        flowerLayerToInitialNumber(initialNumber);

        beeToSky();

        touchEnabled = true;

        playInstructionSound();

        CancelInvoke("noInteraction");
        Invoke("noInteraction", BWConstants.idleTime + 5.0f);
    }
Exemplo n.º 3
0
        public void Bounce(BounceDirection direction)
        {
            _topDirection *= -1;
            switch (direction)
            {
            case BounceDirection.Middle:
                _leftDirection = 0;
                break;

            case BounceDirection.Right:
                _leftDirection = 1;
                break;

            case BounceDirection.Left:
                _leftDirection = -1;
                break;
            }
        }
Exemplo n.º 4
0
    private void updateScroll()
    {
        Vector3 pos = flowersLayer.transform.position;
        // positions for scrollLayer

        BWFlowersLayer layer = flowersLayer.GetComponent <BWFlowersLayer>();
        float          right = pos.x + layer.contentWidth;
        float          left  = pos.x;
        float          minX  = -640;
        float          maxX  = 640;

        float bounceTime = 0.2f;
        int   frameRate  = 60;

        if (!isDragging)
        {
            float friction = 0.96f;

            if (left > minX && direction != BounceDirection.BounceDirectionGoingLeft)
            {
                xvel      = 0;
                direction = BounceDirection.BounceDirectionGoingLeft;
            }
            else if (right < maxX && direction != BounceDirection.BounceDirectionGoingRight)
            {
                xvel      = 0;
                direction = BounceDirection.BounceDirectionGoingRight;
            }

            if (direction == BounceDirection.BounceDirectionGoingRight)
            {
                if (xvel >= 0)
                {
                    float delta          = (maxX - right);
                    float yDeltaPerFrame = (delta / (bounceTime * frameRate));
                    xvel = yDeltaPerFrame;
                }

                if ((right + 0.5f) == maxX)
                {
                    pos.x     = right - layer.contentWidth;
                    xvel      = 0;
                    direction = BounceDirection.BounceDirectionStayingStill;
                }
            }

            else if (direction == BounceDirection.BounceDirectionGoingLeft)
            {
                if (xvel <= 0)
                {
                    float delta          = (minX - left);
                    float yDeltaPerFrame = (delta / (bounceTime * frameRate));
                    xvel = yDeltaPerFrame;
                }

                if ((left + 0.5f) == minX)
                {
                    pos.x     = left;
                    xvel      = 0;
                    direction = BounceDirection.BounceDirectionStayingStill;
                }
            }
            else
            {
                xvel *= friction;
                //lasty = pos.x;
            }
            pos.x += xvel;

            backgroundLayer.moveBackground(pos.x - flowersLayer.transform.position.x);
            foregroundLayer.moveForeground(pos.x - flowersLayer.transform.position.x);
            flowersLayer.transform.position = pos;
        }
        else
        {
            if (left <= minX || right >= maxX)
            {
                direction = BounceDirection.BounceDirectionStayingStill;
            }

            if (direction == BounceDirection.BounceDirectionStayingStill)
            {
                xvel  = (pos.x - lasty) / 2;
                lasty = pos.x;
            }
        }
    }
Exemplo n.º 5
0
    private void updateScroll()
    {
        Vector3 pos = flowersLayer.transform.position;
        // positions for scrollLayer

        BWFlowersLayer layer =  flowersLayer.GetComponent<BWFlowersLayer>();
        float right = pos.x + layer.contentWidth;
        float left = pos.x;
        float minX = -640;
        float maxX = 640;

        float bounceTime = 0.2f;
        int frameRate = 60;

        if(!isDragging) {

            float friction = 0.96f;

            if(left > minX && direction != BounceDirection.BounceDirectionGoingLeft) {
                xvel = 0;
                direction = BounceDirection.BounceDirectionGoingLeft;
            }
            else if(right < maxX && direction != BounceDirection.BounceDirectionGoingRight)	{
                xvel = 0;
                direction = BounceDirection.BounceDirectionGoingRight;
            }

            if(direction == BounceDirection.BounceDirectionGoingRight) {
                if(xvel >= 0) {
                    float delta = (maxX - right);
                    float yDeltaPerFrame = (delta / (bounceTime * frameRate));
                    xvel = yDeltaPerFrame;
                }

                if((right + 0.5f) == maxX) {
                    pos.x = right -  layer.contentWidth;
                    xvel = 0;
                    direction = BounceDirection.BounceDirectionStayingStill;
                }
            }

            else if(direction == BounceDirection.BounceDirectionGoingLeft) {
                if(xvel <= 0) {
                    float delta = (minX - left);
                    float yDeltaPerFrame = (delta / (bounceTime * frameRate));
                    xvel = yDeltaPerFrame;
                }

                if((left + 0.5f) == minX) {
                    pos.x = left;
                    xvel = 0;
                    direction = BounceDirection.BounceDirectionStayingStill;
                }
            } else {

                xvel *= friction;
                //lasty = pos.x;
            }
            pos.x += xvel;

            backgroundLayer.moveBackground(pos.x - flowersLayer.transform.position.x);
            foregroundLayer.moveForeground(pos.x - flowersLayer.transform.position.x);
            flowersLayer.transform.position = pos;

        } else {
            if(left <= minX || right >= maxX) {
                direction = BounceDirection.BounceDirectionStayingStill;
            }

            if(direction == BounceDirection.BounceDirectionStayingStill) {
                xvel = (pos.x - lasty)/2;
                lasty = pos.x;
            }
        }
    }
Exemplo n.º 6
0
    public void nextQuestion()
    {
        gameState = BWGameState.BWGameStateResetting;
        enableScrolling = false;

        if(attempts > 0) {

        }

        attempts = 0;
        dataManager.fetchNextQuestionData();

        numberLineMin = dataManager.numberLineMin;
        numberLineMax = dataManager.numberLineMax;
        initialNumber = dataManager.initialNumber;
        numberToFind = dataManager.numberToFind;

        string numberimg = string.Format("BW_NumberLine/Sprites/Referent/Referant_numbers{0}", AGGameState.modInt(numberToFind));
        bubbleNumber.renderer.material.mainTexture = (Texture2D)Resources.Load(numberimg);

        if(numberToFind < 0) {
            bubbleSymbol.SetActive(true);
        } else {
            bubbleSymbol.SetActive(false);
        }
        //bubbleNumber.text = string.Format("{0}", numberToFind);

        //flowersLayer.transform.position = new Vector3(-640, -300, -200);

        BWFlowersLayer layer =  flowersLayer.GetComponent<BWFlowersLayer>();
        layer.setFlowersLayer(numberLineMin, numberLineMax, initialNumber);

        if ((numberLineMax - numberLineMin) > 7) {
            enableScrolling = true;
            xvel = 0;
            lasty = 0;
            direction = BounceDirection.BounceDirectionStayingStill;
        }

        flowerLayerToInitialNumber(initialNumber);

        beeToSky();

        touchEnabled = true;

        playInstructionSound();

        CancelInvoke("noInteraction");
        Invoke("noInteraction", BWConstants.idleTime + 5.0f);
    }
Exemplo n.º 7
0
    public void nextQuestion()
    {
        enableScrolling = false;
        isDragging      = false;
        isSwiping       = false;
        prevFlower      = null;

        if (attempts > 0)
        {
        }

        attempts = 0;
        dataManager.fetchNextQuestionData();

        numberLineMin    = dataManager.numberLineMin;
        numberLineMax    = dataManager.numberLineMax;
        initialNumber    = dataManager.initialNumber;
        numberToFind     = dataManager.numberToFind;
        beeStartingPoint = dataManager.beeStartingIndex;


        string numberimg = string.Format("BW_NumberLine/Sprites/Referent/Referant_numbers{0}", AGGameState.modInt(numberToFind));

        bubbleNumber.renderer.material.mainTexture = (Texture2D)Resources.Load(numberimg);

        if (numberToFind < 0)
        {
            bubbleSymbol.renderer.material.mainTexture = (Texture2D)Resources.Load("BW_NumberLine/Sprites/Referent/Referant_exporterminus");
        }
        else
        {
            bubbleSymbol.renderer.material.mainTexture = (Texture2D)Resources.Load("BW_NumberLine/Sprites/Referent/Referant_exporterPlus");
        }

        flowersLayer.transform.position = new Vector3(BWConstants.flowersLayerMinX, -350, -200);

        BWFlowersLayer layer = flowersLayer.GetComponent <BWFlowersLayer>();

        layer.setDiagonalFlowersLayer(numberLineMin, numberLineMax, initialNumber);

        if ((numberLineMax - numberLineMin) > BWConstants.numbersOnScreen)
        {
            enableScrolling = true;
            xvel            = 0;
            lasty           = 0;
            direction       = BounceDirection.BounceDirectionStayingStill;
        }

        BWBee beeObj = bee.GetComponent <BWBee>();

        beeObj.flipBee(dataManager.shouldFlipBee);

        flowerLayerToInitialNumber(initialNumber);
        beeToFlower(beeStartingPoint);
        setExpectedNumbers(beeStartingPoint, numberToFind);

        if (dataManager.currentLevel == 0)
        {
            Invoke("levelZeroTutorial", 3);
        }
        else
        {
            playInstructionSound();
        }

        CancelInvoke("noInteraction");
        Invoke("noInteraction", BWConstants.idleTime + 5.0f);

        touchEnabled = true;
    }
Exemplo n.º 8
0
    void FingerGestures_OnFingerDragMove(int fingerIndex, Vector2 fingerPos, Vector2 delta)
    {
        if (!touchEnabled)
        {
            return;
        }


        if (fingerIndex == dragFingerIndex)
        {
            //Scrolling
            if (isDragging)
            {
                if (enableTypeWriter)
                {
                    GameObject selection = PickObject(fingerPos);
                    if ((numberToFind > 0 && delta.x > 0) ||
                        (numberToFind < 0 && delta.x < 0) ||
                        (!isSelectionFlower(selection)))
                    {
                        xvel       = 0;
                        lasty      = 0;
                        direction  = BounceDirection.BounceDirectionStayingStill;
                        isDragging = false;
                        return;
                    }
                }

                // update the position by converting the current screen position of the finger to a world position on the Z = 0 plane
                Vector3 curPos = flowersLayer.transform.position;
                curPos.x += delta.x;

                float offset = (float)(Math.Tan(BWConstants.diagonalAngle)) * delta.x;
                curPos.y += offset;

                flowersLayer.transform.position = curPos;
                backgroundLayer.moveBackground(delta.x);
                foregroundLayer.moveForeground(delta.x);
            }
            else if (isSwiping)
            {
                //Swiping

                GameObject selection = PickObject(fingerPos);

                if (isSelectionFlower(selection))
                {
                    //checking for type writer scroll
                    if (prevFlower == selection)
                    {
                        if (flowerOnTheEdge(selection))
                        {
                            enableTypeWriter = true;
                            isDragging       = true;
                        }
                        else
                        {
                            enableTypeWriter = false;
                            isDragging       = false;
                        }
                    }                     //check for tracing lines
                    else
                    {
                        enableTypeWriter = false;
                        isDragging       = false;

                        BWFlower flowerObj = selection.GetComponent <BWFlower>();
                        if (expectedNumbers.Count > 0 && flowerObj.getFlowerNumber() == (int)expectedNumbers[0] && swipingWentOut)
                        {
                            playSoundEffect("Bee_flowertap_new_01");

                            beeToFlower((int)expectedNumbers[0]);
                            playNumberSound((int)expectedNumbers[0] - beeStartingPoint);

                            swipingWentOut = false;
                            expectedNumbers.RemoveAt(0);
                            addTracingLine(prevFlower, selection);
                            prevFlower = selection;
                        }
                        else if (expectedNumbers.Count == 0 && swipingWentOut)
                        {
                            playSoundEffect("Bee_flowertap_new_01");
                            incorrectSwipingBeyondTarget(prevFlower, selection);
                        }
                        else if (expectedNumbers.Count > 0 && swipingWentOut)
                        {
                            int rand = UnityEngine.Random.Range(2, 4);
                            playHintSound(rand);
                        }
                    }
                }
                else
                {
                    enableTypeWriter = false;
                    isDragging       = false;

                    //either the selection is null or selection is scrollcollider - so swiping went out
                    swipingWentOut = true;

                    //check for auto scroll
                    Vector3 curPosition = GetWorldPos(fingerPos);

                    if (numberToFind > 0 && curPosition.x > 560)
                    {
                        if (flowerOnTheEdge(prevFlower))
                        {
                            //auto scroll
                            BWFlower prevFlowerObj        = prevFlower.GetComponent <BWFlower>();
                            int      lastNumberRegistered = prevFlowerObj.getFlowerNumber();

                            if (lastNumberRegistered == dataManager.numberLineMax)
                            {
                                return;
                            }

                            int numberToScrollTo = lastNumberRegistered - 1;

                            if (numberToScrollTo < dataManager.numberLineMin)
                            {
                                numberToScrollTo = dataManager.numberLineMin;
                            }
                            if (numberToScrollTo + BWConstants.numbersOnScreen > dataManager.numberLineMax)
                            {
                                numberToScrollTo = dataManager.numberLineMax - BWConstants.numbersOnScreen;
                            }

                            Debug.Log("scroll to " + numberToScrollTo);
                            flowerLayerToInitialNumber(numberToScrollTo);
                        }
                    }
                    else if (numberToFind < 0 && curPosition.x < -560)
                    {
                        if (flowerOnTheEdge(prevFlower))
                        {
                            //auto scroll
                            BWFlower prevFlowerObj        = prevFlower.GetComponent <BWFlower>();
                            int      lastNumberRegistered = prevFlowerObj.getFlowerNumber();

                            if (lastNumberRegistered == dataManager.numberLineMin)
                            {
                                return;
                            }

                            int numberToScrollTo = lastNumberRegistered - 6;

                            if (numberToScrollTo < dataManager.numberLineMin)
                            {
                                numberToScrollTo = dataManager.numberLineMin;
                            }

                            if (numberToScrollTo + BWConstants.numbersOnScreen > dataManager.numberLineMax)
                            {
                                numberToScrollTo = dataManager.numberLineMax - BWConstants.numbersOnScreen;
                            }
                            Debug.Log("scroll to " + numberToScrollTo);
                            flowerLayerToInitialNumber(numberToScrollTo);
                        }
                    }
                }
            }
        }
    }
    void FingerGestures_OnFingerDragMove( int fingerIndex, Vector2 fingerPos, Vector2 delta )
    {
        if (!touchEnabled) return;

        if( fingerIndex == dragFingerIndex )
        {
            //Scrolling
            if(isDragging) {

                if(enableTypeWriter) {

                    GameObject selection = PickObject( fingerPos );
                    if((numberToFind > 0 && delta.x > 0) ||
                    (numberToFind < 0 && delta.x < 0) ||
                    (!isSelectionFlower(selection))) {

                        xvel = 0;
                        lasty = 0;
                        direction = BounceDirection.BounceDirectionStayingStill;
                        isDragging = false;
                        return;
                    }
                }

                // update the position by converting the current screen position of the finger to a world position on the Z = 0 plane
                Vector3 curPos = flowersLayer.transform.position;
                curPos.x += delta.x;

                float offset = (float)(Math.Tan(BWConstants.diagonalAngle)) * delta.x;
                curPos.y += offset;

                flowersLayer.transform.position = curPos;
                backgroundLayer.moveBackground(delta.x);
                foregroundLayer.moveForeground(delta.x);

            } else if (isSwiping) {
            //Swiping

                GameObject selection = PickObject( fingerPos );

                if(isSelectionFlower(selection)) {

                    //checking for type writer scroll
                    if (prevFlower == selection) {
                        if(flowerOnTheEdge(selection)) {
                            enableTypeWriter = true;
                            isDragging = true;
                        } else {
                            enableTypeWriter = false;
                            isDragging = false;
                        }

                    } //check for tracing lines
                    else {

                        enableTypeWriter = false;
                        isDragging = false;

                        BWFlower flowerObj = selection.GetComponent<BWFlower>();
                        if(expectedNumbers.Count > 0 && flowerObj.getFlowerNumber() == (int)expectedNumbers[0] && swipingWentOut) {

                            playSoundEffect("Bee_flowertap_new_01");

                            beeToFlower((int)expectedNumbers[0]);
                            playNumberSound((int)expectedNumbers[0] - beeStartingPoint);

                            swipingWentOut = false;
                            expectedNumbers.RemoveAt(0);
                            addTracingLine(prevFlower, selection);
                            prevFlower = selection;

                        } else if (expectedNumbers.Count == 0 && swipingWentOut){

                            playSoundEffect("Bee_flowertap_new_01");
                            incorrectSwipingBeyondTarget(prevFlower, selection);
                        } else if (expectedNumbers.Count > 0 && swipingWentOut) {
                            int rand = UnityEngine.Random.Range(2,4);
                            playHintSound(rand);
                        }
                    }

                } else {
                    enableTypeWriter = false;
                    isDragging = false;

                    //either the selection is null or selection is scrollcollider - so swiping went out
                    swipingWentOut = true;

                    //check for auto scroll
                    Vector3 curPosition = GetWorldPos(fingerPos);

                    if (numberToFind > 0 && curPosition.x > 560) {
                        if(flowerOnTheEdge(prevFlower)) {
                            //auto scroll
                            BWFlower prevFlowerObj = prevFlower.GetComponent<BWFlower>();
                            int lastNumberRegistered = prevFlowerObj.getFlowerNumber();

                            if(lastNumberRegistered == dataManager.numberLineMax) {
                                return;
                            }

                            int numberToScrollTo = lastNumberRegistered - 1;

                            if (numberToScrollTo < dataManager.numberLineMin) {
                                numberToScrollTo = dataManager.numberLineMin;
                            }
                            if (numberToScrollTo+BWConstants.numbersOnScreen > dataManager.numberLineMax) {
                                numberToScrollTo = dataManager.numberLineMax - BWConstants.numbersOnScreen;
                            }

                            Debug.Log("scroll to "+numberToScrollTo);
                            flowerLayerToInitialNumber(numberToScrollTo);
                        }
                    } else if (numberToFind < 0 && curPosition.x < -560) {
                        if(flowerOnTheEdge(prevFlower)) {
                            //auto scroll
                            BWFlower prevFlowerObj = prevFlower.GetComponent<BWFlower>();
                            int lastNumberRegistered = prevFlowerObj.getFlowerNumber();

                            if(lastNumberRegistered == dataManager.numberLineMin) {
                                return;
                            }

                            int numberToScrollTo = lastNumberRegistered - 6;

                            if (numberToScrollTo < dataManager.numberLineMin) {
                                numberToScrollTo = dataManager.numberLineMin;
                            }

                            if (numberToScrollTo+BWConstants.numbersOnScreen > dataManager.numberLineMax) {
                                numberToScrollTo = dataManager.numberLineMax - BWConstants.numbersOnScreen;
                            }
                            Debug.Log("scroll to "+numberToScrollTo);
                            flowerLayerToInitialNumber(numberToScrollTo);

                        }
                    }
                }
            }
        }
    }
    public void resetCurrentQuestion()
    {
        touchEnabled = true;
        flowersLayer.transform.position = new Vector3(BWConstants.flowersLayerMinX, -350, -200);

        BWFlowersLayer layer =  flowersLayer.GetComponent<BWFlowersLayer>();
        layer.resetFlowersLayer();

        if ((numberLineMax - numberLineMin) > BWConstants.numbersOnScreen) {
            enableScrolling = true;
            xvel = 0;
            lasty = 0;
            direction = BounceDirection.BounceDirectionStayingStill;
        }

        BWBee beeObj = bee.GetComponent<BWBee>();
        beeObj.flipBee(dataManager.shouldFlipBee);

        flowerLayerToInitialNumber(initialNumber);
        beeToFlower(beeStartingPoint);
        setExpectedNumbers(beeStartingPoint, numberToFind);
    }
    public void nextQuestion()
    {
        enableScrolling = false;
        isDragging = false;
        isSwiping = false;
        prevFlower = null;

        if(attempts > 0) {

        }

        attempts = 0;
        dataManager.fetchNextQuestionData();

        numberLineMin = dataManager.numberLineMin;
        numberLineMax = dataManager.numberLineMax;
        initialNumber = dataManager.initialNumber;
        numberToFind = dataManager.numberToFind;
        beeStartingPoint = dataManager.beeStartingIndex;

        string numberimg = string.Format("BW_NumberLine/Sprites/Referent/Referant_numbers{0}", AGGameState.modInt(numberToFind));
        bubbleNumber.renderer.material.mainTexture = (Texture2D)Resources.Load(numberimg);

        if(numberToFind < 0) {
            bubbleSymbol.renderer.material.mainTexture = (Texture2D)Resources.Load("BW_NumberLine/Sprites/Referent/Referant_exporterminus");
        } else {
            bubbleSymbol.renderer.material.mainTexture = (Texture2D)Resources.Load("BW_NumberLine/Sprites/Referent/Referant_exporterPlus");
        }

        flowersLayer.transform.position = new Vector3(BWConstants.flowersLayerMinX, -350, -200);

        BWFlowersLayer layer =  flowersLayer.GetComponent<BWFlowersLayer>();
        layer.setDiagonalFlowersLayer(numberLineMin, numberLineMax, initialNumber);

        if ((numberLineMax - numberLineMin) > BWConstants.numbersOnScreen) {
            enableScrolling = true;
            xvel = 0;
            lasty = 0;
            direction = BounceDirection.BounceDirectionStayingStill;
        }

        BWBee beeObj = bee.GetComponent<BWBee>();
        beeObj.flipBee(dataManager.shouldFlipBee);

        flowerLayerToInitialNumber(initialNumber);
        beeToFlower(beeStartingPoint);
        setExpectedNumbers(beeStartingPoint, numberToFind);

        if(dataManager.currentLevel == 0) {
            Invoke("levelZeroTutorial", 3);
        } else {
            playInstructionSound();
        }

        CancelInvoke("noInteraction");
        Invoke("noInteraction", BWConstants.idleTime + 5.0f);

        touchEnabled = true;
    }