Exemplo n.º 1
0
    protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        int         rowIndex = Convert.ToInt32(e.CommandArgument);
        GridViewRow myRow    = GridView1.Rows[rowIndex];
        Label       veIdLbl  = (Label)myRow.FindControl("VeId");
        Label       veImgLbl = (Label)myRow.FindControl("ImgId");

        Guid veGuid  = Guid.Parse(veIdLbl.Text);
        Guid imgGuid = Guid.Parse(veImgLbl.Text);

        if (e.CommandName == "SetAsMain")
        {
            CarClass cc = new CarClass(Profile.UserName);
            cc.SetMainImage(imgGuid, veGuid);
            BindPage(veGuid);
            UserControl ucx      = (UserControl)LoadControl("~/Controls/UserNoticeModal.ascx");
            Label       txtLabel = (Label)ucx.FindControl("TextLabel");
            txtLabel.Text = "Success!";
            Form.Controls.Add(ucx);
        }
        if (e.CommandName == "DeleteImg")
        {
            using (SwapEntities ent = new SwapEntities())
            {
                var delImg = (from tbl in ent.VeImages
                              where tbl.Id == imgGuid
                              select tbl).SingleOrDefault();

                if (delImg != null)
                {
                    string imgPath    = delImg.ImageUrl;
                    string serverPath = Server.MapPath(imgPath);
                    try
                    {
                        System.IO.File.Delete(serverPath);
                    }
                    catch
                    {
                    }

                    ent.DeleteObject(delImg);
                    ent.SaveChanges();
                    BindPage(veGuid);

                    UserControl ucx      = (UserControl)LoadControl("~/Controls/UserNoticeModal.ascx");
                    Label       txtLabel = (Label)ucx.FindControl("TextLabel");
                    txtLabel.Text = "Success!";
                    Form.Controls.Add(ucx);
                }
            }
        }
    }
Exemplo n.º 2
0
    protected void VeEditListView_ItemCommand(object sender, ListViewCommandEventArgs e)
    {
        string[] commandArgs = e.CommandArgument.ToString().Split(new char[] { ',' });
        string   veId        = commandArgs[0];
        string   veImgId     = commandArgs[1];

        Guid veGuid  = Guid.Parse(veId);
        Guid imgGuid = Guid.Parse(veImgId);

        if (e.CommandName == "SetAsMain")
        {
            CarClass cc = new CarClass(Profile.UserName);
            cc.SetMainImage(imgGuid, veGuid);

            UserControl ucx      = (UserControl)LoadControl("~/Controls/UserNoticeModal.ascx");
            Label       txtLabel = (Label)ucx.FindControl("TextLabel");
            txtLabel.Text = "Success!";
            Form.Controls.Add(ucx);
        }
        if (e.CommandName == "DeleteImg")
        {
            using (SwapEntities ent = new SwapEntities())
            {
                var delImg = (from tbl in ent.VeImages
                              where tbl.Id == imgGuid
                              select tbl).SingleOrDefault();

                if (delImg != null)
                {
                    string imgPath    = delImg.ImageUrl;
                    string serverPath = Server.MapPath(imgPath);
                    try
                    {
                        System.IO.File.Delete(serverPath);
                    }
                    catch
                    {
                    }

                    ent.DeleteObject(delImg);
                    ent.SaveChanges();

                    UserControl ucx      = (UserControl)LoadControl("~/Controls/UserNoticeModal.ascx");
                    Label       txtLabel = (Label)ucx.FindControl("TextLabel");
                    txtLabel.Text = "Success!";
                    Form.Controls.Add(ucx);
                }
            }
        }
        CarsGridView.DataSourceID = "CarsDataSource";
        CarsGridView.DataBind();
    }
