예제 #1
0
    public void clickOnBubble(BubbleController b)
    {
        //Pode selecionar um bubble, misturar, explodir ou errar mistura.
        //Debug.Log ("Bubble "+b.getColor()+" clicked.");

        if (b != null && mouseDownOnBubble == b)
        {
            if (selectedBubble == null || (selectedBubble != b))
            {
                if (selectedBubble != null)
                {
                    bool mixBubbles     = verifyMix(selectedBubble.getColor(), b.getColor());
                    bool explodeBubbles = verifiExplode(selectedBubble, b);
                    if (mixBubbles || explodeBubbles)
                    {
                        selectedBubble.goToPosition(new Vector2(b.transform.position.x, b.transform.position.y), b);
                    }
                    selectedBubble.removeSelect();
                    selectedBubble = null;
                }
                else
                {
                    b.selectMe();
                    selectedBubble = b;
                }
            }
            else
            {
                b.removeSelect();
                selectedBubble = null;
            }
        }
    }
예제 #2
0
 private bool verifiExplode(BubbleController bA, BubbleController bB)
 {
     if (bA.getColor().Equals(bB.getColor()))
     {
         if (bA.isSecondaryColor() || bA.isTertiaryColor())
         {
             return(true);
         }
     }
     return(false);
 }
예제 #3
0
    public void hitMe(BubbleController bubble)
    {
        bool broken = false;

        if (bubble.isMovingTo() && bubble.get_bubble_b() == null)
        {
            foreach (Spark s in sparks_left)
            {
                if (GameSethings.getColorName(s.getColor()).Equals(bubble.getColor()))
                {
                    s.toRemove();
                    broken = true;
                    break;
                }
            }

            if (!broken)
            {
                foreach (Spark s in sparks_right)
                {
                    if (GameSethings.getColorName(s.getColor()).Equals(bubble.getColor()))
                    {
                        s.toRemove();
                        broken = true;
                        break;
                    }
                }
            }
        }

        if (broken)
        {
            timeToAnimaHit = 0.1f;
        }

        bubble.explode();
    }
예제 #4
0
    void OnCollisionStay2D(Collision2D coll)
    {
        if (coll == null || bubble_b == null)
        {
            return;
        }

        if (coll.gameObject == bubble_b.gameObject)
        {
            if (bubble_b.getColor().Equals(color) && (isSecondaryColor() || isTertiaryColor()))
            {
                explodeMe          = true;
                forceDirection     = Vector2.zero;
                rigidbody.velocity = forceDirection;
                bubble_b.setExplodeMe(true);
                bubble_b.gameObject.GetComponent <CircleCollider2D>().enabled = false;
                GetComponent <CircleCollider2D>().enabled = false;
            }
            else
            {
                if (color.Equals("Red") && bubble_b.getColor().Equals("Blue") || color.Equals("Blue") && bubble_b.getColor().Equals("Red"))
                {
                    changeColorTo("Purple");
                    bubble_b.removeMeFromScene();
                    bubble_b.gameObject.GetComponent <CircleCollider2D>().enabled = false;
                }
                else if (color.Equals("Red") && bubble_b.getColor().Equals("Yellow") || color.Equals("Yellow") && bubble_b.getColor().Equals("Red"))
                {
                    changeColorTo("Orange");
                    bubble_b.removeMeFromScene();
                    bubble_b.gameObject.GetComponent <CircleCollider2D>().enabled = false;
                }
                else if (color.Equals("Blue") && bubble_b.getColor().Equals("Yellow") || color.Equals("Yellow") && bubble_b.getColor().Equals("Blue"))
                {
                    changeColorTo("Green");
                    bubble_b.removeMeFromScene();
                    bubble_b.gameObject.GetComponent <CircleCollider2D>().enabled = false;
                }
                //RedPurple, RedOrange, BluePurple, YellowOrange, YellowGreen, BlueGreen.
                else if (color.Equals("Red") && bubble_b.getColor().Equals("Purple") || color.Equals("Purple") && bubble_b.getColor().Equals("Red"))
                {
                    changeColorTo("RedPurple");
                    bubble_b.removeMeFromScene();
                    bubble_b.gameObject.GetComponent <CircleCollider2D>().enabled = false;
                }
                else if (color.Equals("Red") && bubble_b.getColor().Equals("Orange") || color.Equals("Orange") && bubble_b.getColor().Equals("Red"))
                {
                    changeColorTo("RedOrange");
                    bubble_b.removeMeFromScene();
                    bubble_b.gameObject.GetComponent <CircleCollider2D>().enabled = false;
                }
                else if (color.Equals("Blue") && bubble_b.getColor().Equals("Purple") || color.Equals("Purple") && bubble_b.getColor().Equals("Blue"))
                {
                    changeColorTo("BluePurple");
                    bubble_b.removeMeFromScene();
                    bubble_b.gameObject.GetComponent <CircleCollider2D>().enabled = false;
                }
                else if (color.Equals("Yellow") && bubble_b.getColor().Equals("Orange") || color.Equals("Orange") && bubble_b.getColor().Equals("Yellow"))
                {
                    changeColorTo("YellowOrange");
                    bubble_b.removeMeFromScene();
                    bubble_b.gameObject.GetComponent <CircleCollider2D>().enabled = false;
                }
                else if (color.Equals("Green") && bubble_b.getColor().Equals("Yellow") || color.Equals("Yellow") && bubble_b.getColor().Equals("Green"))
                {
                    changeColorTo("YellowGreen");
                    bubble_b.removeMeFromScene();
                    bubble_b.gameObject.GetComponent <CircleCollider2D>().enabled = false;
                }
                else if (color.Equals("Blue") && bubble_b.getColor().Equals("Green") || color.Equals("Green") && bubble_b.getColor().Equals("Blue"))
                {
                    changeColorTo("BlueGreen");
                    bubble_b.removeMeFromScene();
                    bubble_b.gameObject.GetComponent <CircleCollider2D>().enabled = false;
                }
                forceDirection     = Vector2.zero;
                rigidbody.velocity = forceDirection;
            }
            bubble_b = null;
        }
    }
