예제 #1
0
파일: Car.cs 프로젝트: Mellowz/nfsw-server
 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;
 }
예제 #2
0
 public Car(CarEntity car)
 {
     id                 = car.id;
     baseCarId          = car.baseCarId;
     raceClass          = car.raceClass;
     paints             = XElement.Parse(car.paints);
     performanceParts   = XElement.Parse(car.performanceParts);
     physicsProfileHash = car.physicsProfileHash;
     rating             = car.rating;
     resalePrice        = car.resalePrice;
     skillModParts      = XElement.Parse(car.skillModParts);
     vinyls             = XElement.Parse(car.vinyls);
     visualParts        = XElement.Parse(car.visualParts);
     durability         = car.durability;
     expirationDate     = car.expirationDate;
     heatLevel          = car.heatLevel;
     carId              = car.carId;
     personaId          = car.ownerPersona.id;
 }
        private void SetupComponents()
        {
            #region FlipViewPersona
            Image[] aFlipViewAvatarArray = new Image[28];
            for (int i = 0; i < 28; i++)
            {
                ImageSource source = BitmapFrame.Create(
                    new Uri("pack://application:,,,/OfflineServer;component/images/NFSW_Avatars/Avatar_" + i.ToString() + ".png", UriKind.Absolute),
                    BitmapCreateOptions.DelayCreation, BitmapCacheOption.OnDemand);
                source.Freeze();

                Image avatarImage = new Image()
                {
                    HorizontalAlignment = HorizontalAlignment.Center,
                    VerticalAlignment   = VerticalAlignment.Center,
                    Source = source
                };

                aFlipViewAvatarArray[i] = avatarImage;
            }
            FlipViewPersonaImage.ItemsSource = aFlipViewAvatarArray;

            Binding indexBind = new Binding()
            {
                Path = new PropertyPath("ActivePersona.IconIndex"),
                UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged,
                Mode   = BindingMode.TwoWay,
                Delay  = 1000,
                Source = Access.CurrentSession
            };
            BindingOperations.SetBinding(FlipViewPersonaImage, FlipView.SelectedIndexProperty, indexBind);
            #endregion

            #region MetroTile -> Random Persona Info
            tRandomPersonaInfo_Tick(null, null);
            RandomPersonaInfo.Tick    += new EventHandler(tRandomPersonaInfo_Tick);
            RandomPersonaInfo.Interval = new TimeSpan(0, 0, 10);
            RandomPersonaInfo.Start();
            #endregion

            #region carDialog
            Binding lBindSelect = new Binding()
            {
                Path   = new PropertyPath("language.Select"),
                Mode   = BindingMode.OneWay,
                Source = Access.dataAccess.appSettings.uiSettings
            };
            Binding lBindCancel = new Binding()
            {
                Path   = new PropertyPath("language.Cancel"),
                Mode   = BindingMode.OneWay,
                Source = Access.dataAccess.appSettings.uiSettings
            };
            Binding lBindSelectCar = new Binding()
            {
                Path   = new PropertyPath("language.AddACarText"),
                Mode   = BindingMode.OneWay,
                Source = Access.dataAccess.appSettings.uiSettings
            };

            ComboBox carComboBox = new ComboBox();
            carComboBox.SetValue(Canvas.LeftProperty, 5d);
            carComboBox.SetValue(Canvas.TopProperty, 20d);
            carComboBox.Width         = 297d;
            carComboBox.ItemsSource   = CarDefinitions.physicsProfileHashNormal.Values;
            carComboBox.SelectedIndex = 0;

            Button selectButton = new Button();
            selectButton.SetValue(Canvas.LeftProperty, 148d);
            selectButton.SetValue(Canvas.TopProperty, 54d);
            selectButton.Width  = 80d;
            selectButton.Click += (object sender, RoutedEventArgs routedEventArgs) =>
            {
                selectButton.IsEnabled = false;

                CarEntity carEntity = new CarEntity();
                carEntity.baseCarId          = CarDefinitions.baseCarId.FirstOrDefault(key => key.Value == carComboBox.SelectedItem.ToString()).Key;
                carEntity.carClassHash       = CarClass.getHashFromCarClass("E");
                carEntity.durability         = 100;
                carEntity.heatLevel          = 1;
                carEntity.paints             = new List <CustomPaintTrans>().SerializeObject();
                carEntity.performanceParts   = new List <PerformancePartTrans>().SerializeObject();
                carEntity.physicsProfileHash = CarDefinitions.physicsProfileHashNormal.FirstOrDefault(key => key.Value == carComboBox.SelectedItem.ToString()).Key;
                carEntity.rating             = 123;
                carEntity.resalePrice        = 0;
                carEntity.skillModParts      = new List <SkillModPartTrans>().SerializeObject();
                carEntity.vinyls             = new List <CustomVinylTrans>().SerializeObject();
                carEntity.visualParts        = new List <VisualPartTrans>().SerializeObject();
                PersonaManagement.addCar(carEntity);
                DialogManager.HideMetroDialogAsync(this, carDialog);
                selectButton.IsEnabled = true;
            };

            Button cancelButton = new Button();
            cancelButton.SetValue(Canvas.LeftProperty, 233d);
            cancelButton.SetValue(Canvas.TopProperty, 54d);
            cancelButton.Width  = 70d;
            cancelButton.Click += (object sender, RoutedEventArgs routedEventArgs) =>
            {
                DialogManager.HideMetroDialogAsync(this, carDialog);
            };

            Canvas canvas = new Canvas();
            canvas.Children.Add(carComboBox);
            canvas.Children.Add(selectButton);
            canvas.Children.Add(cancelButton);

            carDialog         = new CustomDialog();
            carDialog.Height  = 200d;
            carDialog.Content = canvas;

            // internationalization
            BindingOperations.SetBinding(carDialog, CustomDialog.TitleProperty, lBindSelectCar);
            BindingOperations.SetBinding(selectButton, Button.ContentProperty, lBindSelect);
            BindingOperations.SetBinding(cancelButton, Button.ContentProperty, lBindCancel);
            #endregion

            #region nfswDialog
            TextBlock text = new TextBlock();
            text.HorizontalAlignment = HorizontalAlignment.Center;
            text.VerticalAlignment   = VerticalAlignment.Center;
            text.TextAlignment       = TextAlignment.Center;
            text.FontSize            = 32d;
            text.MaxWidth            = 480d;

            Viewbox viewBox = new Viewbox();
            viewBox.StretchDirection = StretchDirection.DownOnly;
            viewBox.Width            = 480d;
            viewBox.Child            = text;

            nfswDialog        = new CustomDialog();
            nfswDialog.Height = 200d;
            nfswDialog.Width  = 520d;
            nfswDialog.HorizontalContentAlignment = HorizontalAlignment.Center;
            nfswDialog.VerticalContentAlignment   = VerticalAlignment.Center;
            nfswDialog.Content = viewBox;

            Binding bindTag = new Binding()
            {
                Path   = new PropertyPath("Tag"),
                Mode   = BindingMode.OneWay,
                Source = nfswDialog
            };

            BindingOperations.SetBinding(text, TextBlock.TextProperty, bindTag);
            #endregion
        }