예제 #1
0
 public void goToCash()
 {
     if (!anim.isOnMove())
     {
         anim.moveTo(cashTarget.position, Random.Range(0.5f, 2f));
     }
     timeToGoCash = -10;
 }
    /*Recebe o pedido (resultado) e aceita-o se estiver na hora certa. Se não, retorna false*/
    public bool addResultOrder(Order order)
    {
        if (waitingForResult)
        {
            gameManager.playAudioCoinClap();
            resultValue = order;
            order.goToOperation(new Vector3(2.2f, 0, 0));
            waitingForResult = false;

            bu_accept.transform.position   = new Vector3(0, 0, 0);
            bu_accept.transform.localScale = new Vector3(0, 0, 0);
            AuxiliarAnim bu_a = bu_accept.GetComponent <AuxiliarAnim>();
            bu_a.moveTo(new Vector3(1.5f, -2.5f, 0), 0.5f);
            bu_a.scaleTo(new Vector3(1, 1, 1), 0.5f);

            return(true);
        }

        if (order == resultValue)
        {
            order.backToInit();
            waitingForResult             = true;
            bu_accept.transform.position = new Vector3(0, -10, 0);
        }

        return(false);
    }
예제 #3
0
 public void goToCounter(Vector3 posCounter)
 {
     initialPosition = transform.position;
     initialScale    = transform.localScale;
     anim.moveTo(posCounter, 0.5f);
     anim.scaleTo(new Vector3(0.4f, 0.4f, 0.4f), 0.5f);
     timeToReload = 0.8f;
 }
    // Update is called once per frame
    void Update()
    {
        if (timeToWait > 0)
        {
            timeToWait -= Time.deltaTime;
        }
        if (timeToWait <= 0 && timeToWait > -5)
        {
            anim.moveTo(goToPosition, 0.2f);
            anim.fadeTo(0, 0.3f);
            timeToWait = -10;
        }

        if (actived && sr.color.a <= 0.001f)
        {
            resetMe();
        }
    }
예제 #5
0
    private void upOrDown()
    {
        Vector3 pos = transform.position;

        //Deslocamentos de em X e Y de (7 e 3.5)
        int rand = Random.Range(0, 2);

        if (rand == 0)
        {
            anim.moveTo(new Vector3(pos.x, 3.5f, pos.z), myMoviment[0].y);
        }
        else
        {
            anim.moveTo(new Vector3(pos.x, -3.5f, pos.z), myMoviment[0].y);
        }

        timeLeftOnMove = myMoviment [0].y;

        myMoviment[0] = new Vector2(myMoviment[0].x, -1);
    }
예제 #6
0
 public void goToPosition(Vector2 pos, BubbleController b)
 {
     if (fixedBubble)
     {
         return;
     }
     anim.moveTo(new Vector3(pos.x, pos.y, 0), 0.5f);
     movingTo           = true;
     timeToMovingTo     = 0.5f;
     rigidbody.velocity = new Vector2(0, 0);
     bubble_b           = b;
 }
예제 #7
0
 public void goToResult(float x, float y)
 {
     anim.moveTo(new Vector3(x, y, 0), 0.5f);
     inToBlender();
 }
    // Update is called once per frame
    void Update()
    {
        if (onOperation)
        {
            if (bu_cancel.transform.position.y == -10)
            {
                bu_cancel.transform.position   = new Vector3(0, 0, 0);
                bu_cancel.transform.localScale = new Vector3(0, 0, 0);
                AuxiliarAnim bu_a = bu_cancel.GetComponent <AuxiliarAnim>();
                bu_a.moveTo(new Vector3(-1.5f, -2.5f, 0), 0.5f);
                bu_a.scaleTo(new Vector3(1, 1, 1), 0.5f);
            }
            if (!onOperators && ((Mathf.Abs(cardB.transform.position.x - (t.localPosition.x + 2)) < 0.05f && cardB.transform.position.y == t.localPosition.y) || totalOperators == 1))
            {
                initOperators();
                onOperators = true;
            }

            if (((Input.GetMouseButtonUp(0)) || totalOperators == 1) && !GameSettings.panelOpened && !GameSettings.cardOnZoom)
            {
                RaycastHit2D hit = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero, Mathf.Infinity, 1 << 9);

                if ((hit.collider != null) || totalOperators == 1 && !operationChoosed)
                {
                    operationChoosed = true;
                    Operator[] ops;
                    if (totalOperators == 1)
                    {
                        ops = getAllOperators();
                        for (int i = 0; i < ops.Length; i++)
                        {
                            if (ops[i].isUseThis())
                            {
                                op = ops[i];
                            }
                        }
                    }
                    else
                    {
                        op = hit.collider.gameObject.GetComponent <Operator>();
                        op.animOnChoose(new Vector3(-0.9f, 0, 0));
                    }

                    ops = getAllOperators();
                    for (int i = 0; i < ops.Length; i++)
                    {
                        if (!ops[i].gameObject.name.Equals(op.gameObject.name))
                        {
                            ops[i].removeMeFromScene();
                        }
                    }

                    if (op == sub && cardA.getCardValue() < cardB.getCardValue())
                    {
                        CardController c_aux = cardA;
                        cardA = cardB;
                        cardB = c_aux;
                        cardA.moveCardTo(cardB.transform.position);
                    }

                    if (totalOperators > 1)
                    {
                        cardB.moveCardTo(new Vector3(0.2f, 0, 0));
                    }

                    cardA.toScale(1f, 0.25f);
                    cardB.toScale(1f, 0.25f);

                    waitingForResult = true;
                    equals.fadeTo(1, 0.5f);

                    int value = -99999;
                    int a     = cardA.getCardValue();
                    int b     = cardB.getCardValue();

                    if (op == sum)
                    {
                        value = a + b;
                    }
                    else if (op == sub)
                    {
                        value = a - b;
                    }
                    else if (op == mul)
                    {
                        value = a * b;
                    }
                    else
                    {
                        value = a / b;
                    }

                    if (totalOperators > 1)
                    {
                        gameManager.playAudioBu_press();
                    }

                    gameManager.initOrders(value);
                }

                if (Input.GetMouseButtonUp(0))
                {
                    hit = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero, Mathf.Infinity, 1 << 5);                       //9 is the UI Layer

                    if (hit.collider != null && !buttonPressed)
                    {
                        if (hit.collider.gameObject.name.Equals("bu_cancel"))
                        {
                            AuxiliarAnim bu_an = hit.collider.gameObject.GetComponent <AuxiliarAnim>();
                            if (!bu_an.isOnMove() && !bu_an.isOnScale())
                            {
                                gameManager.playAudioBu_press();
                                Debug.Log("BU PRESSED DE CANCEL OPERATION!");
                                cancelOperation();
                                buttonPressed = true;
                            }
                        }
                        else if (hit.collider.gameObject.name.Equals("bu_verify"))
                        {
                            AuxiliarAnim bu_an = hit.collider.gameObject.GetComponent <AuxiliarAnim>();
                            if (!bu_an.isOnMove() && !bu_an.isOnScale())
                            {
                                cardA.setEnableClick(false);
                                cardB.setEnableClick(false);
                                verifyOperation();
                                buttonPressed = true;
                            }
                        }
                    }
                }
            }
        }
    }
예제 #9
0
 public void backToInit()
 {
     anim.moveTo(initialPosition, 0.5f);
     anim.scaleTo(initialScale, 0.5f);
 }