Exemplo n.º 3
0
        private CarClass DataTableToCarClass(DataTable dt)
        {
            var row1     = dt.Rows[0];
            var id       = row1.ItemArray[0].ToString();
            var carClass = new CarClass(Guid.Parse(id), row1.ItemArray[2].ToString(), Decimal.Parse(row1.ItemArray[3].ToString()));

            carClass.PublicId   = int.Parse(row1.ItemArray[1].ToString());
            carClass.EditFrom   = row1.ItemArray[4].ToString();
            carClass.CreateFrom = row1.ItemArray[6].ToString();
            carClass.Edit       = DateTime.Parse(row1.ItemArray[5].ToString());
            carClass.Create     = DateTime.Parse(row1.ItemArray[7].ToString());
            return(carClass);
        }
Exemplo n.º 4
0
 public static void Main()
 {
     CarValue <int> c = new CarValue <int>();                    // struct 성공
     //CarValue<string> c = new CarValue<string>();
     CarReference <string> cs = new CarReference <string>();     // class 성공
     //CarReference<decimal> cs = new CarReference<decimal>();
     CarNew <GoodCar> cn = new CarNew <GoodCar>();               // new() 성공
     //CarNew<BadCar> bad = new CarNew<BadCar>();
     CarClass <OfficeCamper> cc = new CarClass <OfficeCamper>(); // 사용자 정의 타입
     //CarClass<BadCar> badCar;
     CarInterface <IKs> h = new CarInterface <IKs>();            // 인터페이스 지정
     //CarInterface<object> ie;
 }
Exemplo n.º 5
0
 private void btn_create_car_Click(object sender, EventArgs e)
 {
     try
     {
         CarClass c = new CarClass(txt_make.Text, txt_model.Text, int.Parse(txt_mileage.Text), decimal.Parse(txt_price.Text));
         myStore.CarList.Add(c);
     }
     catch (FormatException a)
     {
         MessageBox.Show("please use numbers for mileage and price");
     }
     carInventoryBindingSource.ResetBindings(false);
 }
Exemplo n.º 6
0
        private static ICarFactory LoadCarFactory(CarClass car)
        {
            switch (car)
            {
            case CarClass.Toyota:
                return(new ToyotaFactory());

            case CarClass.Benz:
                return(new BenzFactory());

            default:
                return(new ToyotaFactory());
            }
        }
Exemplo n.º 7
0
        public void Post_CarClass_IsTrue()
        {
            var carclass = new CarClass()
            {
                Class = "Ichwerdegeloescht", CostsPerDay = 1000m
            };
            DbContextOptionsBuilder <CarRentDBContext> builder = new DbContextOptionsBuilder <CarRentDBContext>();

            builder.UseInMemoryDatabase("CarRent");
            DbContextOptions <CarRentDBContext> options = builder.Options;
            CarRentDBContext carrent = new CarRentDBContext(options);

            ExampleData.ExampleData.InitTestData(carrent);
            var carclasscontroller = new CarClassesController(carrent);

            if (carrent.CarClasses.Any(e => e.Class == carclass.Class))
            {
                int index        = 0;
                var carclasslist = carclasscontroller.GetCarClasses();
                foreach (var cclass in carclasslist)
                {
                    if (!cclass.Class.Equals(carclass.Class))
                    {
                        continue;
                    }
                    index = cclass.Id;
                }

                carclasscontroller.DeleteCarClass(index);
            }

            carclasscontroller.PostCarClass(carclass);

            var bOk = false;
            var ind = 0;

            foreach (var carsclasses in carclasscontroller.GetCarClasses())
            {
                if (carsclasses.Class.Equals(carclass.Class) && carsclasses.CostsPerDay == carclass.CostsPerDay)
                {
                    bOk = true;
                    ind = carsclasses.Id;
                    break;
                }
            }

            carclasscontroller.DeleteCarClass(ind);
            Assert.IsTrue(bOk);
        }
