public static void DoDebugLogic(GameLoopObject glo, List <Bug> bugs, AnimationService animationService, Ship ship) { //for debugging purposes if (MouseHelper.MouseIsDown) { bugs.ForEach(a => a.OutputDebugInfo = false); bugs.ForEach(a => { var bugrect = new RectangleF(a.Location.X, a.Location.Y, 32, 32); var mouserect = new RectangleF(MouseHelper.Position.X, MouseHelper.Position.Y, 10, 10); if (bugrect.IntersectsWith(mouserect)) { a.OutputDebugInfo = true; } }); } //for debugging purposes if (glo.captureship) { bugs.ForEach(a => { a.Location = BugFactory.EnemyGrid.GetPointByRowCol(a.HomePoint.X, a.HomePoint.Y); a.CurPathPointIndex = 0; a.PathPoints.Clear(); a.Paths.Clear(); a.IsMoving = false; a.StartDelay = 0; a.Started = true; }); var bug = bugs.FirstOrDefault(a => a.Sprite.SpriteType == Sprite.SpriteTypes.GreenBug); EnemyDiveManager.DoEnemyDive(bugs, animationService, ship, Constants.BugDiveSpeed, bug, true); } //for debugging purposes if (glo.morphbug) { ship.Sprite = new Sprite(Sprite.SpriteTypes.DoubleShip); bugs.Where(a => a.IsInIntro).ToList().ForEach(a => { a.Location = BugFactory.EnemyGrid.GetPointByRowCol(a.HomePoint.X, a.HomePoint.Y); a.CurPathPointIndex = 0; a.PathPoints.Clear(); a.Paths.Clear(); a.IsMoving = false; a.StartDelay = 0; a.Started = true; }); var redblubugs = bugs.Where(a => (a.Sprite.SpriteType == Sprite.SpriteTypes.BlueBug || a.Sprite.SpriteType == Sprite.SpriteTypes.RedBug) && a.MorphState != Bug.enMorphState.Started && !a.IsDiving).ToList(); var bug = redblubugs[Utils.Rnd(0, redblubugs.Count - 1)]; bug.MorphState = Bug.enMorphState.Started; } //for debugging purposes if (glo.killbugs) { bugs.All(a => a.IsExploding = true); } }
public static void DoMorph(List <Bug> bugs, Bug bug, AnimationService animationService, Ship ship) { bug.MorphCount++; if (bug.MorphCount == 1) { SetSpriteType(bug); bug.preMorphedSpriteDownFlap = bug.SpriteBank[0]; bug.preMorphedSprite = bug.Sprite; bug.SpriteBank.Clear(); bug.SpriteBank.Add(new Sprite(Sprite.SpriteTypes.RedGreenBug_DownFlap)); } else if (bug.MorphCount == 10) { bug.Sprite = new Sprite(Sprite.SpriteTypes.RedGreenBug); } else if (bug.MorphCount == 15) { var morphedbug = CreateMorphedBug(animationService, bug, true); EnemyDiveManager.DoEnemyDive(bugs, animationService, ship, Constants.BugDiveSpeed, morphedbug, false, false); } else if (bug.MorphCount == 17) { var morphedbug = CreateMorphedBug(animationService, bug, false); EnemyDiveManager.DoEnemyDive(bugs, animationService, ship, Constants.BugDiveSpeed, morphedbug, false, false); } else if (bug.MorphCount == 19) { var morphedbug = CreateMorphedBug(animationService, bug, false); EnemyDiveManager.DoEnemyDive(bugs, animationService, ship, Constants.BugDiveSpeed, morphedbug, false, false); } else if (bug.MorphCount == 20) { bug.DestroyImmediately = true; bug.MorphCount = 0; bug.preMorphedSprite = null; bug.preMorphedSpriteDownFlap = null; } }
public static void MoveEnemyGrid(List <Bug> bugs, AnimationService animationService, Ship ship, bool gameover) { if (BugFactory.EnemyGrid.GridLeft > 330 || BugFactory.EnemyGrid.GridLeft < 160) { MoveEnemyGridIncrement *= -1; } if (!EnemyGridBreathing) { BugFactory.EnemyGrid.GridLeft += MoveEnemyGridIncrement; } else { if (BugFactory.EnemyGrid.GridLeft == Constants.EnemyGridLeft) { BugFactory.EnemyGrid.GridLeft = Constants.EnemyGridLeft; if (BugFactory.EnemyGrid.HSpacing > 60 || BugFactory.EnemyGrid.HSpacing < 45) { BreathEnemyGridIncrement *= -1; } BugFactory.EnemyGrid.HSpacing += BreathEnemyGridIncrement; BugFactory.EnemyGrid.VSpacing += BreathEnemyGridIncrement; if (!BreathSoundPlayed && !gameover) { SoundManager.PlaySound(SoundManager.SoundManagerSounds.breathing); BreathSoundPlayed = true; } } else { BugFactory.EnemyGrid.GridLeft += MoveEnemyGridIncrement; } } bugs.ForEach(bug => { //if the player shoots the bug befire it's captured in the tractor beam //then destroy the tracktor beam if (!bugs.Any(a => a.CaptureState == Bug.enCaptureState.Started)) { animationService.Animatables.RemoveAll(a => a.Sprite.SpriteType == Sprite.SpriteTypes.TractorBeam); SoundManager.MuteAllSounds = false; } if (bug.IsDiveBomber) { if (bug.CurPathPointIndex >= bug.PathPoints.Count - 1) { bug.Speed = Constants.BugDiveSpeed + 2; bug.Paths.Add(new BezierCurve() { StartPoint = bug.Location, ControlPoint1 = bug.Location, ControlPoint2 = bug.DiveBombLocation, EndPoint = bug.DiveBombLocation }); bug.PathPoints.AddRange(animationService.ComputePathPoints(bug.Paths.Last(), true)); } } else if (bug.CaptureState == Bug.enCaptureState.Started) { if (!bug.IsMoving && (bug.Location.Y > Constants.CanvasSize.Height / 3 || bug.FighterCapturedMessageShowing)) { bug.Rotation = -90; GalagaCaptureManager.DoTractorBeam(bug, animationService, ship); } } else if (bug.CaptureState == Bug.enCaptureState.RecaptureStarted) { GalagaCaptureManager.DoRecapture(bug, animationService, ship); } else { //after the ship has been captured and disabled //wait for all bugs to finish diving before re-enabling it if (ship.Disabled) { if (bugs.Count(a => a.IsDiving) == 0) { ship.Disabled = false; } } var homepoint = BugFactory.EnemyGrid.GetPointByRowCol(bug.HomePoint.X, bug.HomePoint.Y); if (!(homepoint.X == 0 && homepoint.Y == 0)) { homepoint.Y += bug.HomePointYOffset; if (bug.IsMoving) { //this makes the bugs go to their spot on the moving enemy grid if (bug.PathPoints.Count > 0) { //update the last point to be the moving homepoint on the enemy grid bug.PathPoints[bug.PathPoints.Count - 1] = homepoint; //if we are moving to the home point, recalc our vector each time it moves if (bug.CurPathPointIndex == bug.PathPoints.Count - 1) { bug.LineFromLocation = new Vector2(bug.Location.X, bug.Location.Y); bug.LineToLocation = new Vector2(homepoint.X, homepoint.Y); } } } //snap to grid if bug isn't moving else if (bug.Started && bug.PathPoints.Count == 0) { bug.Location = homepoint; bug.IsDiving = false; bug.NeverDestroyOffScreen = true; bug.IsInIntro = false; bug.MissileCountDowns.Clear(); if (bug.CaptureState == Bug.enCaptureState.FlyingBackHome) { bug.CaptureState = Bug.enCaptureState.Complete; SoundManager.MuteAllSounds = false; bug.FighterCapturedMessageShowing = false; bug.ClearFighterCapturedMessage = true; ship.Visible = true; ship.Disabled = false; } //if the bug is morphing, do the morph animation //and create the morphed bugs if (bug.MorphState == Bug.enMorphState.Started) { BugMorphMananger.DoMorph(bugs, bug, animationService, ship); } //if the bug is a morphed bug and has flown back home //change back into it's previous form if (bug.IsMorphedBug) { bug.IsMorphedBug = false; bug.Sprite = bug.PreMorphedSprite; bug.SpriteBank.Add(bug.PreMorphedSpriteDownFlap); bug.MorphState = Bug.enMorphState.NotStarted; } } } else if (bug.Started && bug.PathPoints.Count == 0) { //no homepoint means this is a morphed bug and we need to make it dive off screen IDive dive; if (Utils.Rnd(0, 10) % 2 == 0) { dive = new RedBugDive1(); } else { dive = new RedBugDive2(); } EnemyDiveManager.DoEnemyDive(bugs, animationService, ship, Constants.BugDiveSpeed, bug, false, false, dive); } } }); }