//Called when minigames begin public void StartMinigame() { minigameOver = false; //Find and attach players //FindPlayers (); //Also find ui and powerupcontrol ui = GameObject.Find("UI").GetComponent <UI> (); //pauseUI = GameObject.Find ("PauseUI"); powerupControl = GameObject.Find("PowerupControl").GetComponent <PowerupControl> (); //Find scoreBar ScoreBarUI scoreBar = ui.GetComponentInChildren <ScoreBarUI>(); //If the minigame isn't fruit forecast or color craze, disable it if (!SceneManager.GetActiveScene().name.Equals(GameInformation.fruitForecast) && !SceneManager.GetActiveScene().name.Equals(GameInformation.colorCraze)) { scoreBar.HideBars(); } //Apply previous powerup if (activePowerup != null) { powerupControl.ActivatePowerup(); } }
//When the player clicks the mini powerup public virtual void OnMouseDown() { if (this.name == "MiniPower") { PowerupControl.UsePowerup(this.name, 20); //AddScore(); Destroy(this.gameObject); } }
/* Only called when ther is a collision with spaceship and Powerup * 'Uses' the powerup & relocates it */ public virtual void OnTriggerEnter(Collider other) { if (other.CompareTag("Player")) { //Debug.Log("Collision"); Vector3 SpaceshipPosition = GameObject.Find("Spaceship").transform.position; PowerupControl.UsePowerup(Capsule.tag, scoreToAdd); //Relocate powerup to later in the game (Bigger Z axis number) RelocatePowerup(SpaceshipPosition); } }
void Start() { powerupControl = powerupControlObj.GetComponent <PowerupControl> (); }