public void HandleInputs() { if (_raceTrack?.Players != null) { foreach (var player in _raceTrack?.Players) { if (Input.GetKeyDown(player.MovementKeyLeft)) { _raceTrack.MoveLeft(player); } else if (Input.GetKeyDown(player.MovementKeyRight)) { _raceTrack.MoveRight(player); } else if (Input.GetKeyDown(player.MovementKeySwapDirection)) { player.SwapDirection(); } } } if (Input.GetKeyDown(KeyCode.Escape)) { _raceTrack?.Destroy(); _raceTrack = null; Status = GameStatus.None; menuScript.Show(); } }
public static void GetRaceTrackEntity(out double lapDistrance, out int numberOfLaps, out TimeSpan timeToPitstop, out RaceTrack rt) { lapDistrance = 40; numberOfLaps = 10; timeToPitstop = new TimeSpan(600); rt = new RaceTrack(lapDistrance, numberOfLaps, timeToPitstop); }
public void Initialize() { try { //Entity framework memory for DAL testing var myDatabaseName = "mydatabase_" + DateTime.Now.ToFileTimeUtc(); var options = new DbContextOptionsBuilder <CoreCRUDContext>() .UseInMemoryDatabase(databaseName: myDatabaseName) .Options; _context = new CoreCRUDContext(options); raceTrack1 = new RaceTrack { RaceTrackId = 1, Name = "track1", vehicles = new List <Vehicle>() }; _context.RaceTracks.AddRange( raceTrack1 ); _context.SaveChanges(); } catch (Exception ex) { throw ex; } }
public static void GetCarConfigurationEntity(RaceTrack raceTrack, out Guid trackId, out double fuelCapacity, out TimeSpan timePerLap, out double fuelConsumptionPerLap, out CarConfiguration carConfig) { trackId = raceTrack.TrackId; fuelCapacity = 20; timePerLap = new TimeSpan(1800); fuelConsumptionPerLap = 5; carConfig = new CarConfiguration(raceTrack, fuelCapacity, timePerLap, fuelConsumptionPerLap); }
public EditorViewModel() { DisplayName = "Magnus bana"; Numbers = new List <int> { 1, 2, 3, 4, 5, 6, 7, 8 }; RaceTrack = new RaceTrack(DisplayName); }
private void BtnStartRace_Click(object sender, System.Windows.RoutedEventArgs e) { if (cmbRace.SelectedIndex > -1) { int selectedIndex = cmbRace.SelectedIndex; RaceTrack raceTrack = listOfRaceTracks[selectedIndex]; NavigationService.Navigate(new Race(listOfDrivers, raceTrack)); } }
public RacingExample() : base("RacingExample") { ClearColor = Color.Black; G.World.Add(player1 = new PhysicsCar()); G.World.Add(player2 = new PhysicsCar()); G.World.Add(track = new RaceTrack()); player2.Position = player1.Position + new Vector2(100, 0); G.World.Camera.Offset = G.ScreenCenter; }
public void CarCanFinishWithCarThatCannotFinish() { int speed = 1; int batteryDrain = 20; var car = new RemoteControlCar(speed, batteryDrain); int distance = 678; var race = new RaceTrack(distance); Assert.False(race.CarCanFinish(car)); }
public void Car_can_finish_with_car_that_just_cannot_finish() { int speed = 3; int batteryDrain = 20; var car = new RemoteControlCar(speed, batteryDrain); int distance = 16; var race = new RaceTrack(distance); Assert.False(race.CarCanFinish(car)); }
public void Car_can_finish_with_car_that_can_easily_finish() { int speed = 10; int batteryDrain = 2; var car = new RemoteControlCar(speed, batteryDrain); int distance = 100; var race = new RaceTrack(distance); Assert.True(race.CarCanFinish(car)); }
public void CarCanFinishWithCarThatCanJustFinish() { int speed = 2; int batteryDrain = 10; var car = new RemoteControlCar(speed, batteryDrain); int distance = 20; var race = new RaceTrack(distance); Assert.True(race.CarCanFinish(car)); }
public void Car_can_finish_with_car_that_can_just_finish() { int speed = 2; int batteryDrain = 10; var car = new RemoteControlCar(speed, batteryDrain); int distance = 20; var race = new RaceTrack(distance); Assert.True(race.TryFinishTrack(car)); }
public void Awake() { Instance = this; // get checkpoints this.checkpoints = this.GetComponentsInChildren <Checkpoint>(); // setup checkpoints for (int i = 0; i < this.checkpoints.Length; ++i) { this.checkpoints[i].Setup(this, i == this.checkpoints.Length - 1 ? this.checkpoints[0] : this.checkpoints[i + 1]); } }
public void CreateDataTest() { var raceTrack2 = new RaceTrack { RaceTrackId = 2, Name = "track2", vehicles = new List <Vehicle>() }; var addedTrack = new RaceTrackService(_context, raceTrack1).CreateData(raceTrack2); Assert.IsNotNull(addedTrack); Assert.AreEqual(raceTrack2, addedTrack); }
public void DeleteRaceTrack(RaceTrack raceTrack) { using (var connection = new SqlConnection(Connection.Instance.ConnectionString)) { connection.Execute(@" DELETE FROM RaceTrack WHERE RaceTrackId = @RaceTrackId ", new { RaceTrackId = raceTrack.RaceTrackId } ); } }
private void BtnDeleteRaceTrack_Click(object sender, RoutedEventArgs e) { try { RaceTrack raceTrack = (RaceTrack)dgAllRaceTracks.SelectedItem; DatabaseManager.Instance.RaceTrackRepository.DeleteRaceTrack(raceTrack); NavigationService.Navigate(new ShowRaceTracks()); } catch (Exception) { MessageBox.Show("Select a racetrack"); } }
public void AddRaceTrack(RaceTrack raceTrack) { using (var connection = new SqlConnection(Connection.Instance.ConnectionString)) { connection.Execute(@" INSERT INTO RaceTrack (RaceTrackId, Name, Length) VALUES (@RaceTrackId, @Name, @Length) ", new { RaceTrackId = raceTrack.RaceTrackId, Name = raceTrack.Name, Length = raceTrack.Length }); } }
static async Task Main(string[] args) { RaceTrack raceTrack = new RaceTrack(1000, 3, new TimeSpan(TimeSpan.TicksPerSecond * 20)); long seconds = TimeSpan.TicksPerSecond * 60; TimeSpan timePerLap = new TimeSpan(seconds); // 60 seconds per lap CarConfiguration carConiguration = new CarConfiguration(raceTrack, 20, timePerLap, 40); RaceCar car1 = new RaceCar(carConiguration); RaceCar car2 = new RaceCar(carConiguration); List <RaceCar> raceCars = new List <RaceCar>(); Console.WriteLine($"Current Thread Id: {Thread.CurrentThread.ManagedThreadId}"); raceCars.Add(car1); raceCars.Add(car2); //await RunAll(raceCars); await RunAllParalle(raceCars); }
static void Main(string[] args) { List <IDriver> drivers = new List <IDriver>(); List <ITrack> tracks = new List <ITrack>(); try { for (int i = 15; i < 75; i += 7) { IDriver driver = new Driver("Ivan", i); ITrack track = new RaceTrack(i * 1.23, i - 4, "tarmac", i % 2 == 0 ? true : false); drivers.Add(driver); tracks.Add(track); } IDriver bmwDriver = drivers.FirstOrDefault(d => d.Age > 25 && d.Age < 45); IEnumerable <ITrack> openTracks = tracks.Where(t => t.IsOpenAllYear == true); ITrack currentTrack = openTracks.FirstOrDefault(t => t.CornersCount > 25); ICar bmw = new BMW(2005, "M5", 507, bmwDriver, currentTrack); string resultReport = GetInfo(currentTrack, bmw); string path = @"D:\RacetrackReport.txt"; if (!File.Exists(path)) { using (StreamWriter sw = File.CreateText(path)) { sw.WriteLine(resultReport); } } else { using (StreamWriter sw = File.AppendText(path)) { sw.WriteLine(resultReport); } } } catch (Exception ex) { Console.WriteLine(ex.Message); } }
public override void OnInspectorGUI() { RaceTrack mapGen = (RaceTrack)target; if (DrawDefaultInspector()) { if (mapGen.autoUpdate) { mapGen.generateTrack(); } } if (GUILayout.Button("Generate")) { mapGen.generateTrack(); } }
public void StartGame() { var levelDto = _levelsData.Find(levelData => levelData.name == "Level 01 - Test"); var circlePaths = levelDto?.radii .Select(radius => new CirclePath(radius)) .ToList <SinglePath>(); var players = new List <TrackPlayer> { new TrackPlayer("Player 1", "q", "w", "e"), new TrackPlayer("Player 2", "o", "p", "l") }; _raceTrack = new RaceTrack(players, circlePaths); Status = GameStatus.Running; }
public void UpdateDataTest() { var track = new RaceTrack { RaceTrackId = 1, Name = "track2", vehicles = new List <Vehicle>() }; var result = new RaceTrackService(_context, raceTrack1).UpdateData(track); Assert.AreEqual(raceTrack1.Name, result.Name); track.RaceTrackId = 2; var result2 = new RaceTrackService(_context, raceTrack1).UpdateData(track); Assert.IsNull(result2); }
public Race(List <Driver> inputListOfDrivers, RaceTrack inputRaceTrack) { InitializeComponent(); btnFinishRace.IsEnabled = false; foreach (var driver in inputListOfDrivers) { RaceParticipant participant = new RaceParticipant(driver); listOfParticipants.Add(participant); } race = new BL.Models.Race(listOfParticipants, inputRaceTrack); raceEngine = new RaceLogic(race.RaceLength); dgParticipants.ItemsSource = listOfParticipants; }
public SimpleRaceMode(GameManager gameInstance, int laps, int noOfCheckpoints, RaceTrack raceTrack, Car localCar) : base(gameInstance) { this.laps = laps; this.checkpoints = noOfCheckpoints; this.raceTrack = raceTrack; this.car = localCar; this.placementRasterization = raceTrack.GetCurveRasterization(100); PlayerPlace = 1; GameStarted = false; TotalRaceTime = TimeSpan.Zero; var player = gameInstance.GetService <Player>(); player.Lap = 0; players.Add(player); Initialize(); }
public RaceTrack UpdateData(RaceTrack raceTrack) { try { var entity = _context.RaceTracks.SingleOrDefault(x => x.RaceTrackId.Equals(raceTrack.RaceTrackId)); if (entity == null) { return(null); } entity.Name = raceTrack.Name; entity.vehicles = raceTrack.vehicles; _context.RaceTracks.Update(entity); _context.SaveChanges(); return(entity); } catch (Exception ex) { throw ex; } }
// Use this for initialization void Start () { if(PlayerMain.LOCAL==null) { Application.LoadLevel("Preload"); return; } REF = this; /*if(debugRace) { GameObject[] g = GameObject.FindGameObjectsWithTag("Player"); for(int i = 0;i<g.Length;i++) { g[i].GetComponent<HorseController>().debugInit(PlayerMain.LOCAL.horses[i]); } }*/ for(int i = 0;i<racingLines.Count;i++) { racingLines[i].initLine(i); } SmartfoxConnectionHandler.REF.onRaceHostChanged += onRaceHostChanged; if(SmartfoxConnectionHandler.REF!=null) SmartfoxConnectionHandler.REF.onRaceStatusChange += onRaceStatusChange; }
public void loadMap(RaceTrack track, int triangleSize) { Vector3 trackCoordinate = Vector3.Zero; Vector3 offsetVector = new Vector3(Size / 2, 0, Size / 2); for (float f = 0; f <= 1; f += 0.001f) { trackCoordinate = track.Curve.GetPoint(f); trackCoordinate = trackCoordinate / triangleSize; trackCoordinate += offsetVector; for (int x = -4; x < 4; x++) { for (int z = -4; z < 4; z++) { Heights[(int)trackCoordinate.X + x, (int)trackCoordinate.Z + z] = 0.5f; } } } }
private void BtnAddRaceTrack_Click(object sender, RoutedEventArgs e) { bool checkIfInputIsCorrect = true; if (string.IsNullOrEmpty(txtRaceTrackName.Text)) { MessageBox.Show("The new track needs a name"); checkIfInputIsCorrect = false; } if (string.IsNullOrEmpty(txtRaceTrackLength.Text)) { MessageBox.Show("We need to know how long the track is"); checkIfInputIsCorrect = false; } else if (!Int32.TryParse(txtRaceTrackLength.Text, out length)) { MessageBox.Show("The length needs to be a number"); checkIfInputIsCorrect = false; } else if (length < 1) { MessageBox.Show("The length needs to be a positive number"); checkIfInputIsCorrect = false; } if (checkIfInputIsCorrect) { name = txtRaceTrackName.Text; RaceTrack newRaceTrack = new RaceTrack(name, length); DatabaseManager.Instance.RaceTrackRepository.AddRaceTrack(newRaceTrack); NavigationService.Navigate(new ShowRaceTracks()); } }
public void Setup(RaceTrack raceTrack, Checkpoint nextCheckpoint) { this.raceTrack = raceTrack; this.nextCheckpoint = nextCheckpoint; }
public MultiplayerRaceMode(GameManager gameInstance, int laps, int noOfCheckpoints, RaceTrack raceTrack, Car localCar) : base(gameInstance, laps, noOfCheckpoints, raceTrack, localCar) { this.Mode = Mode.Multiplayer; players.AddRange(gameInstance.GetService <ServerClient>().Players.Values); AddLapTriggers(); }
public static void Init(RaceTrackContext context) { context.Database.EnsureDeleted(); context.Database.EnsureCreated(); var raceTrack = new RaceTrack() { Capacity = 5, AllowedVehicleTypes = new VehicleTypeC[] { new VehicleTypeC { VehicleType = VehicleType.CAR }, new VehicleTypeC() { VehicleType = VehicleType.TRUCK } } }; context.RaceTracks.Add(raceTrack); var conditions = new List <Condition>() { new Condition() { Id = "STR", Description = "Tow Strap on the vehicle" }, new Condition() { Id = "LIF", Description = "Not lifted more than 5 inches" }, new Condition() { Id = "WER", Description = "Less than 85% tire wear" } }; context.Conditions.AddRange(conditions.ToArray()); context.SaveChanges(); context.Vehicles.Add(new Vehicle() { VehicleType = VehicleType.CAR }); var conditionLookups = new List <VehicleTypeCondtionLookUp>() { new VehicleTypeCondtionLookUp() { VehicleType = VehicleType.CAR, ConditionCode = "WER" }, new VehicleTypeCondtionLookUp() { VehicleType = VehicleType.CAR, ConditionCode = "STR" }, new VehicleTypeCondtionLookUp() { VehicleType = VehicleType.TRUCK, ConditionCode = "STR" }, new VehicleTypeCondtionLookUp() { VehicleType = VehicleType.TRUCK, ConditionCode = "LIF" } }; context.VehicleTypeCondtionLookUps.AddRange(conditionLookups.ToArray()); context.SaveChanges(); context.SaveChanges(); }
static void Main(string[] args) { RaceTrack c = new RaceTrack(); object o = c.judgePositions(324, 6, new int[] {16, 28, 31, 61, 62, 70, 78, 149, 160, 171, 201, 228, 238, 241, 271, 287, 295, 310}); PrintObj(o); System.Console.In.ReadLine(); }
private static void SetEditMode(bool on) { EditTrack = on; RaceTrack.SetEditMode(on); }