Пример #1
0
 public SoldierProducerViewModel(SoldiersProducer soldiersProducer, SoldierView soldierView)
 {
     this.View             = new SoldierProducerView();
     this.SoldierView      = soldierView;
     SoldierProducer       = soldiersProducer;
     this.View.DataContext = SoldierProducer;
     this.View.SoldierProducerBuyButton.Click += SoldierProducerBuyButtonClick;
 }
Пример #2
0
        public String SerializeSoldierProducerJson(SoldiersProducer soldiersProducer)
        {
            String newSoldiersProducer = "";

            newSoldiersProducer = new JavaScriptSerializer().Serialize(soldiersProducer);
            Console.WriteLine(newSoldiersProducer);
            return(newSoldiersProducer);
        }
 public SoldierProducerViewModel(SoldiersProducer soldiersProducer)
 {
     this.View = new SoldierProducerView(this);
     View.SoldierView.BuyButton.Click += SoldierViewBuyButtonClick;
     SoldiersProducer  = soldiersProducer;
     View.DataContext  = SoldiersProducer;
     View.PriceTB.Text = "Prix : " + SoldiersProducer.Price.ToString();
     EventGenerator();
 }
Пример #4
0
        /// <summary>
        /// This method will find if a SoldierProducer is already bought (IsActive = true) or not and will change the view if it's necessary
        /// </summary>
        /// <param name="soldierProducer">The SoldierProducer that we want to check</param>
        private void CaserneCheck(SoldiersProducer soldierProducer, SoldierView soldierView)
        {
            switch (soldierProducer.Name)
            {
            case "Caserne":
                if (soldierProducer.IsActive == true)
                {
                    this.View.CaserneGrid.Visibility  = System.Windows.Visibility.Collapsed;
                    this.View.soldierView1.Controller = new SoldierViewModel(soldierView, soldierProducer.SoldierType);
                    this.View.soldierView1.Visibility = System.Windows.Visibility.Visible;
                }
                else
                {
                    // This dataContext allows us to see the price and the name of the SoldierProducer
                    SoldierProducerViewModel caserneView = new SoldierProducerViewModel(GameViewModel.Instance.MainCastle.SoldiersProducers[soldierProducer.Name], soldierView);
                    this.View.CaserneSP.Children.Add(caserneView.View);
                    this.View.CaserneGrid.DataContext = GameViewModel.Instance.MainCastle.SoldiersProducers["Caserne"];
                    this.View.Caserne1Button.Click   += Caserne1Button_Click;
                }
                break;

            case "Archerie":
                if (soldierProducer.IsActive == true)
                {
                    this.View.ArcherieGrid.Visibility = System.Windows.Visibility.Collapsed;
                    this.View.soldierView1.Controller = new SoldierViewModel(soldierView, soldierProducer.SoldierType);
                    this.View.soldierView2.Visibility = System.Windows.Visibility.Visible;
                }
                else
                {
                    // This dataContext allows us to see the price and the name of the SoldierProducer
                    SoldierProducerViewModel archerieView = new SoldierProducerViewModel(GameViewModel.Instance.MainCastle.SoldiersProducers[soldierProducer.Name], soldierView);
                    this.View.ArcherieSP.Children.Add(archerieView.View);
                    this.View.ArcherieGrid.DataContext = GameViewModel.Instance.MainCastle.SoldiersProducers["Archerie"];
                    this.View.Caserne2Button.Click    += Caserne2Button_Click;
                }
                break;

            case "Ecurie":
                if (soldierProducer.IsActive == true)
                {
                    this.View.EcurieGrid.Visibility   = System.Windows.Visibility.Collapsed;
                    this.View.soldierView1.Controller = new SoldierViewModel(soldierView, soldierProducer.SoldierType);
                    this.View.soldierView3.Visibility = System.Windows.Visibility.Visible;
                }
                else
                {
                    // This dataContext allows us to see the price and the name of the SoldierProducer
                    SoldierProducerViewModel archerieView = new SoldierProducerViewModel(GameViewModel.Instance.MainCastle.SoldiersProducers[soldierProducer.Name], soldierView);
                    this.View.EcurieSP.Children.Add(archerieView.View);
                    this.View.EcurieGrid.DataContext = GameViewModel.Instance.MainCastle.SoldiersProducers["Ecurie"];
                    this.View.EcurieButton.Click    += Caserne3Button_Click;
                }
                break;
            }
        }
 public static SoldierProducerViewModel GetProducersViewModelMultition(SoldiersProducer Key)
 {
     lock (_lock)
     {
         if (!_instances.ContainsKey(Key))
         {
             _instances.Add(Key, new SoldierProducerViewModel(Key));
         }
         return(_instances[Key]);
     }
 }
Пример #6
0
        private async Task <SoldiersProducer> RecupProducer(int idToRecup)
        {
            SoldiersProducer producerToRdeturn = await mySoldiersProducerSQLManager.Get(idToRecup);

            return(producerToRdeturn);
        }