public override void Update() { MobileEntity mob = Mobs[0]; string bulletType = "BulletTypeB"; if (FrameCount == 0) { mob.Position = new Vector2(Constants.P, -70); mob.Active = true; } //ZigZag down for 4 seconds if (FrameCount <= 4 * Constants.FPS) { if (mob.Position.Y < Constants.A || mob.Position.Y >= Constants.D) { mob.UpdatePosition("downRight"); } else { mob.UpdatePosition("downLeft"); } } //zigzag left for 6 seconds else if (FrameCount <= 10 * Constants.FPS) { if (mob.Position.X >= 0 && mob.Position.X < Constants.C || mob.Position.X >= Constants.G && mob.Position.X < Constants.K || mob.Position.X >= Constants.O && mob.Position.X < Constants.S) { mob.UpdatePosition("upLeft"); } //the mobs move downLeft between C-G, K-O, S-V else if (mob.Position.X >= Constants.C && mob.Position.X < Constants.G || mob.Position.X >= Constants.K && mob.Position.X < Constants.O || mob.Position.X >= Constants.S && mob.Position.X < Constants.V) { mob.UpdatePosition("downLeft"); } } //zigzag right for 5 seconds else if (FrameCount <= 15 * Constants.FPS) { if (mob.Position.X >= 0 && mob.Position.X < Constants.C || mob.Position.X >= Constants.G && mob.Position.X < Constants.K || mob.Position.X >= Constants.O && mob.Position.X < Constants.S) { mob.UpdatePosition("upRight"); } //the mobs move downRight between C-G, K-O, S-V else if (mob.Position.X >= Constants.C && mob.Position.X < Constants.G || mob.Position.X >= Constants.K && mob.Position.X < Constants.O || mob.Position.X >= Constants.S && mob.Position.X < Constants.V) { mob.UpdatePosition("downRight"); } } //zigzag left for 7 seconds else if (FrameCount <= 22 * Constants.FPS) { if (mob.Position.X >= 0 && mob.Position.X < Constants.C || mob.Position.X >= Constants.G && mob.Position.X < Constants.K || mob.Position.X >= Constants.O && mob.Position.X < Constants.S) { mob.UpdatePosition("upLeft"); } //the mobs move downLeft between C-G, K-O, S-V else if (mob.Position.X >= Constants.C && mob.Position.X < Constants.G || mob.Position.X >= Constants.K && mob.Position.X < Constants.O || mob.Position.X >= Constants.S && mob.Position.X < Constants.V) { mob.UpdatePosition("downLeft"); } } //Sawtooth right else if (FrameCount <= 30 * Constants.FPS) { // mobs teleport down when on C,G,K,O, or S if ((FrameCount / Constants.FPS) >= 23 && (FrameCount / Constants.FPS) <= 23.5) { mob.UpdatePosition("down"); mob.UpdatePosition("down"); } else if ((FrameCount / Constants.FPS) >= 25 && (FrameCount / Constants.FPS) <= 25.5) { mob.UpdatePosition("down"); mob.UpdatePosition("down"); } else if ((FrameCount / Constants.FPS) >= 27 && (FrameCount / Constants.FPS) <= 27.5) { mob.UpdatePosition("down"); mob.UpdatePosition("down"); } else if ((FrameCount / Constants.FPS) >= 29 && (FrameCount / Constants.FPS) <= 29.5) { mob.UpdatePosition("down"); mob.UpdatePosition("down"); } //the mobs move upRight otherwise else { mob.UpdatePosition("upRight"); mob.UpdatePosition("upRight"); } } else if (FrameCount <= 38 * Constants.FPS) { // mobs teleport down when on C,G,K,O, or S if ((FrameCount / Constants.FPS) >= 31 && (FrameCount / Constants.FPS) <= 31.5) { mob.UpdatePosition("down"); mob.UpdatePosition("down"); } else if ((FrameCount / Constants.FPS) >= 33 && (FrameCount / Constants.FPS) <= 33.5) { mob.UpdatePosition("down"); mob.UpdatePosition("down"); } else if ((FrameCount / Constants.FPS) >= 35 && (FrameCount / Constants.FPS) <= 35.5) { mob.UpdatePosition("down"); mob.UpdatePosition("down"); } else if ((FrameCount / Constants.FPS) >= 37 && (FrameCount / Constants.FPS) <= 37.5) { mob.UpdatePosition("down"); mob.UpdatePosition("down"); } //the mobs move upRight otherwise else { mob.UpdatePosition("upLeft"); mob.UpdatePosition("upLeft"); } } //small arc arcoss screen to exit else if (FrameCount > 38 * Constants.FPS) { if (FrameCount % 1 == 0) { mob.UpdatePosition("right"); } if (FrameCount % 1 == 0) { mob.Position = new Vector2(mob.Position.X, Constants.H - 40 + (-(float)Math.Sin(mob.Position.X / 200) * 100)); } } //bullets shoot every second after 4 seconds have passed if (FrameCount % 60 == 0 && mob.Active && FrameCount > 4 * Constants.FPS && mob.Position.X < 670) { Formation formation = new ZigZagFormation(new BulletMaker(), mob.Position); Bullets.Add(MoveScriptMaker.CreateMoveScript("ZigZag", formation.SetFormation(bulletType), false)); } //changed the dead area outside the window so it wouldn't kill mobs when they spawn just off screen if (mob.Position.X < -60 || mob.Position.X > 670) { mob.Color = Color.TransparentBlack; //this.Active = false; } //if(frameCount>45*Constants.FPS) //{ // this.Active = false; //} foreach (MoveScript formation in Bullets) { formation.Update(); } FrameCount++; }
public override void Update() { MobileEntity mob = Mobs[0]; string bulletType = "BulletTypeB"; if (FrameCount == 0) { mob.Position = new Vector2(Constants.P, -70); mob.Active = true; } //start sin wave from top left if (FrameCount <= 11 * Constants.FPS) { if (FrameCount % 1 == 0) { mob.UpdatePosition("right"); } if (FrameCount % 1 == 0) { mob.Position = new Vector2(mob.Position.X, Constants.E + (-(float)Math.Cos(mob.Position.X / 50) * 150)); } } //sin wave back right else if (FrameCount <= 22 * Constants.FPS) { if (FrameCount % 1 == 0) { mob.UpdatePosition("left"); } if (FrameCount % 1 == 0) { mob.Position = new Vector2(mob.Position.X, Constants.E + (-(float)Math.Cos(mob.Position.X / 50) * 150)); } } //diagnal from top left else if (FrameCount <= 33 * Constants.FPS) { //mobs enter from top left corner of screen, move to center if (mob.Position.X <= 327) { mob.UpdatePosition("downRight"); } //after hitting center, mobs leave top right else if (mob.Position.X >= 327) { mob.UpdatePosition("upRight"); } } //diagnal from top right else if (FrameCount <= 43 * Constants.FPS) { //mobs enter from top right corner of screen, move to center if (mob.Position.X >= 327) { mob.UpdatePosition("downLeft"); } //after hitting center, mobs leave top left else if (mob.Position.X <= 327) { mob.UpdatePosition("upLeft"); } } //sin wave from left to offscreen right else if (FrameCount > 43 * Constants.FPS) { if (FrameCount % 1 == 0) { mob.UpdatePosition("right"); } if (FrameCount % 1 == 0) { mob.Position = new Vector2(mob.Position.X, Constants.E + (-(float)Math.Sin(mob.Position.X / 10) * 150)); } } //bullets shoot every second after 4 seconds have passed if (FrameCount % 60 == 0 && mob.Active && FrameCount > 4 * Constants.FPS) { Formation formation = new ZigZagFormation(new BulletMaker(), mob.Position); Bullets.Add(MoveScriptMaker.CreateMoveScript("ZigZag", formation.SetFormation(bulletType), false)); } //changed the dead area outside the window so it wouldn't kill mobs when they spawn just off screen if (mob.Position.X < -60 || mob.Position.X > 670) { mob.Active = false; } if (mob.Position.X < -60 || mob.Position.X > 670) { mob.Color = Color.Red; } foreach (MoveScript formation in Bullets) { formation.Update(); } FrameCount++; }