private void HandleSBomb(GamePadState gState, GameTime time) { sBombTimer -= (float)time.ElapsedGameTime.Milliseconds / 1000.0f; if (sBombTimer < 0) { sBombTimer = 0; } if (gState.Buttons.LeftShoulder == ButtonState.Pressed && !lbDown && sBombTimer == 0) { lbDown = true; if (points >= SBOMB_COST) { sBombTimer = MIN_SBOMB_TIMER; if (LevelManager.Mode != GameMode.Worms) { blasts.Add(NormalMap.AddBlast(Position, 5, 1)); points -= SBOMB_COST; } else { float angle; Vector2 v = new Vector2(); for (int i = 0; i < 6; i++) { angle = MathHelper.TwoPi * ((float)(i + 1) / 6.0f); v.X = (float)Math.Cos(angle) * Player.BULLET_SPEED; v.Y = (float)Math.Sin(angle) * Player.BULLET_SPEED; SBBrancher b = new SBBrancher(position, bTex4, 2, angle, 0, 20); bullets.Add(b); } points = 0; } } } else if (gState.Buttons.LeftShoulder == ButtonState.Released) { lbDown = false; } }
//Overrides SpawnNext to create a continuing single stranded SBBrancher segment protected override void SpawnNext() { if (!hasBranched && currentLife > branchTime && positionInChain < repetitions) { Vector2 nextPos = new Vector2(); float rot; for (int i = 0; i < numBranches; i++) { nextPos.X = position.X + (float)Math.Cos(rotation) * length; nextPos.Y = position.Y + (float)Math.Sin(rotation) * length; rot = rotation + (float)((Game1.rand.NextDouble() - 0.5f) * 2) * (MathHelper.PiOver4 / 2); SBBrancher b = new SBBrancher(nextPos, tex, lifeTime, rot, positionInChain + 1, repetitions); Player.AddGrower((Brancher)b); } hasBranched = true; } }