Ejemplo n.º 1
0
 public SoldierViewModel(SoldierView view, Soldier soldier)
 {
     this.view             = view;
     this.Soldier          = soldier;
     this.View.DataContext = this.Soldier;
     EventGenerator();
 }
Ejemplo n.º 2
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;
 }
Ejemplo n.º 3
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;
            }
        }
Ejemplo n.º 4
0
    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);
    }
Ejemplo n.º 5
0
 public SoldierController(SoldierView soldierView)
 {
     _soldierView = soldierView;
 }
Ejemplo n.º 6
0
 public Soldier(SoldierView view)
 {
     m_view = view;
 }
Ejemplo n.º 7
0
 public SoldierViewModel(SoldierView view, Soldier soldier)
 {
     this.view             = view;
     view.BuyButton.Click += BuyButton_Click;
 }