public SoldierViewModel(SoldierView view, Soldier soldier) { this.view = view; this.Soldier = soldier; this.View.DataContext = this.Soldier; EventGenerator(); }
public SoldierProducerViewModel(SoldiersProducer soldiersProducer, SoldierView soldierView) { this.View = new SoldierProducerView(); this.SoldierView = soldierView; SoldierProducer = soldiersProducer; this.View.DataContext = SoldierProducer; this.View.SoldierProducerBuyButton.Click += SoldierProducerBuyButtonClick; }
/// <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; } }
Soldier CreateSoldier(int type) { string name = ""; if (type == 1) { name = "Soldier1"; } else { name = "Soldier2"; } UnityEngine.Object perfab = Resources.Load("Builds/Objects/Soldier/Prefabs/" + name); GameObject go = Instantiate(perfab) as GameObject; go.transform.parent = transform; SoldierView view = go.AddComponent <SoldierView>(); Soldier soldier = new Soldier(view); return(soldier); }
public SoldierController(SoldierView soldierView) { _soldierView = soldierView; }
public Soldier(SoldierView view) { m_view = view; }
public SoldierViewModel(SoldierView view, Soldier soldier) { this.view = view; view.BuyButton.Click += BuyButton_Click; }