/// <summary> /// Create the main menu. /// </summary> /// <param name="game">The game instance.</param> public MainMenu(GammaDraconis game) : base(game) { skybox = new Skybox(); screenScene.track(skybox, GO_TYPE.SKYBOX); Skybox.lights[0] = new Light(new Vector3(-0.05f, 0.1f, -1f), new Vector3(0.9f, 0.7f, 0.7f), new Vector3(1f,1f,1f)); Skybox.lights[1] = new Light(new Vector3(0.95f, -0.9f, 1f), new Vector3(0.4f, 0.4f, 0.4f), new Vector3(0.5f, 0.5f, 0.5f)); racer = (((new Random()).Next(1, 3) == 1) ? Proto.getRacer("Thor") : Proto.getRacer("Raptor")); racer.position = new Coords(startLocation.X, startLocation.Y, startLocation.Z, 0.2f, 1.5f, 1.0f); racer.models[0].scale *= 1; racer.size *= 1; screenScene.track(racer, GO_TYPE.RACER); GameObject planet = new GameObject(); planet.position = new Coords(500f, -300f, -1250f); planet.models.Add(new FBXModel("Resources/Models/Planet", "", 1f)); screenScene.track(planet, GO_TYPE.SCENERY); Sprite NameText = new Sprite(game); NameText.textureName = "Resources/Textures/Logo"; NameText.RelativeRotation = 0.2f; NameText.RelativePosition = new Vector2(300.0f, 20.0f); screenInterface.AddComponent(NameText); }
/// <summary> /// Create a race manager. /// </summary> /// <param name="course">The race course</param> /// <param name="racers">The racers</param> public Race(Course course, Racer[] racers) { this.course = course; this.laps = (course.loop ? course.laps : 1); state = new Dictionary<Racer, int>(); foreach (Racer racer in racers) { state.Add(racer, 0); } finishedRacers = new List<Racer>(); }
/// <summary> /// Create Racer object from ship definition. /// </summary> /// <param name="ship">The target ship</param> /// <returns>New Racer object</returns> public static Racer cloneShip(GameObject ship) { Racer go = new Racer(); go.mass = ship.mass; go.size = ship.size; if (ship.explosion != null) { go.explosion = ship.explosion.clone(); } go.rateL = ship.rateL; go.rateR = ship.rateR; go.dragL = ship.dragL; go.dragR = ship.dragR; foreach (FBXModel model in ship.models) { go.models.Add(model.clone()); } if (ship.shieldModel != null) { go.shieldModel = ship.shieldModel.clone(); } foreach(MountPoint mount in ship.mounts) { go.mounts.Add(mount.clone()); } foreach (Turret turret in ship.turrets) { go.turrets.Add(turret.clone()); } go.relativeLookAt = new Vector3(ship.relativeLookAt.X, ship.relativeLookAt.Y, ship.relativeLookAt.Z); go.relativeLookFrom = new Vector3(ship.relativeLookFrom.X, ship.relativeLookFrom.Y, ship.relativeLookFrom.Z); go.relationalScale = ship.relationalScale; go.thrusterSFX = ship.thrusterSFX; go.engine_startSFX = ship.engine_startSFX; go.onDeathSound = ship.onDeathSound; return go; }
/// <summary> /// Create this menu. /// </summary> /// <param name="game">The game instance.</param> public VideoSettingsMenu(GammaDraconis game) : base(game) { skybox = new Skybox(); screenScene.track(skybox, GO_TYPE.SKYBOX); racer = Proto.getRacer("Raptor"); racer.position = new Coords(startLocation.X, startLocation.Y, startLocation.Z, 0.2f, 1.5f, 1.0f); racer.models[0].scale *= 1; racer.size *= 1; screenScene.track(racer, GO_TYPE.RACER); GameObject planet = new GameObject(); planet.position = new Coords(500f, -300f, -1250f); planet.models.Add(new FBXModel("Resources/Models/Planet", "", 1f)); screenScene.track(planet, GO_TYPE.SCENERY); Sprite NameText = new Sprite(game); NameText.textureName = "Resources/Textures/Logo"; NameText.RelativeRotation = 0.2f; NameText.RelativePosition = new Vector2(300.0f, 20.0f); screenInterface.AddComponent(NameText); }
/// <summary> /// Clone a racer object /// </summary> /// <returns>The cloned racer</returns> public virtual Racer clone() { Racer go = new Racer(); go.mass = mass; go.size = size; if (explosion != null) { go.explosion = explosion.clone(); } go.rateL = rateL; go.rateR = rateR; go.dragL = dragL; go.dragR = dragR; foreach (FBXModel model in models) { go.models.Add(model.clone()); } if (shieldModel != null) { go.shieldModel = shieldModel.clone(); } foreach(MountPoint mount in mounts) { go.mounts.Add(mount.clone()); } foreach (Turret turret in turrets) { go.turrets.Add(turret.clone()); } go.relativeLookAt = new Vector3(relativeLookAt.X, relativeLookAt.Y, relativeLookAt.Z); go.relativeLookFrom = new Vector3(relativeLookFrom.X, relativeLookFrom.Y, relativeLookFrom.Z); go.relationalScale = relationalScale; return go; }
/// <summary> /// Get an upcoming coordinate for the given racer. /// </summary> /// <param name="racer">The racer object</param> /// <param name="offset">How many coordinates forward in the race</param> /// <returns>Coordinate object, or Null if past end of race</returns> public Checkpoint checkpoint(Racer racer, int offset) { RaceStatus info = status(racer, true); int lap = info.lap; int point = info.checkpoint + offset; while (point > course.path.Count) { if (course.loop) { if (lap >= laps && point == course.checkpoints.Count + 1) { return course.checkpoints[0]; } } else { // past end of course return null; } lap++; point -= course.path.Count; } if (point == 0) { point = course.path.Count; } return course.checkpoints[point - 1].clone(); }
/// <summary> /// Get a the lap and checkpoint /// </summary> /// <param name="racer"></param> /// <param name="minimal"></param> /// <returns></returns> public RaceStatus status(Racer racer, bool minimal) { int status = state[racer]; RaceStatus raceStatus = new RaceStatus(); raceStatus.lap = status / course.path.Count + 1; raceStatus.checkpoint = status % course.path.Count + 1; if (!minimal) { raceStatus.place = finishedRacers.IndexOf(racer) + 1; raceStatus.leading = 0; raceStatus.following = 0; foreach (Racer r in new List<Racer>(state.Keys)) { if( r != racer ) { if (state[r] < status) { raceStatus.leading++; } else if (state[r] > status) { raceStatus.following++; } } } } return raceStatus; }
/// <summary> /// Get a the lap and checkpoint /// </summary> /// <param name="racer"></param> /// <returns></returns> public RaceStatus status(Racer racer) { return status(racer, false); }
/// <summary> /// Get the next checkpoint a racer must reach. /// </summary> /// <param name="racer"></param> /// <returns></returns> public Checkpoint nextCheckpoint(Racer racer) { return checkpoint(racer, 1); }