private void changeColorTo(BubbleController b, string color) { if (color.Equals("R")) { b.changeColorTo("Red"); } else if (color.Equals("B")) { b.changeColorTo("Blue"); } else if (color.Equals("Y")) { b.changeColorTo("Yellow"); } else if (color.Equals("G")) { b.changeColorTo("Green"); } else if (color.Equals("P")) { b.changeColorTo("Purple"); } else if (color.Equals("O")) { b.changeColorTo("Orange"); } else if (color.Equals("RO")) { b.changeColorTo("RedOrange"); } else if (color.Equals("RP")) { b.changeColorTo("RedPurple"); } else if (color.Equals("BG")) { b.changeColorTo("BlueGreen"); } else if (color.Equals("BP")) { b.changeColorTo("BluePurple"); } else if (color.Equals("YG")) { b.changeColorTo("YellowGreen"); } else if (color.Equals("YO")) { b.changeColorTo("YellowOrange"); } else { //Se der algum erro fica mais fácil de ver b.transform.localScale = new Vector3(0.3f, 0.3f, 1); } }
/*Create a new bubble and add on bubbles list*/ private void createBubble(string bubbleColor) { if (availableBubbles.Count == 0 || bubbles.Count > maxBubbles) { timeToNewBubble = 1f; gameManager.endGame(); return; } /*Debug.Log("Quanto bubbles "+bubbles.Count); * * if(bubbles.Count < 7) * for (int i = 0; i < 6; i++) { * BubbleController newBu = Instantiate (bubblePrefab, new Vector3 (0, 0, 0), Quaternion.identity) as BubbleController; * newBu.gameObject.SetActive(true); * if(i == 0) * newBu.addTertiaryColor("RedPurple"); * if(i == 1) * newBu.addTertiaryColor("RedOrange"); * if(i == 2) * newBu.addTertiaryColor("BluePurple"); * if(i == 3) * newBu.addTertiaryColor("YellowOrange"); * if(i == 4) * newBu.addTertiaryColor("YellowGreen"); * if(i == 5) * newBu.addTertiaryColor("BlueGreen"); * * bubbles.Add (newBu); * newBu.transform.SetParent(this.transform); * newBu.transform.localPosition = new Vector3(0,0,0); * } * * if(true) * return;*/ Vector3 bornPosition; int rand = Random.Range(1, 9); if (rand == 1) { bornPosition = new Vector3(-8, 5, 0); } else if (rand == 2) { bornPosition = new Vector3(8, 5, 0); } else if (rand == 3) { bornPosition = new Vector3(-8, -5, 0); } else if (rand == 4) { bornPosition = new Vector3(0, 5, 0); } else if (rand == 5) { bornPosition = new Vector3(0, -5, 0); } else if (rand == 6) { bornPosition = new Vector3(8, 0, 0); } else if (rand == 7) { bornPosition = new Vector3(-8, 0, 0); } else { bornPosition = new Vector3(8, -5, 0); } rand = Random.Range(0, availableBubbles.Count); BubbleController newBubble = availableBubbles[rand]; newBubble.gameObject.SetActive(true); newBubble.transform.position = bornPosition; newBubble.initMe(); newBubble.transform.SetParent(this.transform); availableBubbles.Remove(newBubble); bubbles.Add(newBubble); //Se vier cor terecária colocá-la aqui. if (bubbleColor.Equals("RedPurple")) { newBubble.changeColorTo("RedPurple"); tertiaryColors[0] = true; } else if (bubbleColor.Equals("RedOrange")) { newBubble.changeColorTo("RedOrange"); tertiaryColors[1] = true; } else if (bubbleColor.Equals("BluePurple")) { newBubble.changeColorTo("BluePurple"); tertiaryColors[2] = true; } else if (bubbleColor.Equals("YellowOrange")) { newBubble.changeColorTo("YellowOrange"); tertiaryColors[3] = true; } else if (bubbleColor.Equals("YellowGreen")) { newBubble.changeColorTo("YellowGreen"); tertiaryColors[4] = true; } else if (bubbleColor.Equals("BlueGreen")) { newBubble.changeColorTo("BlueGreen"); tertiaryColors[5] = true; } if (gameManager.totalTime < 15) { timeToNewBubble = 2.5f; } else if (gameManager.totalTime < 30) { timeToNewBubble = 2.2f; } else if (gameManager.totalTime < 40) { timeToNewBubble = 2f; } else if (gameManager.totalTime < 50) { timeToNewBubble = 1.6f; } else if (gameManager.totalTime < 60) { timeToNewBubble = 1.4f; } else if (gameManager.totalTime < 80) { timeToNewBubble = 1.2f; } else if (gameManager.totalTime < 100) { timeToNewBubble = 0.9f; } else if (gameManager.totalTime < 130) { timeToNewBubble = 0.6f; } else if (gameManager.totalTime < 180) { timeToNewBubble = 1.5f; } else if (gameManager.totalTime < 200) { timeToNewBubble = 1f; } else if (gameManager.totalTime < 300) { timeToNewBubble = 0.8f; } else { timeToNewBubble = 0.6f; } }