private async void BuyBuilding(GoldProducerUserControl view) { if (GameViewModel.Instance.GoldCounter < RessourceProducer.Price) { int rest = RessourceProducer.Price - GameViewModel.Instance.GoldCounter; System.Windows.MessageBox.Show("Il vous manque " + rest + " Golds !"); } else { GameViewModel.Instance.GoldCounter -= RessourceProducer.Price; RessourceProducer.Price *= 2; RessourceProducer.IsActive = true; RefreshView(); Token = TokenSource.Token; Task usineUnTask = new Task(() => { GameViewModel.Instance.UsineProduction(RessourceProducer.ProductSpeed, RessourceProducer.QuantityProduct, TokenSource); }, Token); usineUnTask.Start(); view.ProductTB.Visibility = Visibility.Visible; view.AcheterButton.Visibility = Visibility.Collapsed; view.UpgradeButton.Visibility = Visibility.Visible; view.LevelTB.Visibility = Visibility.Visible; view.MainGrid.Background = Brushes.Green; } }
private GoldProducersViewModel(RessourceProducer ressourceProducer) { view = new GoldProducerUserControl(this); RessourceProducer = ressourceProducer; EventsGenerator(); view.DataContext = RessourceProducer; }
private GoldProducersViewModelOld(RessourceProducer ressourceProducer) { view = new GoldProducerUserControl(this); RessourceProducer = ressourceProducer; EventsGenerator(); view.DataContext = this; view.BuildingNameLabel.DataContext = RessourceProducer; }