예제 #5
0
    void FixedUpdate()
    {
        if (bubbles.Count > 0)
        {
            int   addCombo  = 0;
            float posXcombo = -100;
            float posYcombo = -100;

            for (int i = bubbles.Count - 1; i > 0; i--)
            {
                BubbleController b = bubbles [i];
                if (b.isExplodeMe())
                {
                    if (b.isSecondaryColor())
                    {
                        gameManager.addScore(GameSethings.joinBubbles.EXPLODE_SECONDARY);
                        if (addCombo != 3)
                        {
                            addCombo = 2;
                        }
                    }
                    else if (b.isTertiaryColor())
                    {
                        gameManager.addScore(GameSethings.joinBubbles.EXPLODE_TERTIARY);
                        posXcombo = b.transform.position.x;
                        posYcombo = b.transform.position.y;
                        addCombo  = 3;
                    }
                    else
                    {
                        gameManager.addScore(GameSethings.joinBubbles.EXPLODE_PRIMATY);
                    }

                    b.explode();
                }
                else if (b.isRemoveMe())
                {
                    if (b.isSecondaryColor())
                    {
                        gameManager.addScore(GameSethings.joinBubbles.MIX_SECONDARY);
                    }
                    else
                    {
                        gameManager.addScore(GameSethings.joinBubbles.MIX_PRIMATY);
                    }

                    bubbles.Remove(b);
                    availableBubbles.Add(b);

                    //Remover boolean de cor terceárea.
                    if (b.getColor().Equals("RedPurple"))
                    {
                        tertiaryColors[0] = false;
                    }
                    else if (b.getColor().Equals("RedOrange"))
                    {
                        tertiaryColors[1] = false;
                    }
                    else if (b.getColor().Equals("BluePurple"))
                    {
                        tertiaryColors[2] = false;
                    }
                    else if (b.getColor().Equals("YellowOrange"))
                    {
                        tertiaryColors[3] = false;
                    }
                    else if (b.getColor().Equals("YellowGreen"))
                    {
                        tertiaryColors[4] = false;
                    }
                    else if (b.getColor().Equals("BlueGreen"))
                    {
                        tertiaryColors[5] = false;
                    }

                    b.transform.position = new Vector3(-100, -100, 0);
                    b.gameObject.SetActive(false);
                    gameManager.attQuantBubbles(bubbles.Count - 1);
                }
                if (selectedBubble != null && b == selectedBubble)
                {
                    continue;
                }
                b.moveMe();
            }

            if (addCombo == 2)
            {
                gameManager.addSecondaryCombo();
            }
            else if (addCombo == 3)
            {
                gameManager.addTertiaryCombo(posXcombo, posYcombo);
            }
        }
    }
예제 #6
0
    public GameSethings.colorGame getColorSelectedBubble()
    {
        if (selectedBubble.getColor().Equals(GameSethings.getColorName(GameSethings.colorGame.BLUE)))
        {
            return(GameSethings.colorGame.BLUE);
        }
        if (selectedBubble.getColor().Equals(GameSethings.getColorName(GameSethings.colorGame.RED)))
        {
            return(GameSethings.colorGame.RED);
        }
        if (selectedBubble.getColor().Equals(GameSethings.getColorName(GameSethings.colorGame.YELLOW)))
        {
            return(GameSethings.colorGame.YELLOW);
        }
        if (selectedBubble.getColor().Equals(GameSethings.getColorName(GameSethings.colorGame.GREEN)))
        {
            return(GameSethings.colorGame.GREEN);
        }
        if (selectedBubble.getColor().Equals(GameSethings.getColorName(GameSethings.colorGame.ORANGE)))
        {
            return(GameSethings.colorGame.ORANGE);
        }
        if (selectedBubble.getColor().Equals(GameSethings.getColorName(GameSethings.colorGame.PURPLE)))
        {
            return(GameSethings.colorGame.PURPLE);
        }
        if (selectedBubble.getColor().Equals(GameSethings.getColorName(GameSethings.colorGame.RED_ORANGE)))
        {
            return(GameSethings.colorGame.RED_ORANGE);
        }
        if (selectedBubble.getColor().Equals(GameSethings.getColorName(GameSethings.colorGame.RED_PURPLE)))
        {
            return(GameSethings.colorGame.RED_PURPLE);
        }
        if (selectedBubble.getColor().Equals(GameSethings.getColorName(GameSethings.colorGame.BLUE_GREEN)))
        {
            return(GameSethings.colorGame.BLUE_GREEN);
        }
        if (selectedBubble.getColor().Equals(GameSethings.getColorName(GameSethings.colorGame.BLUE_PURPLE)))
        {
            return(GameSethings.colorGame.BLUE_PURPLE);
        }
        if (selectedBubble.getColor().Equals(GameSethings.getColorName(GameSethings.colorGame.YELLOW_GREEN)))
        {
            return(GameSethings.colorGame.YELLOW_GREEN);
        }

        return(GameSethings.colorGame.YELLOW_ORANGE);
    }