public void NextLevel() { destroyArea = 0; area = shape.Area(); percent = 0; level++; Color rand = Palette.RandomColorExcept(new List <PColor>() { PColor.WHITE, PColor.YELLOW, PColor.DARKYELLOW, PColor.GOLD, PColor.BRONZE }); gamePlay.background.color = new Color(rand.r, rand.g, rand.b, 0.8f); shape.FillColor(rand); UIEffect.Instance.MakeEffectScore(level); if (mode == 1) { slicerManager.Restart(); } else if (mode == 2) { // ADD MORE BALL HERE ballManager.AddBall(); } }
//divide due to effect of bomb public void Divide() { float bullVelX = 0.1f; float bullVelZ = 0.1f; float norm = (float)Math.Sqrt(bullVelX * bullVelX + bullVelZ * bullVelZ); bullVelZ = bullVelZ * 5; bullVelX = bullVelX * 5; Transform trans = gameObject.transform; DestroyBall(gameObject); float velY = ComputeInitialYVelocity(trans.position.y); //Debug.Log(velY); trans.position = new Vector3(trans.position.x, trans.position.y, trans.position.z); GameObject newBall = (GameObject)Instantiate(ball2, trans.position, trans.rotation); BallManager.AddBall(newBall); newBall.GetComponent <Rigidbody>().velocity = new Vector3(-bullVelZ, 0, bullVelX); newBall.GetComponent <AudioSource>().Play(); trans.position = new Vector3(trans.position.x, trans.position.y, trans.position.z); GameObject newBall2 = (GameObject)Instantiate(ball2, trans.position, trans.rotation); BallManager.AddBall(newBall2); newBall2.GetComponent <Rigidbody>().velocity = new Vector3(bullVelZ, 0, -bullVelX); }
// Update is called once per frame void Update() { if (State == ObjectiveState.Enabled) { if (slots[filled].Holding) { Manager.AddBall(); filled++; if (filled >= slots.Count) { Finish(); } else { slots[filled].enabled = true; } } } }
private void Divide(Info bulletInfo) { //float bullVelX = bulletTrans.velocity.x; //float bullVelZ = bulletTrans.velocity.z; float bullVelX = bulletInfo.getX(); float bullVelZ = bulletInfo.getZ(); float norm = (float)Math.Sqrt(bullVelX * bullVelX + bullVelZ * bullVelZ); //Debug.Log("bullVelX " + bullVelX); //Debug.Log("bullVelZ " + bullVelZ); bullVelZ = bullVelZ * 5; bullVelX = bullVelX * 5; //Debug.Log("Divide"); //Debug.Log("bullVelX " + bullVelX); //Debug.Log("bullVelZ " + bullVelZ); Transform trans = gameObject.transform; DestroyBall(gameObject); float velY = ComputeInitialYVelocity(trans.position.y); if (velY != velY) { velY = 5.0f; } trans.position = new Vector3(trans.position.x, trans.position.y, trans.position.z); GameObject newBall = (GameObject)Instantiate(ball2, trans.position, trans.rotation); BallManager.AddBall(newBall); newBall.GetComponent <Rigidbody>().velocity = new Vector3(-bullVelZ, velY, bullVelX); newBall.GetComponent <AudioSource>().Play(); trans.position = new Vector3(trans.position.x, trans.position.y, trans.position.z); GameObject newBall2 = (GameObject)Instantiate(ball2, trans.position, trans.rotation); BallManager.AddBall(newBall2); newBall2.GetComponent <Rigidbody>().velocity = new Vector3(bullVelZ, velY, -bullVelX); }
protected void SpawnBall(int cannon, string ballType) { //Debug.Log("SpawnBall"); Vector3 pos = Cannon1Position; GameObject ball = (GameObject)Instantiate(Resources.Load(ballType)); //ball.GetComponent<MeshRenderer>().enabled = false; Color c = ball.GetComponent <Renderer>().material.color; switch (cannon) { case CANNON1: ActivateCannon(cannon1, c); pos = Cannon1Position; break; case CANNON2: ActivateCannon(cannon2, c); pos = Cannon2Position; break; case CANNON3: ActivateCannon(cannon3, c); pos = Cannon3Position; break; case CANNON4: ActivateCannon(cannon4, c); pos = Cannon4Position; break; } pos = AdjustPosition(pos, ballType); ball.GetComponent <Rigidbody>().position = pos; //ball.GetComponent<MeshRenderer>().enabled = true; BallManager.AddBall(ball); SpawnedBalls++; }
void SpawnNewBall() { BallManager manager = GameObject.FindGameObjectWithTag("BallManager").GetComponent <BallManager>(); manager.AddBall(); }