Esempio n. 1
0
    private void StartBlinking(WagonType type)
    {
        image.enabled = true;
        image.sprite  = sprites[(int)type];

        animator.SetBool("IsBlinking", true);
    }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
 public Wagon(string name, int serialNumber, WagonType wagonType, int seats, int liftingCapacity)
 {
     Name = name;
     SerialNumber = serialNumber;
     WagonType = wagonType;
     Seats = seats;
     LiftingCapacity = liftingCapacity;
 }
Esempio n. 4
0
 public Wagon(string name, string serialNumber, WagonType type, int seats, int loadCapacity)
 {
     Name         = name;
     SerialNumber = serialNumber;
     Type         = type;
     Seats        = seats;
     LoadCapacity = loadCapacity;
 }
Esempio n. 5
0
    public void BuildWagon(TrainManager trainManager, WagonType type)
    {
        GameObject wagonToCreate = GetWagonOfType(type);

        if (wagonToCreate)
        {
            trainManager.CreateWagon(wagonToCreate);
        }
    }
Esempio n. 6
0
    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];
    }
Esempio n. 7
0
    private GameObject GetWagonOfType(WagonType type)
    {
        foreach (GameObject wagon in availableWagons)
        {
            if (wagon.GetComponent <Wagon>().WagonType == type)
            {
                return(wagon);
            }
        }

        return(null);
    }
Esempio n. 8
0
        /// <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());
            }
        }
Esempio n. 11
0
        /// <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;
                    }
            }
        }
Esempio n. 12
0
 /// <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;
 }
Esempio n. 13
0
 public void AddWagon(WagonType type)
 {
     wagonsInTrain.Add(type);
 }
Esempio n. 14
0
        /// <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");
        }
Esempio n. 15
0
        /// <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");
        }
Esempio n. 16
0
        /// <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");
        }
Esempio n. 17
0
 public void SetType(WagonType type, Sprite sprite)
 {
     wagonType = type;
     sr.sprite = sprite;
 }
Esempio n. 18
0
        /// <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;
                    }
            }

        }
Esempio n. 19
0
        /// <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);
                }
            });            
        }