Beispiel #1
0
        private void StarterPopup(Zombicide game)
        {
            UserInterface.Active.Clear();
            Panel StarterPopup = new Panel(new Vector2(600, 700), PanelSkin.Default, Anchor.Center);
            var   header       = new Header("Select Starter Weapon", Anchor.TopCenter);

            List <Texture2D> starterTextures = new List <Texture2D>();

            foreach (Item I in Item.StarterList)
            {
                string    fileName = I.Name.Replace(' ', '_');
                Texture2D item     = game.Content.Load <Texture2D>(@"Items\" + fileName);
                starterTextures.Add(item);
            }


            Image wpnImage = new Image(starterTextures.First(), new Vector2(350, 500), anchor: Anchor.AutoCenter);

            weaponIndex = 0;

            var leftButton = new Button("", ButtonSkin.Default, Anchor.CenterLeft, new Vector2(50, 50));

            leftButton.Padding = new Vector2(0, 0);
            leftButton.AddChild(new Paragraph("<", Anchor.Center));
            leftButton.OnClick = (Entity btn) =>
            {
                weaponIndex = LimitToRange(weaponIndex - 1, 0, 3);

                wpnImage.Texture = starterTextures.ElementAt(weaponIndex);
            };

            var rightButton = new Button("", ButtonSkin.Default, Anchor.CenterRight, new Vector2(50, 50));

            rightButton.Padding = new Vector2(0, 0);
            rightButton.AddChild(new Paragraph(">", Anchor.Center));
            rightButton.OnClick = (Entity btn) =>
            {
                weaponIndex      = LimitToRange(weaponIndex + 1, 0, 3);
                wpnImage.Texture = starterTextures.ElementAt(weaponIndex);
            };

            var button = new Button("OK", ButtonSkin.Default, Anchor.BottomCenter, new Vector2(300, 50));

            button.OnClick = (Entity btn) =>
            {
                SelectedCharacter.MainHandSlot        = (Weapon)Item.StarterList.Where(x => wpnImage.TextureName.Replace('_', ' ').Contains(x.Name)).First();
                SelectedCharacter.ActiveWeapon        = (Weapon)SelectedCharacter.MainHandSlot;
                SelectedCharacter.ActiveWeapon.Active = true;
                UserInterface.Active.Clear();
                game.SetNextScreen(nameof(MainGameScreen));
            };

            StarterPopup.AddChild(header);
            StarterPopup.AddChild(new HorizontalLine());
            StarterPopup.AddChild(wpnImage);
            StarterPopup.AddChild(leftButton);
            StarterPopup.AddChild(rightButton);
            StarterPopup.AddChild(button);
            UserInterface.Active.AddEntity(StarterPopup);
        }
Beispiel #2
0
 public override void Update(Zombicide game)
 {
     if (game.MouseState.LeftButton == ButtonState.Pressed &&
         newGameButtonRectangle.Contains(game.MouseState.Position))
     {
         game.SetNextScreen(nameof(CharacterSelectScreen));
     }
     textSize += .01;
 }