public void SetPowerUps(powerUpType powerUp) { powerUps[(int)powerUp] = true; Weapon weapon = GetComponent<Weapon>(); switch(powerUp) { case powerUpType.none: for(int i = 0; i<((int)powerUpType.total); i++) { powerUps[i] = false; } weapon.attackRate = ASPEED_DEFAULT; moveSpeed = MSPEED_DEFAULT; shieldActive = false; break; case powerUpType.attackSpeed: weapon.attackRate = ASPEED_BOOST; break; case powerUpType.moveSpeed: moveSpeed = MSPEED_BOOST; break; case powerUpType.shield: shieldActive = true; break; } }
// Start is called before the first frame update void Start() { rand = Random.Range(0, 5); switch (rand) { //give the powerup a random colour depending on the type of powerup case 0: { currentPower = powerUpType.bouncy; GetComponent <Renderer>().material.color = new Color(1, 0.5f, 0); break; } case 1: { currentPower = powerUpType.explosive; GetComponent <Renderer>().material.color = Color.blue; break; } case 2: { currentPower = powerUpType.fast; GetComponent <Renderer>().material.color = Color.magenta; break; } case 3: { currentPower = powerUpType.spread; GetComponent <Renderer>().material.color = Color.yellow; break; } case 4: { currentPower = powerUpType.burst; GetComponent <Renderer>().material.color = Color.green; break; } } }
void Start() { meuPowerUp = powerUpType.Agilidade; singleton = this; Destroy(singleton.gameObject, 5); }
public bool IsPowerupActive(powerUpType powerUp) { return powerUps[(int)powerUp]; }
public void showAd(powerUpType wich) { lastAdReward = "powerUp"; lastAdRewardPU = wich; if (PlayerPrefs.HasKey ("ad_power_up")) { showAd (); } else { showTut ("ad_power_up"); } }
public void pickedPowerUp(powerUpType whatPU) { switch(whatPU){ case powerUpType.shield: btnShield.GetComponent<Image>().sprite = PowerUpsSprites[0]; hasShield = true; break; case powerUpType.fix: btnFix.GetComponent<Image>().sprite = PowerUpsSprites[1]; hasFix = true; break; case powerUpType.bulletTime: btnClock.GetComponent<Image>().sprite = PowerUpsSprites[2]; hasClock = true; break; } showTut ("power_up"); }
void setType() { int value = rand.Next(50); if(value < 1) { index = 0; type = powerUpType.ballDamage; } else if (value < 15) { index = 1; type = powerUpType.extraBullet; } else if (value < 30) { index = 2; type = powerUpType.extraScore; } else if (value < 31) { index = 3; type = powerUpType.extraLife; } else if (value < 32) { index = 4; type = powerUpType.bulletDamage; } else if (value < 38) { index = 5; type = powerUpType.shield; } else if (value < 48) { index = 6; type = powerUpType.penalty; } else if (value < 50) { index = 7; type = powerUpType.tripleShot; } }
// Use this for initialization void Start() { mType = (powerUpType) Random.Range(1, 4); }
/// <summary> /// Activates the power up. [To be called after players both hold "a"] /// </summary> /// <param name="topPlayer">If set to <c>true</c> top player.</param> /// <param name="type">Type.</param> public static void ActivatePowerUp(bool topPlayer, powerUpType type) { if (type == powerUpType.speed) { // Play the speedboost sound AudioSource speedSound = GameObject.Find("SpeedBoostSound").GetComponent<AudioSource>(); speedSound.Play(); if (topPlayer) { Main.S.carTop.GetComponent<UserInteraction> ().startBoost (); } else { Main.S.carBottom.GetComponent<UserInteraction> ().startBoost (); } PowerupGenerator.S.numInstantiatedSpeed--; } else if (type == powerUpType.swap) { // Play the portal sound AudioSource swapSound = GameObject.Find("SwapSound").GetComponent<AudioSource>(); swapSound.Play(); if (topPlayer) { Main.S.carBottom.GetComponent<ArcadeVehicle> ().playerSwap (); } else { Main.S.carTop.GetComponent<ArcadeVehicle> ().playerSwap (); } PowerupGenerator.S.numInstantiatedSwap--; } else if (type == powerUpType.oil) { // Play the portal sound AudioSource oilSound = GameObject.Find("OilSound").GetComponent<AudioSource>(); oilSound.Play(); if (topPlayer) { Main.S.carTop.GetComponent<UserInteraction> ().placeOilSpill (); } else { Main.S.carBottom.GetComponent<UserInteraction> ().placeOilSpill (); } } else if (type == powerUpType.portal) { // Play the portal sound AudioSource portalSound = GameObject.Find("PortalSound").GetComponent<AudioSource>(); portalSound.Play(); if (topPlayer) { Main.S.carTop.GetComponent<UserInteraction> ().moveToNextCheckpoint (); } else { Main.S.carBottom.GetComponent<UserInteraction> ().moveToNextCheckpoint (); } } else if (type == powerUpType.rocket) { AudioSource rocketSound = GameObject.Find("RocketSound").GetComponent<AudioSource>(); rocketSound.Play(); // Spawn a rocket and set it's target; if (topPlayer) { int rocketstop = Main.S.carTop.GetComponent<CarState>().currCheckpoint; Vector3 carpos = Main.S.carTop.transform.position; Main.S.carTop.GetComponent<UserInteraction>().spawnRocket(rocketstop, carpos, Main.S.carBottom); } else { int rocketstop = Main.S.carBottom.GetComponent<CarState>().currCheckpoint; Vector3 carpos = Main.S.carBottom.transform.position; Main.S.carBottom.GetComponent<UserInteraction>().spawnRocket(rocketstop, carpos, Main.S.carTop); } } Logger.S.writeFile(topPlayer, "Activated Powerup " + type + " at: " + Main.S.getGameTime()); if (topPlayer) Main.S.carTop.GetComponent<CarState>().powerupsActivated++; else Main.S.carBottom.GetComponent<CarState>().powerupsActivated++; }
/// <summary> /// When Player has collided with the power up /// </summary> void OnTriggerEnter(Collider coll) { // The rocket is an object going through the track, and may run into a powerup // so we need to account for that and not take any actions if a powerup is hit // by a rocket. Transform rocketTrans = coll.transform.parent; if (rocketTrans && rocketTrans.tag == "Rocket") { // if it is a rocket, don't do anything return; } bool isBottomScreen = coll.GetComponentInParent<Transform>().GetComponentInParent<UserInteraction>().isCarBottom; if (!isBottomScreen) { Main.S.carTop.GetComponent<CarState>().powerupsHit++; } else { Main.S.carBottom.GetComponent<CarState>().powerupsHit++; } Logger.S.writeFile(!isBottomScreen, "Picked Up Powerup at " + Main.S.getGameTime()); if (type == powerUpType.random) { bool isBehind = CarState.isCarBehind(!isBottomScreen); if (isBehind) { int randInt = Random.Range(0, 10); if (randInt < 3) { type = powerUpType.rocket; } else if (randInt < 5) type = powerUpType.swap; else if(randInt < 9) type = powerUpType.portal; else type = powerUpType.speed; } else { int randInt = Random.Range(0, 10); if (randInt < 4) { type = powerUpType.speed; } else if (randInt < 10) { type = powerUpType.oil; } else if (Main.S.raceStarted) { type = powerUpType.swap; } else { type = powerUpType.speed; } } } if ((isBottomScreen && Main.S.carBottomDone) || (!isBottomScreen && Main.S.carTopDone)) { print("cant pick up item now"); } else { CarmonyGUI.S.GiveTeamPowerup(!isBottomScreen, type); } if (!isRandom) Destroy(gameObject); else StartCoroutine("destroyObject"); }
/// <summary> /// Coroutine to display powerup animation and respawn the powerup /// </summary> IEnumerator destroyObject() { m_meshRenderer.enabled = false; m_boxCollider.enabled = false; m_partialSystem.gameObject.SetActive(true); type = powerUpType.random; yield return new WaitForSeconds(1f); m_partialSystem.gameObject.SetActive(false); yield return new WaitForSeconds(3f); m_meshRenderer.enabled = true; m_boxCollider.enabled = true; }