private void StartBlinking(WagonType type) { image.enabled = true; image.sprite = sprites[(int)type]; animator.SetBool("IsBlinking", true); }
public static string Get(WagonType wagonType) { MemberInfo[] memberInfos = typeof(WagonType).GetMember(wagonType.ToString()); object[] attributes = memberInfos[0].GetCustomAttributes(typeof(UzWagonTypeAttribute), false); string typeCode = ((UzWagonTypeAttribute)attributes[0]).TypeCode; return(typeCode); }
public Wagon(string name, int serialNumber, WagonType wagonType, int seats, int liftingCapacity) { Name = name; SerialNumber = serialNumber; WagonType = wagonType; Seats = seats; LiftingCapacity = liftingCapacity; }
public Wagon(string name, string serialNumber, WagonType type, int seats, int loadCapacity) { Name = name; SerialNumber = serialNumber; Type = type; Seats = seats; LoadCapacity = loadCapacity; }
public void BuildWagon(TrainManager trainManager, WagonType type) { GameObject wagonToCreate = GetWagonOfType(type); if (wagonToCreate) { trainManager.CreateWagon(wagonToCreate); } }
private void Start() { do { var typesCount = System.Enum.GetNames(typeof(WagonType)).Length; WType = (WagonType)Random.Range(0, typesCount); }while (checkpointsManager.UsedWagonTypes.Contains(WType)); checkpointsManager.UsedWagonTypes.Add(WType); sr.sprite = sprites[(int)WType]; }
private GameObject GetWagonOfType(WagonType type) { foreach (GameObject wagon in availableWagons) { if (wagon.GetComponent <Wagon>().WagonType == type) { return(wagon); } } return(null); }
/// <summary> /// Добавление вагона к поезду /// </summary> /// <param name="trainId"></param> /// <param name="wagonType"></param> public static async Task AddWagonToTrain(int trainId, WagonType wagonType) { var wagon = new Wagon(); wagon.WagonType = (byte)wagonType; wagon.WagonNum = GetWagonNumber(trainId); ContextKeeper.Wagons.Add(wagon); var trainWagon = new TrainWagon(); trainWagon.WagonId = wagon.Id; trainWagon.TrainId = trainId; ContextKeeper.TrainWagons.Add(trainWagon); await Task.Run(() => AddSeatsToWagonAsync(wagon.Id, wagonType)); }
public async Task <ActionResult> Edit(WagonType wagonType) { try { if (ModelState.IsValid) { dbContext.Entry(wagonType).State = EntityState.Modified; await dbContext.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View()); } catch { return(NotFound()); } }
public async Task <ActionResult> Create(WagonType wagonType) { try { if (ModelState.IsValid) { await dbContext.AddAsync(wagonType); await dbContext.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View()); } catch { return(NotFound()); } }
/// <summary> /// Подсчет цены места заданного типа для конкретного маршрута /// </summary> /// <param name="trainId"></param> /// <param name="seatType"></param> /// <returns></returns> public static double CalculatePrice(double voyageDistance, WagonType seatType) { double basePrice = _kilometerPrice * voyageDistance * priceCoefficient; switch (seatType) { case WagonType.BERTH: { return Math.Round(basePrice * (double)PriceMultiplyers.BERTH); } case WagonType.COUPE: { return Math.Round(basePrice * (double)PriceMultiplyers.COUPE); } case WagonType.LUX: { return Math.Round(basePrice * (double)PriceMultiplyers.LUX); } default: { return basePrice; } } }
/// <summary> /// Получение количества мест в вагоне по типу вагона /// </summary> /// <param name="wagonType"></param> /// <returns></returns> private static int GetSeatsAmount(WagonType wagonType) { switch (wagonType) { case WagonType.BERTH: { return (int)WagonSeatsAmount.BERTH; } case WagonType.COUPE: { return (int)WagonSeatsAmount.COUPE; } case WagonType.LUX: { return (int)WagonSeatsAmount.LUX; } } return (int)WagonSeatsAmount.BERTH; }
public void AddWagon(WagonType type) { wagonsInTrain.Add(type); }
/// <summary> /// Generate Sample Authoritative Instruction Create Message /// </summary> /// <param name="filename"></param> private void GenerateCreateMessage(string filename) { var ns = new XmlSerializerNamespaces(); ns.Add("ns", "http://gpcopsschema.azurewebsites.net/schema/2015/1.0/ConsignmentService"); // Creates an instance of the XmlSerializer class; // specifies the type of object to serialize. var serializer = new XmlSerializer(typeof(AuthoritativeInstruction)); TextWriter writer = new StreamWriter(filename); //Customer Authority Type var ca = new CustomerAuthorityType { DispatchingMine = "Curragh", DispatchingCustomer = "Curragh", UnloadLocation = "GLD" }; var aid = new AuthorisationIdType { Consignment = "AA24288", RailServiceID = "B53M" }; var dt = new DateTime(2015, 05, 16); aid.RailServiceDateTime = dt; //DateTime.ParseExact(dt.ToString("yyyy-MM-dd"),"yyyy-MM-dd",null); var aih = new AuthoritativeInstructionHeader { CustomerAuthority = ca, Identifier = aid }; var msgDt = DateTime.Now; aih.MessageTimeStamp = msgDt; var firstwagon = new WagonType { Sequence = 2, Number = 56012, Type = WagonTypeType.Wagon, Class = "VCBS" }; var lastwagon = new WagonType { Sequence = 104, Number = 49717, Type = WagonTypeType.Wagon, Class = "VSAL" }; var ct = new CreateType { Count = 102, Stockpile = 661, FirstWagon = firstwagon, LastWagon = lastwagon }; var cm = new CoalMetadataType { CoalType = "Curragh Mid Ash", CoalProperty = CoalMetadataTypeCoalProperty.Normal, Ash = 0.25f, AshSpecified = true, Moisture = 0.25f, MoistureSpecified = true }; var dtNow = DateTime.Now; var ld = new LoadOutDetailsType { LoadLocation = "ALocation", LoadOutOperator = "CurraghUser", TonnesLoaded = 8328, UnloadInstruction = "A Sample Instruction", LoadCompleteDateTime = dtNow.AddHours(-1) }; var cc = new CommentType { ConsignmentComment = "Optional Create Comment" }; var aiCreate = new AuthoritativeInstructionActionCreate { Instruction = ct, CoalMetadata = cm, LoadOutDetails = ld, CreateComment = cc }; var aiAction = new AuthoritativeInstructionAction { Item = aiCreate }; var ai = new AuthoritativeInstruction { Action = aiAction, Header = aih }; /***** To see generated XML Uncomment the code below: ******/ var sw = new StringWriter(); var xmlWriter = XmlWriter.Create(sw, new XmlWriterSettings() { OmitXmlDeclaration = true, Indent = true }); serializer.Serialize(xmlWriter, ai, ns); string xmlString = sw.ToString(); Console.WriteLine("Create Authoritative Instruction XML For Create Message : " + xmlString + " \n\n\n"); }
/// <summary> /// Generate Sample Authoritative Instruction Cancellation Message /// </summary> /// <param name="filename"></param> private void GenerateCancelMessage(string filename) { var ns = new XmlSerializerNamespaces(); ns.Add("ns", "http://gpcopsschema.azurewebsites.net/schema/2015/1.0/ConsignmentService"); // Creates an instance of the XmlSerializer class; // specifies the type of object to serialize. var serializer = new XmlSerializer(typeof(AuthoritativeInstruction)); TextWriter writer = new StreamWriter(filename); //Customer Authority Type var ca = new CustomerAuthorityType { DispatchingMine = "Curragh", DispatchingCustomer = "Curragh", UnloadLocation = "GLD" }; var aid = new AuthorisationIdType { Consignment = "AA24288", RailServiceID = "B53M" }; var dt = new DateTime(2015, 05, 16); aid.RailServiceDateTime = dt; var aih = new AuthoritativeInstructionHeader { CustomerAuthority = ca, Identifier = aid }; var msgDt = DateTime.Now; aih.MessageTimeStamp = msgDt; var firstwagon = new WagonType { Sequence = 2, Number = 56012, Type = WagonTypeType.Wagon, Class = "VCBS" }; var lastwagon = new WagonType { Sequence = 104, Number = 49717, Type = WagonTypeType.Wagon, Class = "VSAL" }; var ct = new CancelType { Count = 102, Stockpile = 661, FirstWagon = firstwagon, LastWagon = lastwagon }; var cc = new CommentType { ConsignmentComment = "Mendatory Cancellation Comment..." }; var aiCancel = new AuthoritativeInstructionActionCancel() { Instruction = ct, CancellationComment = cc }; var aiAction = new AuthoritativeInstructionAction { Item = aiCancel }; var ai = new AuthoritativeInstruction { Action = aiAction, Header = aih }; /***** To see generated XML Uncomment the code below: ******/ var sw = new StringWriter(); var xmlWriter = XmlWriter.Create(sw, new XmlWriterSettings() { OmitXmlDeclaration = true, Indent = true }); serializer.Serialize(xmlWriter, ai, ns); string xmlString = sw.ToString(); Console.WriteLine("Authoritative Instruction XML For Cancellation Message : " + xmlString + " \n\n\n"); }
/// <summary> /// Generate Sample Authoritative Instruction Update Message /// </summary> /// <param name="filename"></param> private void GenerateUpdateMessage(string filename) { var ns = new XmlSerializerNamespaces(); ns.Add("ns", "http://gpcopsschema.azurewebsites.net/schema/2015/1.0/ConsignmentService"); // Creates an instance of the XmlSerializer class; // specifies the type of object to serialize. var serializer = new XmlSerializer(typeof(AuthoritativeInstruction)); TextWriter writer = new StreamWriter(filename); //Customer Authority Type var ca = new CustomerAuthorityType { DispatchingMine = "Curragh", DispatchingCustomer = "Curragh", UnloadLocation = "GLD" }; var aid = new AuthorisationIdType { Consignment = "AA24288", RailServiceID = "B53M" }; var dt = new DateTime(2015, 05, 16); aid.RailServiceDateTime = dt; var aih = new AuthoritativeInstructionHeader { CustomerAuthority = ca, Identifier = aid }; var msgDt = DateTime.Now; aih.MessageTimeStamp = msgDt; var newfirstwagon = new WagonType { Sequence = 2, Number = 56012, Type = WagonTypeType.Wagon, Class = "VCBS" }; var newlastwagon = new WagonType { Sequence = 104, Number = 49717, Type = WagonTypeType.Wagon, Class = "VSAL" }; var ut = new UpdateType { NewCount = 102, NewStockpile = 661, NewFirstWagon = newfirstwagon, NewLastWagon = newlastwagon }; var cm = new CoalMetadataType { CoalType = "Curragh PCI Coal", CoalProperty = CoalMetadataTypeCoalProperty.Normal, Ash = 0.05f, Moisture = 0.05f }; var uc = new CommentType { ConsignmentComment = "Mendatory Update Comment..." }; var aiUpdate = new AuthoritativeInstructionActionUpdate() { Instruction = ut, CoalMetadata = cm, UpdateComment = uc }; var aiAction = new AuthoritativeInstructionAction { Item = aiUpdate }; var ai = new AuthoritativeInstruction { Action = aiAction, Header = aih }; var sw = new StringWriter(); var xmlWriter = XmlWriter.Create(sw, new XmlWriterSettings() { OmitXmlDeclaration = true, Indent = true }); serializer.Serialize(xmlWriter, ai, ns); string xmlString = sw.ToString(); Console.WriteLine("Authoritative Instruction XML For Update Message : " + xmlString + " \n\n\n"); }
public void SetType(WagonType type, Sprite sprite) { wagonType = type; sr.sprite = sprite; }
/// <summary> /// Установка текущего типа вагонов поезда в зависимости от выбранной вкладки /// </summary> private void SetCurrentWagonType() { switch (CurrentTabIndex) { case 0: { _currentWagonType = WagonType.BERTH; if (Berth.Count != 0) { CurrentBerth = Berth[0]; SetStartNextPrevButtons(Berth.Count); SetWagonSeatsButtonsVisibility(CurrentBerth, _berthSeatsVisibility); BerthSeatsVisibility.Add(null); } break; } case 1: { _currentWagonType = WagonType.COUPE; if (Coupe.Count != 0) { CurrentCoupe = Coupe[0]; SetStartNextPrevButtons(Coupe.Count); SetWagonSeatsButtonsVisibility(CurrentCoupe, _coupeSeatsVisibility); CoupeSeatsVisibility.Add(null); } break; } case 2: { if (Lux.Count != 0) { CurrentLux = Lux[0]; SetStartNextPrevButtons(Lux.Count); SetWagonSeatsButtonsVisibility(CurrentLux, _luxSeatsVisibility); LuxSeatsVisibility.Add(null); } _currentWagonType = WagonType.LUX; break; } } }
/// <summary> /// Добавление мест определённого типа к заданному вагона /// </summary> /// <param name="wagonId"></param> /// <param name="wagonType"></param> private static Task AddSeatsToWagonAsync(int wagonId, WagonType wagonType) { return Task.Run(() => { for (int i = 0; i < GetSeatsAmount(wagonType); i++) { var seat = new Seat(); seat.SeatNum = i + 1; ContextKeeper.Seats.Add(seat); var wagonSeat = new WagonSeat(); wagonSeat.WagonId = wagonId; wagonSeat.SeatId = seat.Id; ContextKeeper.WagonSeats.Add(wagonSeat); } }); }