static void InstanciatExplotionAnimation(int x, int y) { if (grid [x, y].GetBallColor().x == 1 && grid [x, y].GetBallColor().y == 0.92f) { BallExplosion yellowExplotionAnimation = Resources.Load <BallExplosion>("prefabs/AnimationPrefabs/YellowBallExplosionPosition/YellowBallExplosionPosition"); BallExplosion anim = (BallExplosion)Instantiate(yellowExplotionAnimation, new Vector3(x, y, 0), Quaternion.identity); anim.transform.position = grid [x, y].transform.position; } if (grid [x, y].GetBallColor().x == 1 && grid [x, y].GetBallColor().y == 0 && grid [x, y].GetBallColor().z == 0) { BallExplosion redExplotionAnimation = Resources.Load <BallExplosion>("prefabs/AnimationPrefabs/RedBallExplosionPosition/RedBallExplosionPosition"); BallExplosion anim = (BallExplosion)Instantiate(redExplotionAnimation, new Vector3(x, y, 0), Quaternion.identity); anim.transform.position = grid [x, y].transform.position; } if (grid [x, y].GetBallColor().x == 0 && grid [x, y].GetBallColor().y == 1 && grid [x, y].GetBallColor().z == 0) { BallExplosion greenExplotionAnimation = Resources.Load <BallExplosion>("prefabs/AnimationPrefabs/GreenBallExplosionPosition/GreenBallExplosionPosition"); BallExplosion anim = (BallExplosion)Instantiate(greenExplotionAnimation, new Vector3(x, y, 0), Quaternion.identity); anim.transform.position = grid [x, y].transform.position; } if (grid [x, y].GetBallColor().x == 0.5f) { BallExplosion greyExplotionAnimation = Resources.Load <BallExplosion>("prefabs/AnimationPrefabs/GreyBallExplosionPosition/GreyBallExplosionPosition"); BallExplosion anim = (BallExplosion)Instantiate(greyExplotionAnimation, new Vector3(x, y, 0), Quaternion.identity); anim.transform.position = grid [x, y].transform.position; } if (grid [x, y].GetBallColor().x == 1 && grid [x, y].GetBallColor().y == 0 && grid [x, y].GetBallColor().z == 1) { BallExplosion purpleExplotionAnimation = Resources.Load <BallExplosion>("prefabs/AnimationPrefabs/PurpleBallExplosionPosition/PurpleBallExplosionPosition"); BallExplosion anim = (BallExplosion)Instantiate(purpleExplotionAnimation, new Vector3(x, y, 0), Quaternion.identity); anim.transform.position = grid [x, y].transform.position; } }
void OnTriggerEnter(Collider other) { if (other.gameObject.tag == "Ball") { BallExplosion explosion = other.gameObject.GetComponent <BallExplosion> (); // ball.start being electrified explosion.ToggleOnGoalLine(true); } }
void OnTriggerExit(Collider other) { if (other.gameObject.tag == "Ball") { bool goal2 = other.gameObject.transform.position.x < transform.position.x; bool goal1 = other.gameObject.transform.position.x > transform.position.x; bool goal = teamNumber == 1 ? goal1 : goal2; BallExplosion explosion = other.gameObject.GetComponent <BallExplosion> (); if (goal) { explosion.Explode(); gameManager.GoalScored(teamNumber); // explode the ball } else { // stop electrifying the ball explosion.ToggleOnGoalLine(false); } } }