public void UsePowerup(Powerup.PowerupType typeOfPowerup) { //We should use coroutines in order to remove the efect after a while switch (typeOfPowerup) { case Powerup.PowerupType.SizeDecrease: StartCoroutine(HalfSize()); break; case Powerup.PowerupType.SizeIncrease: StartCoroutine(DoubleSize()); break; case Powerup.PowerupType.SpeedDecrease: StartCoroutine(HalfSpeed()); break; case Powerup.PowerupType.SpeedIncrease: StartCoroutine(DoubleSpeed()); break; default: Debug.LogError("PowerType: " + typeOfPowerup + " not handled"); break; } }
public void DeactivatePowerup() { switch (activePowerup) { case Powerup.PowerupType.NULL: break; case Powerup.PowerupType.SPEED: //if (isBubbleMode) // bubble.speedIncrease = 1.0f; //else // legs.speedIncrease = 1.0f; break; case Powerup.PowerupType.STRENGTH: break; case Powerup.PowerupType.SHIELD: numShields--; break; case Powerup.PowerupType.STICKYFEET: bubble.autoAimDist = 0f; bubble.autoAimAccuracy = 0f; break; } powerupEffects[(int)activePowerup].SetActive(false); activePowerup = Powerup.PowerupType.NULL; }
public bool applyPowerupToPlayer(int _playerID, Powerup.PowerupType _type) { if (!m_players[_playerID].canTakeStatusEffect()) { Debug.Log("Failed to apply pickup, player cannot accept"); return(false); } if (_playerID >= m_players.Count) { Debug.Log("Failed to apply pickup, player id out of range"); return(false); } if (_type == Powerup.PowerupType.Freeze) { Debug.Log("Starting Freeze"); StartCoroutine("usePowerupFreeze", m_players[_playerID]); } else if (_type == Powerup.PowerupType.Speed) { Debug.Log("Starting Speed"); StartCoroutine("usePowerupSpeed", m_players[_playerID]); } else if (_type == Powerup.PowerupType.Invincible) { Debug.Log("Starting invincible"); StartCoroutine("usePowerupInvincible", m_players[_playerID]); } else if (_type == Powerup.PowerupType.Obstacles) { StartCoroutine("usePowerupObstacle", m_players[_playerID]); } return(true); }
void Start() { m_rb = GetComponent <Rigidbody>(); m_anim = GetComponent <Animator>(); defaultSpeed = m_speed; m_heldPower = Powerup.PowerupType.None; m_battery = 15; m_camera.transform.position = transform.position - (m_camera.transform.rotation * new Vector3(0.0f, 0.0f, 1.0f)) * 70.0f; if (m_playerNumber == 0) { m_icon.GetComponent <MeshRenderer>().material.color = m_aColor; } else if (m_playerNumber == 1) { m_icon.GetComponent <MeshRenderer>().material.color = m_bColor; } else if (m_playerNumber == 2) { m_icon.GetComponent <MeshRenderer>().material.color = m_xColor; } else if (m_playerNumber == 3) { m_icon.GetComponent <MeshRenderer>().material.color = m_yColor; } }
public void ActivatePowerup(Powerup.PowerupType power, float time) { switch (power) { case Powerup.PowerupType.DoublePoints: scoreManager.MultiplyScoreMultiplier(2); powerupTimers.Add(new PowerupTimer(time, power)); break; case Powerup.PowerupType.SafeMode: // if safe mode is already on, refresh the timer if (safeMode) { foreach (PowerupTimer timer in powerupTimers) { if (timer.GetPower() == Powerup.PowerupType.SafeMode) { timer.SetTimer(time); } } } else { spikePooler.DeactivateAllObjects(); powerupTimers.Add(new PowerupTimer(time, power)); safeMode = true; } break; default: break; } }
public void chagePowTypes(Powerup.PowerupType pt) { foreach (Powerup p in pows) { p.changeType(pt); } }
public GameObject GetPrefab(Powerup.PowerupType powerup_type) { if (!m_powerupMap.ContainsKey(powerup_type)) { Debug.LogWarningFormat("Powerup prefab not found {0}", powerup_type); return(null); } return(m_powerupMap [powerup_type]); }
public void PowerupPicked(Powerup.PowerupType type) { audioManager.PlaySound("Pickup"); if (type == Powerup.PowerupType.HPREGEN) { playerStats.Health += Mathf.RoundToInt(playerStats.maxHealth / 3f); hpBar.SetHealth(playerStats.Health, playerStats.maxHealth); } else if (type == Powerup.PowerupType.STOPWATCH) { if (!isTimeSlowed) { prevTimeScale = Time.timeScale; Time.timeScale = timeSlowAmount; isTimeSlowed = true; slowTimer = slowTimeDuration; } else { slowTimer += slowTimeDuration; } } else if (type == Powerup.PowerupType.FIRERATE) { if (!isFireRateEnhanced) { prevFireRate = playerStats.fireRate; playerStats.fireRate *= fireRateAmount; isFireRateEnhanced = true; fireRateTimer = fireRateDuration; } else { fireRateTimer += fireRateDuration; } } else if (type == Powerup.PowerupType.TRIANGLE) { if (!isTriangleAttack) { playerStats.isTriangleAttack = true; isTriangleAttack = true; triangleTimer = triangleAttackDuration; } else { triangleTimer += triangleAttackDuration; } } else if (type == Powerup.PowerupType.SHIELD) { playerStats.EnableShield(); } }
public void usePowerup(int _playerID) { // If managed to use status effect if (m_gpController.applyPowerupToPlayer(_playerID, m_heldPower)) { Debug.Log("Applying Powerup"); m_canvas.GetComponent <CanvasController>().clearPowerupIcon(); m_heldPower = Powerup.PowerupType.None; } // else, dont clear the icon, you still have it }
public void PowerUp(Powerup.PowerupType powerUp) { CancelPowerups(); faceController.SetSmugImage(2f); AchievementsController.instance.SetPowerupCollected(); switch (powerUp) { case Powerup.PowerupType.EXTRA_LIFE: Debug.Log("EXTRA LIFE!"); lives++; UpdateLives(); break; case Powerup.PowerupType.INVULNERNABILITY: Debug.Log("You are invulnerable... FOR NOW!"); invincible = true; invincibleImage.SetActive(true); currentPowerup = Powerup.PowerupType.INVULNERNABILITY; windowSpawner.GetComponent <WindowSpawner>().SetPowerUpTimer(); break; case Powerup.PowerupType.MONEYBAG: Debug.Log("Money falls from the sky."); moneybag = true; moneybagImage.SetActive(true); currentPowerup = Powerup.PowerupType.MONEYBAG; if (FistTable.instance.fistSpecial == 9) { windowSpawner.GetComponent <WindowSpawner>().SetPowerUpTimer(1 / FistTable.instance.fistPowerupsScale, BonusMoneyBag(windowSpawner.timeAlive)); } else { windowSpawner.GetComponent <WindowSpawner>().SetPowerUpTimer(1, BonusMoneyBag(windowSpawner.timeAlive)); } break; case Powerup.PowerupType.SLOW: Debug.Log("Slowing down the screen."); slowDown = true; slowDownImage.SetActive(true); currentPowerup = Powerup.PowerupType.SLOW; cameraScript.GetComponent <CameraScript>().SetSlowSpeed(true); windowSpawner.GetComponent <WindowSpawner>().SetPowerUpTimer(); break; case Powerup.PowerupType.SUPER_SOCKO: Debug.Log("SUPER SOCKO TIME!!!!!"); superSocko = true; superSockoImage.SetActive(true); currentPowerup = Powerup.PowerupType.SUPER_SOCKO; windowSpawner.GetComponent <WindowSpawner>().SetPowerUpTimer(); break; } }
public void ActivatePowerup(Powerup.PowerupType type, float duration) { DeactivatePowerup(); activePowerup = type; powerUpTime = duration; switch (activePowerup) { case Powerup.PowerupType.NULL: break; case Powerup.PowerupType.SPEED: if (!p_isSpeedActive) { StartCoroutine(Speed()); } break; case Powerup.PowerupType.STRENGTH: if (!p_isStrengthActive) { StartCoroutine(Strength()); } break; case Powerup.PowerupType.BALLS2WALL: // play animation if (!p_isB2WActive) { StartCoroutine(BallsToTheWall()); } break; case Powerup.PowerupType.BUSTER: if (!p_isBusterActive) { StartCoroutine(BallBuster()); } break; case Powerup.PowerupType.STICKYFEET: bubble.autoAimDist = 5f; bubble.autoAimAccuracy = 5f; break; case Powerup.PowerupType.SHIELD: // TODO: turn on shield numShields++; break; } powerupEffects[(int)activePowerup].SetActive(true); }
public void UsePowerup() { Debug.Log($"{Username} used a powerup"); foreach (Player player in FindObjectsOfType <Player>()) { player.photonView.RPC("RPC_BeAffectedByPowerup", RpcTarget.All, powerup, (Vector2)transform.position); } powerup = Powerup.PowerupType.None; }
public void ChangePlayerStat(Powerup.PowerupType type, float amount) { System.Random random = new System.Random(); int select = 1; string soundName = ""; switch (type) { case Powerup.PowerupType.Attack: soundName = "AttackPowerup"; select = random.Next(1, 3); soundName += select; audioManager.Play(soundName); m_meleeDamageModifier += amount; m_weapon.IncreaseByDamageMod(m_meleeDamageModifier); m_rangedDamageModifier += amount; break; case Powerup.PowerupType.Health: soundName = "HealthPowerup"; select = random.Next(1, 3); soundName += select; audioManager.Play(soundName); m_maxHealth += amount; break; case Powerup.PowerupType.Speed: soundName = "SpeedBoost"; select = random.Next(1, 3); soundName += select; audioManager.Play(soundName); m_walkSpeed += amount; break; case Powerup.PowerupType.Heal: soundName = "HealthPickup"; audioManager.Play(soundName); m_currentHealth += amount; if (m_currentHealth > m_maxHealth) { m_currentHealth = m_maxHealth; } break; default: break; } }
public void setPowerUpType(Powerup.PowerupType powerupType) { if (powerupSprite != null) { powerupSprite.RemoveFromContainer(); } powerupSprite = new Powerup(powerupType); powerupSprite.SetPosition(this.GetPosition()); this.container.AddChild(powerupSprite); if (powerupType != Powerup.PowerupType.NONE) { this.percentage = 1.0f; } }
public void AddPowerup(Vector3 pos, Powerup.PowerupType powerup_type) { Debug.LogFormat("Add powerup {0}", powerup_type); GameObject powerup_prefab = m_powerupPrefab.GetPrefab(powerup_type); if (powerup_prefab == null) { return; } GameObject powerup = (GameObject)Instantiate(powerup_prefab, pos, Quaternion.identity); m_cacheList.Add(powerup); m_powerupNumber++; }
public void RemoveBrick(GameObject brick) { //brick.SetActive(true); Brick brick_obj = brick.GetComponent <Brick> (); Powerup.PowerupType powerup_type = brick_obj.GetPowerup(); if (powerup_type != Powerup.PowerupType.powerup_none) { AddPowerup(brick.transform.position, powerup_type); } UpdateScore(brick_obj.m_brickValue); AddBrickExplosion(brick); m_brickNumber--; }
public void Initialize() { activePowerup = Powerup.PowerupType.NULL; powerupEffects = new GameObject[temp.Length]; for (int i = 0; i < powerupEffects.Length; i++) { powerupEffects[i] = temp[i].gameObject; } foreach (GameObject go in powerupEffects) { go.SetActive(false); } }
// This script handles all trigger detections for the Player private void OnTriggerEnter2D(Collider2D other) { if (other.TryGetComponent <Enemy>(out Enemy enemy)) { enemy.Damage(); _player.Damage(); } else if (other.TryGetComponent <Powerup>(out Powerup powerup)) { Powerup.PowerupType type = powerup.GetPowerupType(); float duration = powerup.GetDuration(); float bonus = powerup.GetBonusValue(); PowerupSelection(type, powerup, duration, bonus); } }
public void DeactivatePowerup(Powerup.PowerupType power) { switch (power) { case Powerup.PowerupType.DoublePoints: scoreManager.MultiplyScoreMultiplier(0.5f); break; case Powerup.PowerupType.SafeMode: safeMode = false; break; default: break; } }
void RPC_BeAffectedByPowerup(Powerup.PowerupType powerupType, Vector2 powerupPosition) { switch (powerupType) { case Powerup.PowerupType.Bomb: float bombForce = 40f; float bombRadius = 4f; Sound.PlayBombSound(Sound.bombSound); Vector2 delta = -(powerupPosition - (Vector2)transform.position); // Vector of difference between player and bomb float deltaMag = Mathf.Abs(delta.magnitude); // Magniude of delta // (-1/radius * mag) + 1 is a linear equation, starting at 1 and ending at 0. Then gets multiplied by bombForce scalar and the direction of the delta. Vector2 force = Mathf.Max((((-1 / bombRadius) * deltaMag) + 1), 0) * bombForce * delta.normalized; myBody.AddForce(force, ForceMode2D.Impulse); break; } }
public void CancelPowerups() { invincible = false; superSocko = false; slowDown = false; moneybag = false; invincibleImage.GetComponent <Image>().color = normalColor; superSockoImage.GetComponent <Image>().color = normalColor; slowDownImage.GetComponent <Image>().color = normalColor; moneybagImage.GetComponent <Image>().color = normalColor; invincibleImage.SetActive(false); superSockoImage.SetActive(false); slowDownImage.SetActive(false); moneybagImage.SetActive(false); cameraScript.GetComponent <CameraScript>().SetSlowSpeed(false); currentPowerup = Powerup.PowerupType.NONE; }
public void changePowerupIcon(Powerup.PowerupType _type) { m_powerupImage.color = new Color(1, 1, 1, 1); if (_type == Powerup.PowerupType.Freeze) { m_powerupImage.sprite = m_spriteFreeze; } else if (_type == Powerup.PowerupType.Invincible) { m_powerupImage.sprite = m_spriteInvincible; } else if (_type == Powerup.PowerupType.Speed) { m_powerupImage.sprite = m_spriteSpeed; } else if (_type == Powerup.PowerupType.Obstacles) { m_powerupImage.sprite = m_spriteObstacle; } }
public void ActivatePowerup(Powerup.PowerupType powerupType) { switch (powerupType) { case Powerup.PowerupType.AttackSpeed: attackSpeedPowerupActive = true; LeanTween.delayedCall(gameObject, 8f, () => { attackSpeedPowerupActive = false; }); break; case Powerup.PowerupType.Catpaw: catPawPowerupActive = true; LeanTween.delayedCall(gameObject, 8f, () => { catPawPowerupActive = false; }); break; case Powerup.PowerupType.TripleShot: tripleShotPowerupActive = true; LeanTween.delayedCall(gameObject, 8f, () => { tripleShotPowerupActive = false; }); break; } }
void AddBrick(int i, int j, int brick_id, int powerup_id) { float x = 1.2f - i * 0.2f - 0.1f; float y = 1.4f - j * 0.1f - 0.1f; Brick.BrickType brick_type = (Brick.BrickType)brick_id; Powerup.PowerupType powerup_type = (Powerup.PowerupType)powerup_id; GameObject brick = (GameObject)m_brickPrefab.GetPrefab(brick_type); if (brick == null) { return; } GameObject brick_obj = Instantiate(brick, new Vector3(x, y, 0.07f), Quaternion.identity) as GameObject; m_cacheList.Add(brick_obj); m_brickNumber++; if (powerup_type != Powerup.PowerupType.powerup_none) { brick_obj.GetComponent <Brick> ().m_powerupType = powerup_type; } }
IEnumerator SpawnPowerup() { while (!_stopSpawning) { yield return(new WaitForSeconds(Random.Range(4.0f, 8.0f))); Powerup.PowerupType newPowerupType = RandomPowerup(); switch (newPowerupType) { case Powerup.PowerupType.TripleShot: Instantiate(_tripleShotPrefab); break; case Powerup.PowerupType.Speed: Instantiate(_speedPowerupPrefab); break; case Powerup.PowerupType.Shield: Instantiate(_shieldPowerupPrefab); break; } } }
// Update is called once per frame void Update() { int wheels = 0; if (!init) { return; } GearboxCooldown -= Time.deltaTime; if (audioSource == null) { audioSource = GetComponentInChildren <AudioSource>(); return; } powerupduration -= Time.deltaTime; if (powerupduration < 0) { poweruptype = Powerup.PowerupType.None; } foreach (var item in SteerWheels) { item.steerAngle = SteerInput * 25; WheelVis vis = item.GetComponentInChildren <WheelVis>(); if (vis.Grounded) { wheels++; } if (GetComponentInChildren <Rigidbody>().velocity.magnitude > 15) { if (Brakes < 0.5f) { item.brakeTorque = 0; } else { item.motorTorque = 0; item.brakeTorque = Brakes * 2000; } } else { item.brakeTorque = 0; } } if (Vector3.Dot(transform.GetChild(0).up, Vector3.up) < 0.1f) { GetComponentInChildren <Rigidbody>().AddRelativeTorque(0, 0, -SteerInput * 900000 * Time.deltaTime); } float rpm = 0; if (poweruptype == Powerup.PowerupType.Tank) { GetComponentInChildren <Rigidbody>().mass = DefaultMass * 5; } else { GetComponentInChildren <Rigidbody>().mass = DefaultMass; } ApplyHealth(); float adjustedthrottle = Throttle * ThrottleCurve.Evaluate(RPM / 7000); if (RPM > MaxRPM) { adjustedthrottle = 0; } foreach (var item in DriveWheels) { WheelVis vis = item.GetComponentInChildren <WheelVis>(); if (vis.Grounded) { wheels++; } if (GetComponentInChildren <Rigidbody>().velocity.magnitude < 15) { item.motorTorque = adjustedthrottle * Power; item.brakeTorque = 0; if (Brakes > 0.5f) { item.motorTorque = -adjustedthrottle * Power * 1f; item.brakeTorque = 0; } } else { if (Brakes < 0.5f) { item.motorTorque = adjustedthrottle * Power; item.brakeTorque = 0; if (poweruptype == Powerup.PowerupType.QuadPower || poweruptype == Powerup.PowerupType.Tank) { item.motorTorque *= 4; } } else { item.motorTorque = 0; item.brakeTorque = Brakes * 4000; } } rpm += item.rpm; } rpm /= DriveWheels.Length; rpm *= FDR; rpm = CalculateGear(rpm); if (poweruptype == Powerup.PowerupType.QuadPower) { rpm /= 2; } RPM = Mathf.Lerp(RPM, rpm, Time.deltaTime * 10f); points += Time.deltaTime * GetComponentInChildren <Rigidbody>().velocity.magnitude * 4; audioSource.volume = Mathf.Clamp(rpm / 5000, 0.2f, 0.7f); audioSource.pitch = Mathf.Clamp(rpm / 6000, 0.5f, 1.2f) * Time.timeScale; if (wheels == 0 && !Physics.Raycast(new Ray(transform.GetChild(0).position, Vector3.down), 4)) { GetComponentInChildren <Rigidbody>().AddRelativeTorque(0, 0, -SteerInput * 100000 * Time.deltaTime); AirTime += Time.deltaTime * 300f; points += Time.deltaTime * 300f; } else { AirTime = 0; } if (transform.GetChild(0).position.y < -20) { HP -= Time.deltaTime * 50; if (HP < 0 && GetComponent <Player>() != null) { GetComponent <Player>().reason = DeathReason.Fall; } } }
public void PickUpPowerup(Powerup.PowerupType powerupType) { powerup = powerupType; }
public void SetPowerup(Powerup.PowerupType powerup) { m_powerupType = powerup; }
public PowerupTimer(float t, Powerup.PowerupType p) { currentTime = t; power = p; }
void PowerupSelection(Powerup.PowerupType type, Powerup powerup, float duration, float bonus) { // Activate appropriate functionality dependant on PowerupType switch (type) { case Powerup.PowerupType.TripleShot: if (!_player.TripleShotStatus() && !_player.WideLaserStatus()) { powerup.PlaySFX(); _player.ToggleTripleShot(); Destroy(powerup.gameObject); StartCoroutine(PowerupCooldown(duration, () => { _player.ToggleTripleShot(); })); } break; case Powerup.PowerupType.SpeedBoost: if (!_player.SpeedBoostStatus()) { powerup.PlaySFX(); _player.ToggleSpeedBoost(bonus); Destroy(powerup.gameObject); StartCoroutine(PowerupCooldown(duration, () => { _player.ToggleSpeedBoost(bonus); })); } break; case Powerup.PowerupType.Shield: if (!_player.ShieldStatus()) { powerup.PlaySFX(); _player.ToggleShield((int)bonus); Destroy(powerup.gameObject); // Shield depletes with damage so no cooldown required } break; case Powerup.PowerupType.WideLaser: if (!_player.WideLaserStatus() && !_player.TripleShotStatus()) { powerup.PlaySFX(); _player.ToggleWideLaser(); Destroy(powerup.gameObject); StartCoroutine(PowerupCooldown(duration, () => { _player.ToggleWideLaser(); })); } break; case Powerup.PowerupType.Ammo: if (_player.AmmoStatus() < 15) { powerup.PlaySFX(); _player.AddAmmo((int)bonus); Destroy(powerup.gameObject); // Only adds ammo to the Player so no cooldown required } break; case Powerup.PowerupType.Health: if (_player.LivesStatus() < 3) { powerup.PlaySFX(); _player.AddLife((int)bonus); Destroy(powerup.gameObject); // Only adds a life to the Player so no cooldown required } break; default: Debug.Log("No such Powerup: " + type); break; } }