Exemplo n.º 8
0
    protected void ScheduleListView_ItemDataBound(object sender, ListViewItemEventArgs e)
    {
        ListViewItem myItem      = (ListViewItem)e.Item;
        Label        userMain    = (Label)myItem.FindControl("UserMain");
        Label        userOther   = (Label)myItem.FindControl("UserOther");
        Label        swapWith    = (Label)myItem.FindControl("SwappingWith");
        Label        swapVe      = (Label)myItem.FindControl("SwapVe");
        Label        vMain       = (Label)myItem.FindControl("VMain");
        Label        vOther      = (Label)myItem.FindControl("VOther");
        Label        swapFrom    = (Label)myItem.FindControl("SwapFromDate");
        Label        swapTo      = (Label)myItem.FindControl("SwapToDate");
        Label        phone       = (Label)myItem.FindControl("Phone");
        Label        swapId      = (Label)myItem.FindControl("ScheduleId");
        Image        swapImg     = (Image)myItem.FindControl("SchedSwapVeImage");
        Image        persSwapImg = (Image)myItem.FindControl("SchedSwapPersImg");
        HyperLink    rateLink    = (HyperLink)myItem.FindControl("RateSwapLink");
        HyperLink    msgLink     = (HyperLink)myItem.FindControl("SendMsgLink");
        Guid         veMainGuid  = Guid.Parse(vMain.Text);
        Guid         veOtherGuid = Guid.Parse(vOther.Text);

        if (userMain.Text == Profile.UserName)
        {
            UserClass uc = new UserClass(userOther.Text);
            CarClass  cc = new CarClass(userOther.Text);
            swapWith.Text = uc.PublicFirstName;
            UserVehicle userVe = cc.GetVehicleInfo(veOtherGuid);
            swapImg.ImageUrl     = uc.PublicImgMainUrl(veOtherGuid);
            persSwapImg.ImageUrl = uc.PublicPersonalImage;
            swapVe.Text          = userVe.VehicleYear + " " + userVe.VehicleMake + " " + userVe.VehicleModel;
            rateLink.NavigateUrl = rateLink.NavigateUrl + "?Id=" + swapId.Text + "&User="******"&FirstName=" + uc.PublicFirstName + "&DateFrom=" + swapFrom.Text +
                                   "&DateTo=" + swapTo.Text;
            phone.Text          = uc.PublicFormattedPhone;
            msgLink.NavigateUrl = msgLink.NavigateUrl + "?from=" + uc.PublicUserName;
        }
        else
        {
            UserClass uc = new UserClass(userMain.Text);
            CarClass  cc = new CarClass(userMain.Text);
            swapWith.Text = uc.PublicFirstName;
            UserVehicle userVe = cc.GetVehicleInfo(veMainGuid);
            swapImg.ImageUrl     = uc.PublicImgMainUrl(veMainGuid);
            persSwapImg.ImageUrl = uc.PublicPersonalImage;
            swapVe.Text          = userVe.VehicleYear + " " + userVe.VehicleMake + " " + userVe.VehicleModel;
            rateLink.NavigateUrl = rateLink.NavigateUrl + "?Id=" + swapId.Text + "&User="******"&FirstName=" + uc.PublicFirstName + "&DateFrom=" + swapFrom.Text +
                                   "&DateTo=" + swapTo.Text;
            phone.Text          = uc.PublicFormattedPhone;
            msgLink.NavigateUrl = msgLink.NavigateUrl + "?from=" + uc.PublicUserName;
        }
    }
Exemplo n.º 9
0
        public void CarRepository_UpdatingCarInList()
        {
            //--Arrange
            CarClass newCar = new CarClass(carType.Hybrid, "Porsche", "918 Spyder", "2013", 89, 1);

            carRepo.AddCarToList(newCar);
            carRepo.updateCar(carType.Gas, "Porsche", "918 Spyder", "2013", 89, 1);

            //--Act
            int actual   = carRepo.GetList().Count;
            int expected = 4;

            //--Assert
            Assert.AreEqual(expected, actual);
        }
Exemplo n.º 10
0
        public void DeleteItem(object sender, System.EventArgs e)
        {
            String CarID = ((HtmlAnchor)sender).HRef.ToString();
            int    i     = CarClass.Delete(CarID, Convert.ToInt32(lblPersonID.Text));

            if (i == 0)
            {
                ScriptManager.RegisterClientScriptBlock(Page, Page.GetType(), Guid.NewGuid().ToString(), "alert('خطا در حذف');", true);
            }
            else
            {
                BindGrid();
            }
            LightBox.Value = "0";
        }
