Esempio n. 1
0
        /// <summary>
        /// Creates the car.
        /// </summary>
        /// <param name="position">The position.</param>
        /// <param name="id">The identifier.</param>
        /// <param name="type">The type.</param>
        /// <returns>
        /// The created ViewModel
        /// </returns>
        public AbstractCarViewModel CreateNewObject(VRPosition position, int id, int type)
        {
            AbstractCarViewModel car = null;
            switch (type)
            {
                case (int)CarEnum.Normal:
                    car = new NormalCarViewModel(position, id);
                    break;

                case (int)CarEnum.Police:
                    car = new PoliceCarViewModel(position, id);
                    break;

                case (int)CarEnum.Ambulance:
                    car = new AmbulanceCarViewModel(position, id);
                    break;

                case (int)CarEnum.Firetruck:
                    car = new FiretruckCarViewModel(position, id);
                    break;

                default:
                    break;
            }

            CarView view = new CarView(car);
            this.LinkMVVM(view, car);
            return car;
        }
Esempio n. 2
0
        public void CarTest()
        {
            JObject car = new JObject();
            car.Add("Id", 1);
            car.Add("SirenActive", false);
            car.Add("x", 200);
            car.Add("y", 300);
            car.Add("r", 500);
            car.Add("type", 1);

            AbstractCarViewModel c1 = new NormalCarViewModel(new VRPosition(100, 200, 300), 1);
            Dictionary<int, AbstractCarViewModel> cars = handler.Cars;
            cars.Add(c1.Id, c1);
            handler.Cars = cars;
            handler.Handle(car);
            AbstractCarViewModel c2 = new NormalCarViewModel(new VRPosition(200, 300, 500), 1);

            Assert.AreEqual(c1.ToString(), c2.ToString());
        }