예제 #1
0
    public bool initOperation()
    {
        if (cardA == null || cardB == null || choosedOp == null)
        {
            return(false);
        }

        choosedOp.fadeTo(1, 1.5f);
        eq.fadeTo(1, 1.5f);

        int value = cardA.getCardValue() + cardB.getCardValue();

        if (choosedOp.gameObject.name.Equals("Subtracao"))
        {
            value = cardA.getCardValue() - cardB.getCardValue();
        }
        if (choosedOp.gameObject.name.Equals("Multiplicacao"))
        {
            value = cardA.getCardValue() * cardB.getCardValue();
        }
        if (choosedOp.gameObject.name.Equals("Divisao"))
        {
            value = cardA.getCardValue() / cardB.getCardValue();
        }

        gameManager.initOrders(value);

        onOperation = true;
        return(true);
    }
예제 #2
0
    public void playGame()
    {
        fadePlane.gameObject.SetActive(true);
        fadePlane.gameObject.GetComponent <SpriteRenderer> ().color = new Color(0, 0, 0, 0);
        fadePlane.fadeTo(1, 0.4f);

        Application.LoadLevelAsync("LevelsScene");
    }
예제 #3
0
    public void desapear()
    {
        onDesapear = true;
        onShowMe   = false;
        anim.scaleTo(new Vector3(0f, 0f, 1), 0.6f);
        anim.fadeTo(0f, 0.6f);

        for (int i = transform.childCount - 1; i >= 0; i--)
        {
            Destroy(transform.GetChild(i).gameObject);
        }
    }
예제 #4
0
 public void addOrder(Order order)
 {
     if (timeToNewTurn > 0)
     {
         return;
     }
     if (choosedOrder != null)
     {
         choosedOrder.backToInit();
     }
     choosedOrder = order;
     choosedOrder.goToOperation(new Vector3(5, -0.5f, 0), new Vector3(5, 4, 1));
     bu_verify.fadeTo(1, 0.5f);
     bu_end.fadeTo(0, 0.2f);
 }
예제 #5
0
    private void initBright()
    {
        float timeAnim    = 0;
        float initialFade = 0;
        float toScale     = 0;

        if (!isSecondaryColor() && !isTertiaryColor())
        {
            return;
        }

        if (isSecondaryColor())
        {
            timeAnim        = 1;
            initialFade     = 0.5f;
            toScale         = 1.2f;
            timeToNewBright = 1.2f;
            //Debug.Log("Secondary Bright");
        }
        else if (isTertiaryColor())
        {
            timeAnim = 0.5f;
            //initialFade = 1;
            initialFade     = 0.5f;
            toScale         = 1.5f;
            timeToNewBright = 0.8f;
            //Debug.Log("Tertiary Bright");
        }

        anim_bright.gameObject.transform.localScale = new Vector3(1.06f, 1.06f, 1);
        sr_bright.color = new Color(sr_bright.color.r, sr_bright.color.g, sr_bright.color.b, initialFade);

        anim_bright.scaleTo(new Vector3(toScale, toScale, 1), timeAnim);
        anim_bright.fadeTo(0, timeAnim);
    }
예제 #6
0
    public void loseMe()
    {
        float moveX = Random.Range(0.0f, 1.0f);

        anim.moveTo(new Vector3(t.position.x + moveX, t.position.y - 1, t.position.z), 1);
        anim.fadeTo(0, 1);
        timeToDestroyMe = 1;
    }
    // Update is called once per frame
    void Update()
    {
        if (currentSituation <= 11)
        {
            if (timeToWait >= 0)
            {
                timeToWait -= Time.deltaTime;
            }
            else
            {
                if (currentSituation == 10)
                {
                    fadePlane.fadeTo(1, 1f);
                    timeToWait = 1;
                }

                if (currentSituation == 11)
                {
                    Application.LoadLevel("TitleScreen");
                }

                if (currentSituation < 9)
                {
                    quads[currentSituation].SetActive(true);
                    //Adicionar som de puc/plim.
                    if (currentSituation == 6)
                    {
                        name.fadeTo(1, 1f);
                    }
                }

                if (currentSituation < 6)
                {
                    timeToWait = 0.3f;
                }
                else if (currentSituation < 9)
                {
                    timeToWait = 0.1f;
                }
                else if (currentSituation == 9)
                {
                    timeToWait = 2;
                }

                currentSituation++;
            }
        }
    }
    // 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();
        }
    }
예제 #9
0
    public void animaOnLose()
    {
        if (hp() > 0 || bossLose == true)
        {
            return;
        }

        bossLose = true;
        if (transform.localScale.x > 0)
        {
            anim.scaleTo(new Vector3(2, 2, 1), 0.5f);
        }
        else
        {
            anim.scaleTo(new Vector3(-2, 2, 1), 0.5f);
        }
        anim.fadeTo(0, 0.5f);
        timeToDestroyMe = 0.6f;
    }
예제 #10
0
    public void explode()
    {
        if (timeToRemoveMe != -10 || !explodeMe)
        {
            return;
        }

        GameObject bubbleBright = transform.GetChild(0).gameObject;

        bubbleBright.GetComponent <SpriteRenderer> ().color = new Color(1, 1, 1, 0);

        CircleCollider2D col = GetComponent <CircleCollider2D> ();

        col.enabled = false;
        anim.scaleTo(new Vector3(1.8f, 1.8f, 1), 0.3f);
        anim.fadeTo(0, 0.3f);
        timeToRemoveMe = 0.5f;

        explodeMe = false;
    }
예제 #11
0
 public void fadeIn(float time)
 {
     anim.fadeTo(1, time);
 }
    // 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;
                            }
                        }
                    }
                }
            }
        }
    }