//update cycle public GameState Update() { if (Blaze.WasPressed(Keys.Escape)) { frames = splashFrames - 1; } frames++; if (frames == splashFrames) { if (firstOver) { return(new MainMenu()); } else { firstOver = true; frames = 0; } } return(this); }
public void Update(List <Box> terrain) { Axis axis = Playing.Instance.axis; box.X += velocity.X; box.Y += velocity.Y; box.Z += velocity.Z; //handle walking sounds if (hadYCollision && (velocity.X != 0 || velocity.Z != 0)) { if (walkTimer == 0) { walkTimer = walkTime; jump.Play(1f, .5f, 0f); } else if (walkTimer == walkTime / 2) { jump.Play(1f, .4f, 0f); walkTimer--; } else { walkTimer--; } } else { walkTimer = walkTime; } HandleCollisions(terrain, axis); if (velocity.Y > -3) { velocity.Y -= gravity; } //handle turning lights on/off and drawing text prompts foreach (Light light in Playing.Instance.lights) { var intersection = box.Project(axis).GetIntersection(light.box.Project(axis)); if (intersection.width == 0 || intersection.height == 0) { light.drawText = false; } else { light.drawText = true; if (Blaze.WasPressed(Keys.E)) { if (!light.lit) { if (lights > 0) { lights--; light.lit = true; } } else { lights++; light.lit = false; } } } } var ex = box.Project(axis).GetIntersection(Playing.Instance.exit.box.Project(axis)); if (ex.width != 0 && ex.height != 0 && canCollide) { if (Blaze.WasPressed(Keys.E)) { Blaze.instance.settings.levelUnlocked = Math.Max(Blaze.instance.settings.levelUnlocked, Playing.Instance.levelNum + 1); Blaze.instance.SaveSettings(); Playing.Instance.LoadLevel(Playing.Instance.levelNum + 1); } Playing.Instance.exit.drawText = true; } else { Playing.Instance.exit.drawText = false; } }