protected override void OnAttach()
        {
            base.OnAttach();
            positionY = maxout;

            if (spawner == null)
            {
                spawner = Entities.Instance.GetByName("TechlabMechSpawn") as Spawner;
            }

            if (camera == null)
            {
                camera = Entities.Instance.GetByName("TechlabCam") as MapCamera;
            }

            MechsPriceList = (PriceListC)Entities.Instance.Create("MechPriceList", Map.Instance);
            AunitPriceList = (PriceListC)Entities.Instance.Create("AunitPriceList", Map.Instance);
            GunitPriceList = (PriceListC)Entities.Instance.Create("GunitPriceList", Map.Instance);
            JunitPriceList = (PriceListC)Entities.Instance.Create("JunitPriceList", Map.Instance);

            GetListOfPlayerUnits();

            cash = GetPlayerCashSQL();

            InitCameraViewFromTarget();
            //positionY = maxout;
        }
        private void UpdateDisplayedList(List <CustomizableUnit> unitList, PriceListC unitPriceList)
        {
            if (unitList != null)
            {
                currentList = unitList;
            }

            if (unitPriceList != null)
            {
                currentPriceList = unitPriceList;
            }

            maxPages = 1 + (int)(MechDBUnits.Count / 15);

            UpdatePageDisplay();

            int maxIndex = (currentPage - 1) * 15;

            for (int i = 0; i < 15; i++)
            {
                Button  BB            = window.Controls["BB" + (i + 1).ToString()] as Button;
                TextBox Mechname      = BB.Controls["MechName"] as TextBox;
                TextBox MechVar       = BB.Controls["MechVar"] as TextBox;
                Control MechIcon      = BB.Controls["MechIcon"] as Control;
                Control RelatedUnitID = BB.Controls["RelatedUnitID"] as Control;

                if (i + maxIndex >= currentList.Count)
                {
                    BB.Visible = false;
                }
                else
                {
                    int FinalUnitIndex = currentList[i + maxIndex].ID;

                    BB.Visible = true;

                    UnitType ut = currentPriceList.Type.PriceLists[FinalUnitIndex].PricedUnit as UnitType;

                    Mechname.Text        = currentPriceList.Type.PriceLists[FinalUnitIndex].Name;
                    MechVar.Text         = string.Empty;
                    MechIcon.BackTexture = TextureManager.Instance.Load(
                        "Assault Knights\\Huds\\UnitReadouts\\" + ut.Name.ToString());
                    RelatedUnitID.Text = FinalUnitIndex.ToString();

                    BB.Click += delegate(Button sender)
                    {
                        BB.Active = true;
                        ClearOtherButtons(BB.Name);
                        SelectedB = BB;
                    };
                }
            }
        }
