void CmdEnterVehicle(Vector3 origin, Vector3 direction) { RaycastHit hit; Ray ray = new Ray(origin, direction); Debug.DrawRay(ray.origin, ray.direction * 3f, Color.red, 1f); bool result = Physics.Raycast(ray, out hit, range); if (result) { TestCar vehicle = hit.transform.GetComponent <TestCar>(); if (hit.transform.tag == "Vehicle") { //Destroy(hit.transform.gameObject); vehicle.enabled = true; EnterVehicle(); this.gameObject.transform.parent = vehicle.gameObject.transform.Find("DriverSeat"); //this.gameObject.transform. = new Vector3(0, 0, 0); this.gameObject.transform.position = new Vector3(0, 0, 0); this.gameObject.transform.rotation = new Quaternion(0, 0, 0, 0); } } }
public ActionResult DeleteConfirmed(int id) { TestCar testCar = db.TestCar.Find(id); db.TestCar.Remove(testCar); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "TestCarId,new_name,confirm_name")] TestCar testCar) { if (ModelState.IsValid) { db.Entry(testCar).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(testCar)); }
public void Update(int id, TestCar testCar) { var test_car = db.TestCars.Where(u => u.id == id).FirstOrDefault(); //to-do //... db.TestCars.Add(test_car); db.SaveChanges(); }
static void Main(string[] args) { TestCar aTestCar = new TestCar(); aTestCar[0] = new Car(); aTestCar[1] = new Car(); aTestCar[0].name = "비오는 날에는 소시지빵"; aTestCar[1].name = "게임은 폭력적이다"; Console.WriteLine(aTestCar[0].name); }
public void should_Create_New() { var newCar = new TestCar("Velar"); _testCarRepository.Create(newCar); var car = _testCarRepository.Find(newCar.Id); Assert.NotNull(car); Console.WriteLine(car); }
public void should_Create() { var testEntity = new TestCar("Velar", "X"); _testEntityRepository.CreateAsync(testEntity).Wait(); var newTestEntity = _testEntityRepository.GetAsync(testEntity.Id).Result; Assert.NotNull(newTestEntity); Log.Debug(newTestEntity.ToString()); }
public ActionResult Create([Bind(Include = "TestCarId,new_name,confirm_name")] TestCar testCar) { if (ModelState.IsValid) { db.TestCar.Add(testCar); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(testCar)); }
public void TestCar_Blank() { //arrange var car = new TestCar() { }; //act var value = ObjectToURLStringFactory.Create(car); //assert Assert.Equal("Make=&NumberOfWheels=0&DateOfManufacture=0001-01-01T00%3a00%3a00&RightHandedDrive=false", value); }
public void should_Create_Or_Update_New() { var newCar = new TestCar("Velar"); _testCarRepository.CreateOrUpdate(newCar); _testCarRepository.SaveChanges(); var car = _testCarRepository.Get(newCar.Id); Assert.NotNull(car); Console.WriteLine(car); }
// GET: TestCars/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } TestCar testCar = db.TestCar.Find(id); if (testCar == null) { return(HttpNotFound()); } return(View(testCar)); }
public void TestCar_ReliantRobin() { //arrange var car = new TestCar() { Make = "Reliant", NumberOfWheels = 3, DateOfManufacture = new DateTime(1973, 12, 24), RightHandedDrive = true }; //act var value = ObjectToURLStringFactory.Create(car); //assert Assert.Equal("Make=Reliant&NumberOfWheels=3&DateOfManufacture=1973-12-24T00%3a00%3a00&RightHandedDrive=true", value); }
void Start() { Speed = 40f; m_Car = GetComponent <TestCar>(); }
void Update() { if (GameMaster.GM.selected == transform) { if (agresive) { GameMaster.GM.infoPanel.text = "<color=red><b> car </b> \nSpeed: " + speed.ToString("F1") + "\nMax Speed: " + speedBackup.ToString("F1") + "\nAllowed Speed: " + MaxSpeed.ToString("F1") + "\nLane:</color> " + currentRoadWay; } else { GameMaster.GM.infoPanel.text = "<b> car </b> \nSpeed: " + speed.ToString("F1") + "\nMax Speed: " + speedBackup.ToString("F1") + "\nAllowed Speed: " + MaxSpeed.ToString("F1") + "\n <color=yellow>Lane:</color> " + currentRoadWay; } carMat.material.color = Color.black; } else { if (GameMaster.GM.carSpeedMode) { carMat.material.color = SpeedColor(speed); } else { if (agresive) { carMat.material.color = Color.white; } else { carMat.material.color = colorStart; } } } //AngleTest = Vector2.Angle(transform.right, (from - transform.position)) / 180;// <<<<<<<<<<<<<<<<<<<<<<<<<<< DELETE THIS!! ITS TEST FUNCTION!!!! #region RayCast2D leftStart = transform.position + transform.right * boxCol.size.x / 2 * 1.01f + transform.up * boxCol.size.y / 2; rightStart = transform.position + transform.right * boxCol.size.x / 2 * 1.01f - transform.up * boxCol.size.y / 2; hitInfoL = Physics2D.Raycast(leftStart, transform.right, 5f); hitInfoR = Physics2D.Raycast(rightStart, transform.right, 5f); Debug.DrawRay(leftStart, transform.right); Debug.DrawRay(rightStart, transform.right); if (hitInfoL.collider == boxCol) { Debug.Log("I hit myslef LEFT"); } if (hitInfoR.collider == boxCol) { Debug.Log("I hit myslef RIGHT"); } if (hitInfoL.point == Vector2.zero && hitInfoR.point == Vector2.zero) { //nothing is hit if (speed < 1) { speed += Time.deltaTime * 2; } else { speed += Random.Range(5, 10) * Time.deltaTime; } prevCol = null; otherCar = null; } else { // Something is hit if ((hitInfoL.point - (Vector2)transform.position).magnitude < (hitInfoR.point - (Vector2)transform.position).magnitude) { if (prevCol != hitInfoL.collider && hitInfoL.collider.tag == "Car") { prevCol = hitInfoL.collider; try { otherCar = hitInfoL.collider.GetComponent <TestCar>(); TryChangeLane(); //if (otherCar.speedBackup + 5 < speedBackup) { if (currentRoadWay == roadSize - 1) { currentRoadWay = otherCar.currentRoadWay - 1; } else { currentRoadWay = otherCar.currentRoadWay + 1; } } } catch { } } //speed = 0;//speed = 15 * hitInfoL.fraction; if (Vector3.Distance(leftStart, hitInfoL.point) <= 2f) { try { float tmpspeed = otherCar.speed;//hitInfoL.collider.GetComponent<TestCar>().speed; speed = Mathf.Clamp(speed, 0, tmpspeed); } catch { } } else { try { if (otherCar.speed == 0) { speed -= 25 * Time.deltaTime; } else { speed -= Random.Range(0.8f, 1.2f) * Time.deltaTime; if (speed < otherCar.speed) { speed += Random.Range(0.8f, 1.2f) * Time.deltaTime; } //speed = Mathf.Clamp(speed, otherCar.speed - 0.5f, MaxSpeed); } } catch { } } if (Vector3.Distance(leftStart, hitInfoL.point) < 1f) { speed = 0;//speed = Mathf.Lerp(speed, 0, Time.deltaTime / 4); // FAST BREAK speed = 0 } } else { if (prevCol != hitInfoR.collider && hitInfoR.collider.tag == "Car") { prevCol = hitInfoR.collider; try { otherCar = hitInfoR.collider.GetComponent <TestCar>(); TryChangeLane(); //if (otherCar.speedBackup + 5 < speedBackup) { if (currentRoadWay == roadSize - 1) { currentRoadWay = otherCar.currentRoadWay - 1; } else { currentRoadWay = otherCar.currentRoadWay + 1; } } } catch { } } if (Vector3.Distance(rightStart, hitInfoR.point) <= 2f) { try { float tmpspeed = otherCar.speed;//= hitInfoR.collider.GetComponent<TestCar>().speed; speed = Mathf.Clamp(speed, 0, tmpspeed); } catch { } } else { try { if (otherCar.speed == 0) { speed -= 25 * Time.deltaTime; } else { speed -= Random.Range(0.8f, 1.2f) * Time.deltaTime; if (speed < otherCar.speed) { speed += Random.Range(0.8f, 1.2f) * Time.deltaTime; } //speed = Mathf.Clamp(speed, otherCar.speed - 0.5f, MaxSpeed); } } catch { } } if (Vector3.Distance(rightStart, hitInfoR.point) < 1f) { speed = 0;//speed = Mathf.Lerp(speed, 0, Time.deltaTime / 4); // FAST BREAK speed = 0 } } //Debug.Log((hitInfo.point - (Vector2)transform.position).magnitude); if (hitInfoL.collider != null && hitInfoL.collider.tag == "TrafficLight" || hitInfoR.collider != null && hitInfoR.collider.tag == "TrafficLight") { speed = 0; //speed -= 20 * Time.deltaTime; } } if (agresive) { speed = Mathf.Clamp(speed, 0, speedBackup); speed = Mathf.Clamp(speed, 0, MaxSpeed + 5); } else { speed = Mathf.Clamp(speed, 0, speedBackup); speed = Mathf.Clamp(speed, 0, MaxSpeed); } #endregion #region MoveForward //move transform.position += transform.right * speed * Time.deltaTime; #endregion #region Rotate if (road != null) { //when moving towards last node we whant to change our end point to this: if (i == road.Capacity - 1) { changeNode = road[i].position + new Vector3(to.y, -to.x) * currentRoadWay * 3.5f; } else { if (i < road.Capacity) { if (i == 0) { Vector3 to2 = road[i + 1].position - road[i].position; to2.Normalize(); Vector3 to2Inv = new Vector3(to2.y, -to2.x) * currentRoadWay * 3.5f; changeNode = road[i].position + to2Inv; to = (changeNode - transform.position).normalized; } else { Vector3 to1 = road[i].position - road[i - 1].position; Vector3 to2 = road[i + 1].position - road[i].position; to1.Normalize(); to2.Normalize(); Vector3 to1Inv = new Vector3(to.y, -to.x) * currentRoadWay * 3.5f; Vector3 to2Inv = new Vector3(to2.y, -to2.x) * currentRoadWay * 3.5f; try { changeNode = LineIntersectionPoint(road[i].position + to1Inv, road[i].position + to1Inv + to1, road[i + 1].position + to2Inv, road[i + 1].position + to2Inv + to2); } catch { changeNode = road[i].position + to1Inv; Debug.Log("Lines Are Paralel"); } } } } } if (Vector3.Distance(transform.position, from + new Vector3(to.y, -to.x) * currentRoadWay * 3.5f) < step) { from += to * 2; } Vector3 dir = (from + new Vector3(to.y, -to.x) * currentRoadWay * 3.5f) - transform.position; float angle = Mathf.Atan2(dir.y, dir.x) * Mathf.Rad2Deg; Quaternion q = Quaternion.AngleAxis(angle, Vector3.forward); //float rotateSpeed = turnSpeed * (speed / MaxSpeed) * (1-AngleTest); float rotateSpeed = turnSpeed * (speed / MaxSpeed); transform.rotation = Quaternion.Slerp(transform.rotation, q, Time.deltaTime * rotateSpeed); //Debug.DrawRay(from + new Vector3(to.y, -to.x) * currentRoadWay * 3.5f, to); //Debug.DrawRay(changeNode, to); #endregion #region waypointNodeChange if (road != null && i < road.Capacity) { //Vector3 target = road[i].position; if (Vector3.Distance(changeNode, transform.position) < step) { if (i < road.Capacity - 1) { //from = road[i].position; to = (road[i + 1].position - road[i].position).normalized; to.z = 0; from = changeNode + new Vector3(-to.y, to.x).normalized *currentRoadWay * 3.5f; i++; //i = Mathf.Clamp(i, 0, road.Capacity); } else //on last node take direction normal from last - prelast nodes { from = road[i].position; to = (road[i].position - road[i - 1].position).normalized; to.z = 0; i++; } } } #endregion if (prevTimeTryChangeLane < Time.time) { if (speed < 5) { if (agresive) { prevTimeTryChangeLane = Time.time + Random.Range(0, 2); } else { prevTimeTryChangeLane = Time.time + Random.Range(0, 5); } } else { if (agresive) { prevTimeTryChangeLane = Time.time + Random.Range(3, 5); } else { prevTimeTryChangeLane = Time.time + Random.Range(10, 20); } TryChangeLane2(); } } currentRoadWay = Mathf.Clamp(currentRoadWay, 0, (int)(roadSize - 1)); //Debug.DrawLine(rightStart + ((-transform.up) * 3.0f), rightStart + ((-transform.up) * 3.0f) + (transform.right * (-9f))); }
private TestCar2 m_Car2; // the car controller we want to use private void Awake() { // get the car controller m_Car = GetComponent <TestCar>(); m_Car2 = GetComponent <TestCar2>(); }
protected override void Seed(CoinTrust.DataAccessLayer.TestCarContext context) { //This method will be called after migrating to the latest version. //You can use the DbSet<T>.AddOrUpdate() helper extension method //to avoid creating duplicate seed data. //This method will be called after migrating to the latest version. //You can use the DbSet<T>.AddOrUpdate() helper extension method //to avoid creating duplicate seed data. /* * Car Owner type wheel * gtr YY C 16 17 * gt86 PL D 17 18 * z4 YY B 16 18 * m5 YY A 17 19 */ TestCar gtr = new TestCar(); TestCar gt86 = new TestCar(); TestCar z4 = new TestCar(); TestCar m5 = new TestCar(); TestCarKey gtrk = new TestCarKey(); TestCarKey gt86k = new TestCarKey(); TestCarKey z4k = new TestCarKey(); TestCarKey m5k = new TestCarKey(); TestCarOwner YY = new TestCarOwner(); TestCarOwner PL = new TestCarOwner(); TestCarWheel wh16 = new TestCarWheel(); TestCarWheel wh17 = new TestCarWheel(); TestCarWheel wh18 = new TestCarWheel(); TestCarWheel wh19 = new TestCarWheel(); gtr.Name = "GTR"; gtr.TestCarWheel = new List <TestCarWheel> { wh16, wh17 }; gtr.TestCarOwner = YY; gt86.Name = "GT86"; gt86.TestCarWheel = new List <TestCarWheel> { wh17, wh18 }; gt86.TestCarOwner = PL; z4.Name = "Z4"; z4.TestCarWheel = new List <TestCarWheel> { wh16, wh18 }; z4.TestCarOwner = YY; m5.Name = "M5"; m5.TestCarWheel = new List <TestCarWheel> { wh17, wh19 }; m5.TestCarOwner = YY; YY.TestCar = new List <TestCar> { gtr, z4, m5 }; YY.Name = "Yung Yuan"; PL.TestCar = new List <TestCar> { gt86 }; PL.Name = "Pin Lun"; wh16.TestCar = new List <TestCar> { gtr, z4 }; wh16.Size = 16; wh17.TestCar = new List <TestCar> { gtr, gt86, m5 }; wh17.Size = 17; wh18.TestCar = new List <TestCar> { gt86, z4 }; wh18.Size = 18; wh19.TestCar = new List <TestCar> { m5 }; wh19.Size = 19; context.TestCarOwner.Add(YY); context.TestCarOwner.Add(PL); context.TestCarWheel.Add(wh16); context.TestCarWheel.Add(wh17); context.TestCarWheel.Add(wh18); context.TestCarWheel.Add(wh19); context.TestCar.Add(gtr); context.TestCar.Add(gt86); context.TestCar.Add(z4); context.TestCar.Add(m5); context.SaveChanges(); gtrk.Type = "C"; gtrk.TestCarId = gtr.CarId; gt86k.Type = "D"; gt86k.TestCarId = gt86.CarId; z4k.Type = "B"; z4k.TestCarId = z4.CarId; m5k.Type = "A"; m5k.TestCarId = m5.CarId; context.TestCarKey.Add(gtrk); context.TestCarKey.Add(gt86k); context.TestCarKey.Add(z4k); context.TestCarKey.Add(m5k); context.SaveChanges(); }
public void TestCase1() { var car = new DevCode.Car(); var testCar = new TestCar(); }
public void insert(TestCar testCar) { db.TestCars.Add(testCar); db.SaveChanges(); }