public CarUpdate Update(float t, float h, float carAngle) { currentOrientation = carAngle; /*if (Mathf.Abs(h) < lastHAbs) { * this.wheelsOrientation = currentOrientation; * } else {*/ wheelsOrientation = -h * maxWheelsOrientation; //} lastHAbs = Mathf.Abs(h); float vertical_gap = (t * velocity.magnitude) * -Mathf.Sin(wheelsOrientation); //velocity = new Vector3(Mathf.Min(velocity.x - Mathf.Abs(vertical_gap), baseSpeed) , Mathf.Max(0, velocity.y - Mathf.Abs(vertical_gap)), velocity.z); //Solving SAS Triangle float b = velocity.magnitude; float c = width; float angleA = (Mathf.PI / 2 + (Mathf.PI / 2 - Mathf.Abs(wheelsOrientation)) - Mathf.Abs(currentOrientation)); float a = Mathf.Sqrt(b * b + c * c - 2 * b * c * Mathf.Cos(angleA)); float angleB = Mathf.Sign(-h) * Mathf.Asin(b * Mathf.Sin(angleA) / a); Vector3 deltaPosition = new Vector3(vertical_gap, 0, 0); CarUpdate carUpdate = new CarUpdate(angleB * Mathf.Rad2Deg, wheelsOrientation * Mathf.Rad2Deg, deltaPosition); return(carUpdate); }
public IActionResult Update(CarUpdate model) { if (!ModelState.IsValid) { return(BadRequest()); } _carService.Update(model, User.Claims); return(Ok()); }
public void CarUpdate(CarUpdate request) { using (SqlConnection con = new SqlConnection("Server=den1.mssql5.gear.host;Database=carstest;User Id=carstest;Password=Hy19Ks!-Kom3")) { con.Open(); SqlCommand cmd = con.CreateCommand(); cmd.CommandText = "cars_update"; cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@Id", request.Id); cmd.Parameters.AddWithValue("@Make", request.Make); cmd.Parameters.AddWithValue("@Model", request.Model); cmd.Parameters.AddWithValue("@Year", request.Year); cmd.Parameters.AddWithValue("@Color", request.Color); cmd.ExecuteNonQuery(); } }
public HttpResponseMessage CarUpdate(int Id, CarUpdate updateRequest) { CarsService carsService = new CarsService(); if (updateRequest == null) { ModelState.AddModelError("", "missing model"); } else if (Id != updateRequest.Id) { ModelState.AddModelError("Id", "id does not match URL"); } if (!ModelState.IsValid) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState)); } carsService.CarUpdate(updateRequest); return(Request.CreateResponse(HttpStatusCode.OK)); }
public void Update(CarUpdate model, IEnumerable <Claim> claims) { var entity = _dbContext.Cars.SingleOrDefault(m => m.Id == model.Id); if (entity == null) { throw new NotFoundException(nameof(Car), model.Id); } if (!_authorizationService.AllowModifyEntity(claims, entity.UserId)) { throw new NotAuthorizedException(); } entity.CarMakeId = model.CarMakeId; entity.Country = model.Country; entity.CarModelId = model.CarModelId; entity.Price = model.Price; entity.DateOfProduction = model.DateOfProduction; _dbContext.Cars.Update(entity); _dbContext.SaveChanges(); }
public void GetCarUpdate(string name) { string filePath = "Assets/carUpdate.json"; if (File.Exists(filePath)) { // Read the json from the file into a string string dataAsJson = File.ReadAllText(filePath); // Pass the json to JsonUtility, and tell it to create a GameData object from it CarUpdate loadedData = JsonUtility.FromJson <CarUpdate>(dataAsJson); // TODO: // 1.) Compare queues // 2.) If different, adjust sim car queue and position Debug.Log(loadedData.actionQueue); GameObject vehicle = GameObject.Find(name); if (vehicle != null) { car = (Vehicle)vehicle.GetComponent("Vehicle"); int simQueueLen = car.GetCurrPathLength() - car.GetCurr(); // Path is full length, minus nodes we reached if (simQueueLen != loadedData.actionQueue.Length) { // Simulation is behind if (simQueueLen > loadedData.actionQueue.Length) { } else { } } } } else { Debug.LogError("Cannot load game data!"); } }
// PUT api/values/5 [HttpPut("{id}")] public bool Put(int id, [FromBody] CarUpdate value) { if (_lstCars.Select(x => x.ID == id).Count() != 1) { return(false); } Car newCar = new Car(id, value); Car oldCar = _lstCars.Where(x => x.ID == id).ElementAt(0); oldCar.Make = newCar.Make; oldCar.Model = newCar.Model; oldCar.Year = newCar.Year; oldCar.Color = newCar.Color; return(true); }
// POST api/values [HttpPost] public int Post([FromBody] CarUpdate value) { Car newCar = new Car(_lstCars.Count() + 1, value); _lstCars.Add(newCar); return(newCar.ID); }