Exemple #3
0
        protected override void OnAttach()
        {
            base.OnAttach();

            window = ControlDeclarationManager.Instance.CreateControl("Gui\\TechLabUnitCustomizeWindow.gui");
            Controls.Add(window);

            if (spawner == null)
            {
                spawner = Entities.Instance.GetByName("TechlabMechSpawn") as Spawner;
            }
            else
            {
                spawner = Entities.Instance.GetByName("TechlabMechSpawn") as Spawner;
            }

            if (camera == null)
            {
                camera = Entities.Instance.GetByName("TechlabCam") as MapCamera;
            }
            else
            {
                camera = Entities.Instance.GetByName("TechlabCam") as MapCamera;
            }

            //declare controls
            btnMechs        = (Button)window.Controls["Mechs"];
            btnMechs.Click += new Button.ClickDelegate(btnMechs_Click);

            btnGroundUnits        = (Button)window.Controls["Gunit"];
            btnGroundUnits.Click += new Button.ClickDelegate(btnGroundUnits_Click);

            btnAirUnits        = (Button)window.Controls["Aunit"];
            btnAirUnits.Click += new Button.ClickDelegate(btnAirUnits_Click);

            btnJets        = (Button)window.Controls["Junit"];
            btnJets.Click += new Button.ClickDelegate(btnJets_Click);

            btnNext        = (Button)window.Controls["Next"];
            btnNext.Click += new Button.ClickDelegate(btnNext_Click);

            btnPrevious        = (Button)window.Controls["Previous"];
            btnPrevious.Click += new Button.ClickDelegate(btnPrevious_Click);

            btnRA        = (Button)window.Controls["RA"];
            btnRA.Click += new Button.ClickDelegate(btnRA_Click);

            btnRT        = (Button)window.Controls["RT"];
            btnRT.Click += new Button.ClickDelegate(btnRT_Click);

            btnCT        = (Button)window.Controls["CT"];
            btnCT.Click += new Button.ClickDelegate(btnCT_Click);

            btnLT        = (Button)window.Controls["LT"];
            btnLT.Click += new Button.ClickDelegate(btnLT_Click);

            btnLA        = (Button)window.Controls["LA"];
            btnLA.Click += new Button.ClickDelegate(btnLA_Click);
            //iNCIN -- SlotList
            cbxWeaponSlots = (ListBox)window.Controls["SlotList"];
            cbxWeaponSlots.SelectedIndexChange +=
                new ListBox.SelectedIndexChangeDelegate(cbxWeaponSlots_SelectedIndexChange);

            cbxVariantList = (ListBox)window.Controls["VariantList"];
            cbxVariantList.SelectedIndexChange +=
                new ListBox.SelectedIndexChangeDelegate(cbxVariantList_SelectedIndexChange);

            lstWeaponList = (ListBox)window.Controls["WeaponList"];
            lstWeaponList.SelectedIndexChange +=
                new ListBox.SelectedIndexChangeDelegate(lstWeaponList_SelectedIndexChange);

            btnAddWeapon        = (Button)window.Controls["AddWeapon"];
            btnAddWeapon.Click += new Button.ClickDelegate(btnAddWeapon_Click);

            txtWeaponInfo = (EditBox)window.Controls["WeaponInfo"];
            txtCash       = (TextBox)window.Controls["Cash"];

            btnSaveVariant        = (Button)window.Controls["SaveCustomUnit"];
            btnSaveVariant.Click += new Button.ClickDelegate(btnSaveVariant_Click);

            btnExit        = (Button)window.Controls["Quit"];
            btnExit.Click += new Button.ClickDelegate(btnExit_Click);

            txtUnitName = (TextBox)window.Controls["UnitName"];

            MechsPriceList = (PriceListC)Entities.Instance.Create("MechPriceList", Map.Instance);
            AunitPriceList = (PriceListC)Entities.Instance.Create("AunitPriceList", Map.Instance);
            GunitPriceList = (PriceListC)Entities.Instance.Create("GunitPriceList", Map.Instance);
            JunitPriceList = (PriceListC)Entities.Instance.Create("JunitPriceList", Map.Instance);

            GetListOfPlayerUnits();

            cash = GetPlayerCashSQL();

            if (MechDBUnits.Count == 0)
            {
                btnMechs.Enable = false;
            }

            if (ADBUnits.Count == 0)
            {
                btnAirUnits.Enable = false;
            }

            if (GDBUnits.Count == 0)
            {
                btnGroundUnits.Enable = false;
            }

            if (JDBUnits.Count == 0)
            {
                btnJets.Enable = false;
            }

            if (MechDBUnits.Count == 0 || ADBUnits.Count == 0 || GDBUnits.Count == 0 || JDBUnits.Count == 0)
            {
                //player has not bought any units
                Log.Info("No units purchased. TODO: ask user if they want to go to buy window");
            }

            InitCameraViewFromTarget();
            //positionY = maxout;

            spawner.UnitSpawned += new Spawner.OnUnitSpawned(spawner_UnitSpawned);
        }
        protected override void OnAttach()
        {
            base.OnAttach();

            window = ControlDeclarationManager.Instance.CreateControl("Gui\\PlayerBuyWindow.gui");
            Controls.Add(window);

            MechsPriceList = (PriceListC)Entities.Instance.Create("MechPriceList", Map.Instance);
            AunitPriceList = (PriceListC)Entities.Instance.Create("AunitPriceList", Map.Instance);
            GunitPriceList = (PriceListC)Entities.Instance.Create("GunitPriceList", Map.Instance);
            JunitPriceList = (PriceListC)Entities.Instance.Create("JunitPriceList", Map.Instance);

            ((Button)window.Controls["Close"]).Click += delegate(Button sender) { SetShouldDetach(); };

            btnBuy        = (Button)window.Controls["Buy"];
            btnBuy.Click += new Button.ClickDelegate(btnBuy_Click);
            btnBuy.Enable = false;

            btnMechs       = window.Controls["MechsB"] as Button;
            btnAirUnits    = window.Controls["Aunits"] as Button;
            btnGroundUnits = window.Controls["Gunits"] as Button;
            btnJets        = window.Controls["Junits"] as Button;

            btnNext        = (Button)window.Controls["NextB"];
            btnNext.Click += new Button.ClickDelegate(btnNext_Click);

            btnPrevious        = (Button)window.Controls["PreviousB"];
            btnPrevious.Click += new Button.ClickDelegate(btnPrevious_Click);

            txtPageInfo = (TextBox)window.Controls["Pageinfo"];

            variantList = (ComboBox)window.Controls["CustomUnit"];
            variantList.Items.Add("Stock");
            variantList.SelectedIndex        = 0;
            variantList.SelectedIndexChange += new ComboBox.SelectedIndexChangeDelegate(variantList_SelectedIndexChange);

            if (mechHangar != null)
            {
                btnMechs.Click += new Button.ClickDelegate(btnMechs_Click);
            }
            else
            {
                btnMechs.Enable = false;
            }

            if (groundUnitHangar != null)
            {
                btnGroundUnits.Click += new Button.ClickDelegate(btnGroundUnits_Click);
            }
            else
            {
                btnGroundUnits.Enable = false;
            }

            if (airUnitHangar != null)
            {
                btnAirUnits.Click += new Button.ClickDelegate(btnAirUnits_Click);
            }
            else
            {
                btnAirUnits.Enable = false;
            }

            if (jetHangar != null)
            {
                btnJets.Click += new Button.ClickDelegate(btnJets_Click);
            }
            else
            {
                btnJets.Enable = false;
            }

            GetListOfPlayerUnits();

            SetupFirstList();
        }
