/// <summary> /// Spawns the addition meteors /// /// </summary> /// <param name="Lmeteor">Meteor List</param> /// <param name="oldMeteor">Meteor object</param> public void SpawnMeteors(Meteor oldMeteor, int potShotPenalty) { for (int i = Settings.meteorPotshotPenalty ? -(Settings.meteorMinSpawns) : 0; i < (Settings.meteorPotshotPenalty ? potShotPenalty : Settings.meteorSpawnNumber); i++) { if (!Settings.useFancyCollisions) newSizeSubtractor = 200 - Utilities.getRand10() * 10; newMeteors.Add(new Meteor(oldMeteor.Position.X, oldMeteor.Position.Y, oldMeteor.Velocity.X + (Utilities.getRandBase(Settings.meteorSpawnSpeed) - Settings.meteorSpawnSpeed / 2) * (potShotPenalty + 1) / 10.0F, oldMeteor.Velocity.Y + (Utilities.getRandBase(Settings.meteorSpawnSpeed) - Settings.meteorSpawnSpeed / 2) * (potShotPenalty + 1) / 10.0F, Settings.useFancyCollisions ? oldMeteor.biggerDimension * (Utilities.getRandBase(Settings.meteorDimUpperLim) + Settings.meteorDimLowerLim) / Settings.meteorDimRandDivisor : Math.Abs(oldMeteor.Dimensions.X - newSizeSubtractor) + 30, Settings.useFancyCollisions ? oldMeteor.biggerDimension * (Utilities.getRandBase(Settings.meteorDimUpperLim) + Settings.meteorDimLowerLim) / Settings.meteorDimRandDivisor : Math.Abs(oldMeteor.Dimensions.X - newSizeSubtractor) + 30, oldMeteor.ImgPath)); } }
/// <summary> /// Handles the collision of a bullet and a meteor (meteor spawning called from here) /// </summary> /// <param name="m">The Meteor</param> /// <param name="b">The Weapon</param> private void bulletHitMeteor(Meteor m, Weapon b) { if (Settings.debug && Settings.useFancyCollisions) { m.isCollidedFoReal = true; b.isCollidedFoReal = true; } m.IsDying = true; b.IsActive = false; DestroyedMeteors.Add(m); UsedBullets.Add(b); MainGame.score += Settings.meteorScoreBase / (int)m.biggerDimension; MainGame.extraLivesCounter += Settings.meteorScoreBase / (int)m.biggerDimension; if (MainGame.extraLivesCounter > Settings.scoreToNextLife) { MainGame.extraLivesCounter = 0; MainGame.lives++; MainGame.extraLifeAdded = true; } if (m.biggerDimension > Settings.meteorMinSize) { Meteor TmpMeteor = m; int potShotPenalty; if (Settings.meteorPotshotPenalty && m.Dimensions.X > Settings.meteorMinSize) { potShotPenalty = (int)(Math.Abs(b.Velocity.getDirection() - b.Position.getDirectionTo(m.Position)) * Settings.meteorPotShotPenaltyMult); if (potShotPenalty > Settings.meteorMaxExtraSpawns) { potShotPenalty = Settings.meteorMaxExtraSpawns; } //Threads.MeteorSpawningTasks.Add(Task.Run(() => meteorSpawner.SpawnMeteors(TmpMeteor, potShotPenalty))); meteorSpawner.SpawnMeteors(TmpMeteor, potShotPenalty); } else { meteorSpawner.SpawnMeteors(TmpMeteor, 0); } //Threads.MeteorSpawningTasks.Add(Task.Run(() => meteorSpawner.SpawnMeteors(TmpMeteor, 0))); } }
/// <summary> /// This was going to be a cool method for having meteors split down the middle where the player shoots /// them, breaking into two semi-circular pieces instead of many smaller round meteors. It is doable - I /// just didn't have time. The drawImage method has overloads that allow you to just draw a portion of an image, /// and my fancyCollisions SAT algorithm would allow for non-ellipsoid meteors, too. It was going to be awesome. /// </summary> /// <param name="meteor">the old meteor</param> /// <param name="bullet">the bullet that hit it</param> /// <param name="potShotPenalty">the inaccuracy penalty</param> public void SplitMeteor(Meteor meteor, Weapon bullet, int potShotPenalty) // Not yet implemented { float splitLineAngle = bullet.Position.getDirectionTo(meteor.Position); }