/// <summary> /// Shoot if we have the laser powerup /// </summary> private void Shoot() { if (!mLaser) { return; } BrickBustGame game = (BrickBustGame)RB.Game; var level = game.Level; LaserShot shot; if (mLaserTurn == 0) { shot = new LaserShot(new Vector2i(Rect.x + 1, Rect.y - 8)); level.AddShot(shot); } else { shot = new LaserShot(new Vector2i(Rect.x + Rect.width, Rect.y - 8)); level.AddShot(shot); } level.Particles.Impact(new Vector2i(shot.Rect.x + 3, shot.Rect.y + 5), new Vector2(0, -1), C.COLOR_GREEN_BRICK); mLaserTurn = (mLaserTurn == 0) ? 1 : 0; RB.SoundPlay(C.SOUND_LASERSHOT, 1, UnityEngine.Random.Range(0.9f, 1.1f)); }
/// <summary> /// Update /// </summary> public virtual void Update() { if (mDead) { return; } mPos.y += 1.0f; mRect = new Rect2i((int)mPos.x, (int)mPos.y, 19, 10); if (mPos.y > RB.DisplaySize.height) { mDead = true; } BrickBustGame game = (BrickBustGame)RB.Game; var level = game.Level; var paddleRect = level.Paddle.Rect; if (paddleRect.Intersects(mRect)) { level.Particles.Explode(new Rect2i(40, 20, mRect.width, mRect.height), new Vector2i((int)mPos.x, (int)mPos.y), mColorTint); Activate(); mDead = true; } }
/// <summary> /// Activate the power up /// </summary> protected override void Activate() { base.Activate(); BrickBustGame game = (BrickBustGame)RB.Game; var paddle = game.Level.Paddle; paddle.Catch(); }
/// <summary> /// Activate the power up /// </summary> protected override void Activate() { base.Activate(); BrickBustGame game = (BrickBustGame)RB.Game; var level = game.Level; level.Lives++; }
/// <summary> /// Activate/Pickup the power up /// </summary> protected virtual void Activate() { RB.SoundPlay(C.SOUND_POWERUP); BrickBustGame game = (BrickBustGame)RB.Game; var level = game.Level; level.Score += 10; }
/// <summary> /// Handle the hit /// </summary> /// <param name="collider">Who hit us</param> /// <param name="pos">Position if impact</param> /// <param name="velocity">Velocity at impact</param> public override void Hit(Collidable collider, Vector2i pos, Vector2 velocity) { base.Hit(collider, pos, velocity); BrickBustGame game = (BrickBustGame)RB.Game; game.Level.Particles.Impact(pos, velocity, C.COLOR_BLACK_BRICK); RB.SoundPlay(C.SOUND_HIT_WALL, 1, UnityEngine.Random.Range(0.9f, 1.1f)); }
/// <summary> /// Activate the power up /// </summary> protected override void Activate() { base.Activate(); BrickBustGame game = (BrickBustGame)RB.Game; var balls = game.Level.Balls; for (int i = 0; i < balls.Count; i++) { balls[i].ResetSpeed(); } game.Level.Paddle.CancelPowerups(); }
/// <summary> /// Activate the power up /// </summary> protected override void Activate() { base.Activate(); BrickBustGame game = (BrickBustGame)RB.Game; var paddle = game.Level.Paddle; paddle.Extend(); // Make sure all balls stuck to the paddle are released var balls = game.Level.Balls; for (int i = 0; i < balls.Count; i++) { balls[i].StuckToPaddle = false; } }
/// <summary> /// Activate the power up /// </summary> protected override void Activate() { base.Activate(); BrickBustGame game = (BrickBustGame)RB.Game; var level = game.Level; var balls = level.Balls; if (balls == null || balls.Count == 0) { return; } for (int i = 0; i < 3; i++) { var randomBall = balls[UnityEngine.Random.Range(0, balls.Count)]; var ball = new Ball(new Vector2i((int)randomBall.Rect.center.x, (int)randomBall.Rect.center.y)); bool goodAngle = false; int angle = 0; while (!goodAngle) { angle = UnityEngine.Random.Range(0, 360); if (angle % 90 >= 25 && angle % 90 <= 75) { goodAngle = true; } } ball.Dir = UnityEngine.Quaternion.Euler(0, 0, angle) * new UnityEngine.Vector2(1, 0); ball.Speed = randomBall.Speed; ball.StuckToPaddle = randomBall.StuckToPaddle; balls.Add(ball); } }
/// <summary> /// Handle collision /// </summary> /// <param name="collider">Who hit us</param> /// <param name="pos">Position at impact</param> /// <param name="velocity">Velocity at impact</param> public override void Hit(Collidable collider, Vector2i pos, Vector2 velocity) { base.Hit(collider, pos, velocity); Life = Math.Max(0, Life - 1); if (collider is Ball) { RB.SoundPlay(C.SOUND_HIT_BRICK, 1, UnityEngine.Random.Range(0.9f, 1.1f)); } BrickBustGame game = (BrickBustGame)RB.Game; game.Level.Particles.Impact(pos, velocity, C.COLOR_BLACK_BRICK); if (Life <= 0) { game.Level.Score += Score; game.Shake(0.3f); game.Level.Particles.Explode(LastSpriteRect, new Vector2i(Rect.x, Rect.y), ColorTint); RB.SoundPlay(C.SOUND_EXPLODE, 1, UnityEngine.Random.Range(0.9f, 1.1f)); } }