Exemplo n.º 1
0
        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;
        }
        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();
        }
        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);
        }