public void PostInitialize()
        {
            this.Width.Set(700, 0);
            this.Height.Set(500, 0);
            this.HAlign          = 0.5f;
            this.VAlign          = 0.5f;
            this.BackgroundColor = Color.Black * 0.5f;

            int currentOption = 0;

            foreach (BuyMenuButton button in MenuOptions)
            {
                button.Top.Set(5 + 42 * currentOption, 0);
                button.Left.Set(5, 0);
                button.Height.Set(38, 0);
                button.Width.Set(300, 0);

                this.Append(button);

                currentOption++;
            }

            BackButton = new BuyMenuButton("Back");
            BackButton.Top.Set(this.Height.Pixels - 60, 0);
            BackButton.Left.Set(10, 0);
            BackButton.Height.Set(38, 0);
            BackButton.Width.Set(300, 0);
            BackButton.OnClick += GoToMainMenu;

            this.Append(BackButton);
        }
        public void AddOption(string optionName, Action <UIMouseEvent, UIElement> action = null)
        {
            BuyMenuButton option = new BuyMenuButton(optionName);

            if (action != null)
            {
                option.OnClick += new UIElement.MouseEvent(action);
            }

            MenuOptions.Add(option);
        }
Beispiel #3
0
        public override void OnInitialize()
        {
            MainMenu = new BuyMenuPanel();
            var categoryIndex = 1;

            for (var i = GunCategories.Instance.FirstIndex; i < GunCategories.Instance.NextIndex; i++)
            {
                var category   = GunCategories.Instance.GetGeneric(i);
                var riflePanel = new BuyMenuPanel();

                var gunIndex = 1;
                for (var j = 0; j < category.Count; j++)
                {
                    var gun = category[j];

                    if (gun.GunItem == default)
                    {
                        continue;
                    }

                    riflePanel.AddOption($"{gunIndex} - {gun.UnlocalizedName}", gun);
                    gunIndex++;
                }

                MainMenu.AddOption($"{categoryIndex} - {category.DisplayName}", delegate { GoTo(riflePanel); });
                MainMenu.PostInitialize();

                riflePanel.PostInitialize();
                categoryIndex++;
            }

            /*MainMenu.AddOption("Pistols", delegate { GoTo(PistolMenu); } );
             * MainMenu.AddOption("SMGs");
             * MainMenu.AddOption("Heavy");
             * MainMenu.AddOption("Rifles", delegate { GoTo(RifleMenu); });
             * MainMenu.AddOption("Equipment", delegate { GoTo(EquipmentMenu); });
             * MainMenu.AddOption("Grenades");
             * MainMenu.PostInitialize();*/

            MainMenu.RemoveChild(MainMenu.BackButton);

            var backButton = new BuyMenuButton("Close");

            backButton.Top.Set(440, 0);
            backButton.Left.Set(10, 0);
            backButton.Height.Set(38, 0);
            backButton.Width.Set(300, 0);
            backButton.OnClick += delegate { Visible = false; };

            /*RifleMenu = new BuyMenuPanel();
            *  RifleMenu.AddOption("M4A4", GunDefinitions.Instance.FindGeneric(x => x.UnlocalizedName == "m4a4"));
            *  RifleMenu.AddOption("AK 47", GunDefinitions.Instance.FindGeneric(x => x.UnlocalizedName == "ak47"));
            *  RifleMenu.AddOption("AUG");
            *  RifleMenu.AddOption("SG 553");
            *  RifleMenu.PostInitialize();
            *
            *  PistolMenu = new BuyMenuPanel();
            *  PistolMenu.AddOption("Glock-18", GunDefinitions.Instance.FindGeneric(x => x.UnlocalizedName == "glock18"));
            *  PistolMenu.AddOption("Desert Eagle", GunDefinitions.Instance.FindGeneric(x => x.UnlocalizedName == "deagle"));
            *  PistolMenu.PostInitialize();
            *
            *  EquipmentMenu = new BuyMenuPanel();
            *  EquipmentMenu.AddOption("Kevlar");
            *  EquipmentMenu.AddOption("Kevlar + Helmet");
            *  EquipmentMenu.AddOption("Zeus x27");
            *  EquipmentMenu.AddOption("Diffusal Kit");
            *  EquipmentMenu.PostInitialize();*/

            MainMenu.Append(backButton);


            Append(MainMenu);
        }