Exemplo n.º 11
0
    public void ghostCarSpawning()
    {
        float timeIncrement = 0;

        ghostCar = new CarClass(platform, this, allStops[0], allStops[1]);

        for (int i = 0; i < allCars.Length; i++)
        {
            //If timeGap passes a spawn, it will increment with nextStop(), need parameters if it surpases more than one stop in an increment
            allCars[i] = new CarClass(platform, this, ghostCar.platform.transform, ghostCar.destination);
            allCars[i].currentStopNumber = ghostCar.currentStopNumber;
            timeIncrement += timeSpawnGap;
            ghostCar.canIMove(timeIncrement);
        }
        ghostCar.platform.gameObject.SetActive(false);
    }
Exemplo n.º 12
0
        public void BindGrid()
        {
            ClCar cl = new ClCar();

            cl.PersonID = PersonID;
            DataSet  ds = CarClass.GetList(cl);
            DataView dv = new DataView(ds.Tables[0]);

            if (ViewState["CarID"] == null)
            {
                ViewState["CarID"] = "CarID Desc";
            }
            dv.Sort = Securenamespace.SecureData.CheckSecurity(ViewState["CarID"].ToString()).ToString();
            GridView1.DataSource = dv;
            GridView1.DataBind();
        }
Exemplo n.º 13
0
        public static CarClass getCarClassForRaceRoomId(int carClassId)
        {
            if (carClassId != -1)
            {
                foreach (CarClass carClass in carClasses)
                {
                    if (carClass.raceroomClassIds.Contains(carClassId))
                    {
                        return(carClass);
                    }
                }
            }
            CarClass defaultClass = getDefaultCarClass();

            return(defaultClass);
        }
Exemplo n.º 14
0
        // returns default car class with rFactor vehicle class name
        public static CarClass getCarClassForRF1ClassName(String rF1ClassName)
        {
            foreach (CarClass carClass in carClasses)
            {
                if (carClass.rF1ClassName == rF1ClassName)
                {
                    return(carClass);
                }
            }
            // create one if it doesn't exist
            CarClass rFactorClass = new CarClass(CarClassEnum.UNKNOWN_RACE, new String[] { "" }, new int[] { -1 }, BrakeType.Iron_Race, TyreType.Unknown_Race, maxRaceSafeWaterTemp, maxRaceSafeOilTemp);

            rFactorClass.rF1ClassName = rF1ClassName;
            carClasses.Add(rFactorClass);
            return(rFactorClass);
        }
Exemplo n.º 15
0
        private int ChekPelak(string Pelak)
        {
            ClCar cl = new ClCar();

            cl.Pelak = Pelak;
            DataSet ds = CarClass.GetList(cl);

            if ((ds.Tables[0].Rows.Count) > 0)
            {
                return(Convert.ToInt32(ds.Tables[0].Rows[0]["CarID"].ToString()));
            }
            else
            {
                return(0);
            }
        }