Exemple #5
0
        protected override void OnAttach()
        {
            window = ControlDeclarationManager.Instance.CreateControl("Gui\\TechLabUnitBuyWindow.gui");
            Controls.Add(window);

            if (spawner == null)
            {
                spawner = Entities.Instance.GetByName("TechlabMechSpawn") as Spawner;
            }
            else
            {
                spawner = Entities.Instance.GetByName("TechlabMechSpawn") as Spawner;
            }

            if (camera == null)
            {
                camera = Entities.Instance.GetByName("TechlabCam") as MapCamera;
            }
            else
            {
                camera = Entities.Instance.GetByName("TechlabCam") as MapCamera;
            }

            btnMechs        = (Button)window.Controls["Mechs"];
            btnMechs.Click += new Button.ClickDelegate(btnMechs_Click);

            btnGroundUnits        = (Button)window.Controls["Gunit"];
            btnGroundUnits.Click += new Button.ClickDelegate(btnGroundUnits_Click);

            btnAirUnits        = (Button)window.Controls["Aunit"];
            btnAirUnits.Click += new Button.ClickDelegate(btnAirUnits_Click);

            btnJets        = (Button)window.Controls["Junit"];
            btnJets.Click += new Button.ClickDelegate(btnJets_Click);

            btnExit        = (Button)window.Controls["Quit"];
            btnExit.Click += new Button.ClickDelegate(btnExit_Click);

            btnNext        = (Button)window.Controls["Next"];
            btnNext.Click += new Button.ClickDelegate(btnNext_Click);

            btnPrevious        = (Button)window.Controls["Previous"];
            btnPrevious.Click += new Button.ClickDelegate(btnPrevious_Click);

            btnBuy        = (Button)window.Controls["Buy"];
            btnBuy.Click += new Button.ClickDelegate(btnBuy_Click);

            txtUnitName = (TextBox)window.Controls["UnitName"];
            txtUnitCost = (TextBox)window.Controls["UnitCost"];
            txtCash     = (TextBox)window.Controls["Cash"];

            txtCash.Text = "Cash: " + cash.ToString();

            lstWeapons = (ListBox)window.Controls["Weapons"];

            spawner.UnitSpawned += new Spawner.OnUnitSpawned(spawner_UnitSpawned);

            InitCameraViewFromTarget();
            //positionY = maxout;

            MechsPriceList = (PriceListC)Entities.Instance.Create("MechPriceList", Map.Instance);
            AunitPriceList = (PriceListC)Entities.Instance.Create("AunitPriceList", Map.Instance);
            GunitPriceList = (PriceListC)Entities.Instance.Create("GunitPriceList", Map.Instance);
            JunitPriceList = (PriceListC)Entities.Instance.Create("JunitPriceList", Map.Instance);

            GetListOfPlayerUnits();

            cash = GetPlayerCashSQL();

            base.OnAttach();
        }