Exemplo n.º 16
0
        //public int Disscount
        //{
        //    get {
        //        if (rbWhithDiscount.Checked)
        //            return 1009;
        //        else
        //            return 0;
        //    }


        //}
        public bool checkAjance()
        {
            ClCar cl = new ClCar();

            cl.Pelak = CtlPelak.Text;
            DataSet ds = CarClass.GetList(cl);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 17
0
        private static void RentCar(ClientClass client)
        {
            Console.Clear();
            //AutoParkService.PrintAvailableCars();
            CarClass chosenCar = AutoParkService.ChooseCar();

            Console.Clear();
            if (chosenCar != null)
            {
                RentService.AddNewRent(new RentClass(client, chosenCar));
                Console.WriteLine("Car with id '{0}' was successfully rented.", chosenCar.CarId);
            }
            else
            {
                Console.WriteLine("Id not found!");
            }
        }
Exemplo n.º 18
0
        public void CarRepository_AddingCarToList()
        {
            //--Arrange
            CarClass        newCar  = new CarClass(carType.Hybrid, "Porsche", "918 Spyder", "2013", 89, 1);
            List <CarClass> newList = new List <CarClass>();

            newList.Add(newCar);
            carRepo.AddCarToList(newList);
            List <CarClass> carList = carRepo.GetList();

            //--Act
            int actual   = carList.Count;
            int expected = 4;

            //--Assert
            Assert.AreEqual(expected, actual);
        }
Exemplo n.º 19
0
        public void UpdateCar(Guid Id, CarClass value)
        {
            var car = _carList.Where(c => c._Id == Id).Single();

            if (value._maker != null)
            {
                car._maker = value._maker;
            }
            if (value._model != null)
            {
                car._model = value._model;
            }
            if (value._Year != null)
            {
                car._Year = value._Year;
            }
        }
Exemplo n.º 20
0
        static void Main(string[] args)
        {
            CarClass car = new CarClass(2018, "Honda");

            Console.WriteLine(car.Speed);

            for (int i = 0; i < 5; i++)
            {
                car.Accelerate();
                Console.WriteLine(car.Speed);
            }
            for (int i = 0; i < 5; i++)
            {
                car.Brake();
                Console.WriteLine(car.Speed);
            }
            Console.ReadLine();
        }
        public async Task <IActionResult> CreateClass([FromBody] CarClass carClass)
        {
            if (carClass == null)
            {
                return(BadRequest($"{nameof(carClass)} must not be null!"));
            }

            try
            {
                var obj = await _classRepository.AddAsync(carClass);

                return(CreatedAtRoute("GetCarClass", new { id = obj.Id }, obj));
            }
            catch (Exception e)
            {
                return(StatusCode((int)HttpStatusCode.InternalServerError, e));
            }
        }
Exemplo n.º 22
0
        private async Task <CarClass> CreateCarClass(string vehicleClass)
        {
            if (!string.IsNullOrEmpty(vehicleClass))
            {
                CarClass carClass = new CarClass()
                {
                    VehicleClass = vehicleClass
                };
                _context.CarClasses.Add(carClass);
                await _context.SaveChangesAsync();

                return(carClass);
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 23
0
        private async Task <Car> CreateCar(string vehicleName, CarClass vehicleClass)
        {
            if (!string.IsNullOrEmpty(vehicleName) && vehicleClass != null)
            {
                Car car = new Car()
                {
                    VehicleName = vehicleName, VehicleClass = vehicleClass
                };
                _context.Cars.Add(car);
                await _context.SaveChangesAsync();

                return(car);
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 24
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string getMyVeId    = Request.QueryString.Get("toVeId");
        string getOtherVeId = Request.QueryString.Get("fromVeId");
        string requestFrom  = Request.QueryString.Get("requestfrom");
        string requestId    = Request.QueryString.Get("id");

        Guid myVeGuid    = Guid.Parse(getMyVeId);
        Guid otherVeGuid = Guid.Parse(getOtherVeId);
        Guid requestGuid = Guid.Parse(requestId);

        UserClass uc  = new UserClass(Profile.UserName);
        UserClass ouc = new UserClass(requestFrom);

        RequestGuidLabel.Text = requestId;
        string imgUrl = uc.PublicImgMainUrl(myVeGuid);

        using (SwapEntities ent = new SwapEntities())
        {
            CarClass cc = new CarClass(Profile.UserName);

            var fromVe = (from tbl in ent.VeImages orderby tbl.IsMain descending
                          where tbl.VehicleId == otherVeGuid
                          select tbl);

            Repeater.DataSource = fromVe;
            Repeater.DataBind();

            UserVehicle  myVe        = cc.GetVehicleInfo(myVeGuid);
            UserVehicle  otherVe     = cc.GetVehicleInfo(otherVeGuid);
            RequestEvent thisRequest = cc.GetSwapRequestInfo(requestGuid);

            OtherUser.Text    = ouc.PublicFirstName;
            OtherUser2.Text   = ouc.PublicFirstName;
            SwapFromDate.Text = thisRequest.DateFrom.ToShortDateString();
            SwapToDate.Text   = thisRequest.DateTo.ToShortDateString();
            MyVeLabel.Text    = myVe.VehicleYear + " " + myVe.VehicleMake + " " + myVe.VehicleModel;
            OtherVeLabel.Text = otherVe.VehicleYear + " " + otherVe.VehicleMake + " " + otherVe.VehicleModel;
            VeMiles.Text      = otherVe.VehicleMiles.ToString();
            CityState.Text    = ouc.PublicCity + ", " + ouc.PublicState;
            Distance.Text     = cc.GetDistance(uc.PublicZip, ouc.PublicZip).ToString();
        }
        MyImg.ImageUrl = imgUrl;
    }
        public async Task <IActionResult> UpdateClass([FromBody] CarClass carClass)
        {
            try
            {
                var exists = await _classRepository.GetAsync(carClass.Id) != null;

                if (!exists)
                {
                    return(NotFound($"No Object found with ID {carClass.Id}"));
                }

                await _classRepository.UpdateAsync(carClass);

                return(Ok());
            }
            catch (Exception e)
            {
                return(StatusCode((int)HttpStatusCode.InternalServerError, e));
            }
        }
Exemplo n.º 26
0
        public void UpdateCar(Guid Id, CarClass value)
        {
            _data.UpdateCar(Id, value);
            //var car = _carList.Where(c => c._Id == Id).Single();

            //if (updateMaker != null)
            //{
            //    car._maker = updateMaker;
            //}

            //if (updateModel != null)
            //{
            //    car._model = updateModel;
            //}

            //if (updateYear != null)
            //{
            //    car._Year = updateYear;
            //}
        }
Exemplo n.º 27
0
        public async Task <ActionResult <Reservation> > PostReservation(Reservation reservation)
        {
            if (!ReservationExists(reservation))
            {
                List <Reservation> reslist = _context.Reservations.ToList();
                bool carreserved           = false;
                foreach (var res in reslist)
                {
                    if (reservation.CarId == res.CarId)
                    {
                        DateTime resend = res.RentalDate;
                        resend = resend.AddDays(res.RentalDays);
                        DateTime reservationEnd = reservation.RentalDate;
                        reservationEnd = reservationEnd.AddDays(reservation.RentalDays);
                        if (reservation.RentalDate.Date >= res.RentalDate.Date && reservation.RentalDate <= resend || reservationEnd.Date >= res.RentalDate.Date && reservationEnd <= resend)
                        {
                            carreserved = true;
                            break;
                        }
                    }
                }
                if (!carreserved)
                {
                    CarClass carclass = new CarClass();
                    Car      car      = _context.Cars.Find(reservation.CarId);
                    carclass          = _context.CarClasses.Find(car.ClassId);
                    reservation.Costs = reservation.RentalDays * carclass.CostsPerDay;
                    if (reservation.State != ReservationState.pending)
                    {
                        reservation.State = ReservationState.pending;
                    }
                    _context.Reservations.Add(reservation);
                    await _context.SaveChangesAsync();

                    return(CreatedAtAction("GetReservation", new { id = reservation.Id }, reservation));
                }
            }

            return(NoContent());
        }
Exemplo n.º 28
0
        public static CarClass getCarClassForRaceRoomId(int carClassId)
        {
            // first check if it's in the cache
            if (intToCarClass.ContainsKey(carClassId))
            {
                return intToCarClass[carClassId];
            }
            foreach (CarClass carClass in CAR_CLASSES.carClasses)
            {
                if (carClass.raceroomClassIds.Contains(carClassId))
                {
                    intToCarClass.Add(carClassId, carClass);
                    return carClass;
                }
            }

            // create one if it doesn't exist
            CarClass newCarClass = new CarClass();
            intToCarClass.Add(carClassId, newCarClass);
            newCarClass.placeholderClassId = carClassId.ToString();
            return newCarClass;
        }
Exemplo n.º 29
0
        protected void grdPosts_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            //store Theme row that was click
            Int32 selectedRow = e.RowIndex;

            //get the selected StudetnID using the grid's data key collection
            Int32 carID = Convert.ToInt32(grdPosts.DataKeys[selectedRow].Values["carID"]);

            //use EF to remove the seleted student
            using (COMP2007Entities db = new COMP2007Entities())
            {
                Car cars = (from objs in db.Cars where objs.carID == carID select objs).FirstOrDefault();
                CarClass carClass = (from objs in db.CarClasses where objs.carID == carID select objs).FirstOrDefault();

                db.Cars.Remove(cars);
                db.CarClasses.Remove(carClass);
                db.SaveChanges();
            }

            //refresh the grid
            getAccount();
            getPosts();
        }
Exemplo n.º 30
0
 public static List<CornerData.EnumWithThresholds> getTyreTempThresholds(CarClass carClass)
 {
     var predefinedTyreThresholds = tyreTempThresholds[carClass.defaultTyreType];
     // Copy predefined thresholds to avoid overriding defaults.
     var ttt = new List<CornerData.EnumWithThresholds>();
     foreach (var threshold in predefinedTyreThresholds)
     {
         ttt.Add(new CornerData.EnumWithThresholds(threshold.e, threshold.lowerThreshold, threshold.upperThreshold));
     }
     // Apply overrides from .json, if user provided them.
     if (ttt.Count == 4) // COLD, WARM, HOT, COOKING thresholds
     {
         // Should we validate thresholds to see if they make any sense?
         if (carClass.maxColdTyreTemp > 0)
         {
             Debug.Assert((TyreTemp)ttt[0].e == TyreTemp.COLD);
             ttt[0].upperThreshold = carClass.maxColdTyreTemp;
             Debug.Assert((TyreTemp)ttt[1].e == TyreTemp.WARM);
             ttt[1].lowerThreshold = carClass.maxColdTyreTemp;
         }
         if (carClass.maxWarmTyreTemp > 0)
         {
             Debug.Assert((TyreTemp)ttt[1].e == TyreTemp.WARM);
             ttt[1].upperThreshold = carClass.maxWarmTyreTemp;
             Debug.Assert((TyreTemp)ttt[2].e == TyreTemp.HOT);
             ttt[2].lowerThreshold = carClass.maxWarmTyreTemp;
         }
         if (carClass.maxHotTyreTemp > 0)
         {
             Debug.Assert((TyreTemp)ttt[2].e == TyreTemp.HOT);
             ttt[2].upperThreshold = carClass.maxHotTyreTemp;
             Debug.Assert((TyreTemp)ttt[3].e == TyreTemp.COOKING);
             ttt[3].lowerThreshold = carClass.maxHotTyreTemp;
         }
     }
     return ttt;
 }
Exemplo n.º 31
0
 public static TyreType getDefaultTyreType(CarClass carClass, String carName)
 {
     if (carName != null && defaultTyreTypesPerCarName.ContainsKey(carName))
     {
         return defaultTyreTypesPerCarName[carName];
     }
     return carClass.defaultTyreType;
 }
Exemplo n.º 32
0
 public static List<CornerData.EnumWithThresholds> getBrakeTempThresholds(CarClass carClass, String carName)
 {
     if (carName!= null && brakeTypesPerCarName.ContainsKey(carName))
     {
         return brakeTempThresholds[brakeTypesPerCarName[carName]];
     }
     return brakeTempThresholds[carClass.brakeType];
 }
Exemplo n.º 33
0
 public Car(Int64 baseCarId, CarClass raceClass, Int64 apId, XElement paints, XElement performanceParts, Int64 physicsProfileHash, Int32 rating, Int32 resalePrice, XElement skillModParts, XElement vinyls, XElement visualParts, Int16 durability, DateTime expirationDate, Int16 heatLevel, Int32 id)
 {
     BaseCarId = baseCarId;
     RaceClass = raceClass;
     ApId = apId;
     Paints = paints;
     PerformanceParts = performanceParts;
     PhysicsProfileHash = physicsProfileHash;
     Rating = rating;
     ResalePrice = resalePrice;
     SkillModParts = skillModParts;
     Vinyls = vinyls;
     VisualParts = visualParts;
     Durability = durability;
     ExpirationDate = expirationDate;
     HeatLevel = heatLevel;
     Id = id;
 }