Example #1
0
 public Button(Texture2D bg, Vector2 position, Text text, Color c, object o)
 {
     ButtonText = text;
     Texture = bg;
     Position = position;
     StoredObject = o;
     ForeColor = c;
 }
        public override void LoadContent()
        {
            main = ScreenSystem.Content.Load<SpriteFont>(@"Fonts/menu");
            levelinfosmall = ScreenSystem.Content.Load<SpriteFont>(@"Fonts/LevelSelectSmall");
            levelinfolarge = ScreenSystem.Content.Load<SpriteFont>(@"Fonts/LevelSelectLarge");
            selectText = new Text("Select a map", main);
            selectText.Position = new Vector2(border.X, border.Y - selectText.Dimensions.Y);

            ml = ScreenSystem.Content.Load<MapLoader>("Maps\\MapLoader");
            numberOfLevelsText = new Text(String.Format("[{0} maps]", ml.Maps.Count), main);
            numberOfLevelsText.Position = new Vector2(border.X + selectText.Dimensions.X + 10,
                border.Y - numberOfLevelsText.Dimensions.Y);
            previousMap = null;
            selectedMap = ml.Maps[index];
            nextMap = (index + 1) < ml.Maps.Count ? ml.Maps[index + 1] : null;

            MapLoader.Singleton = ml;

            background = ScreenSystem.Content.Load<Texture2D>(@"Textures/Menu/MainMenuBackground");
            pixel = new Texture2D(ScreenSystem.GraphicsDevice, 1, 1);
            Color[] cArray = new Color[] { Color.Black };
            pixel.SetData<Color>(cArray);
        }
Example #3
0
        public override void LoadContent()
        {
            ContentManager content = ScreenSystem.Content;
            font = content.Load<SpriteFont>(@"Fonts/menu");
            smallfont = content.Load<SpriteFont>(@"Fonts/menusmall");

            inactiveButtonTexture = content.Load<Texture2D>("Textures\\Menu\\inactivebutton");
            activeButtonTexture = content.Load<Texture2D>("Textures\\Menu\\activebutton");

            Selected = new Color(214, 232, 223);
            Normal = new Color(104, 173, 178);

            mouse = new Mouse(content.Load<Texture2D>("Textures\\menu\\mouse"));

            musicBlock = new UIBlock(ScreenSystem.GraphicsDevice, new Rectangle(10, 110, ScreenSystem.Viewport.Width - 10, 100), Color.White);
            soundBlock = new UIBlock(ScreenSystem.GraphicsDevice, new Rectangle(10, 220, ScreenSystem.Viewport.Width - 10, 100), Color.White);

            Vector2 pos = new Vector2((int)(musicBlock.Dimensions.Left + inactiveButtonTexture.Width), (int)(musicBlock.Dimensions.Top + inactiveButtonTexture.Height));
            Button b = new Button(inactiveButtonTexture, pos,
                new Text(String.Format("Music:{0}%", (int)(Settings.MusicVolume * 100)), font, new Vector2(pos.X - (inactiveButtonTexture.Width / 2) + 10, pos.Y - (inactiveButtonTexture.Height / 2))), Normal, this);
            b.LeftClickEvent += new EventHandler(music_LeftClickEvent);
            musicBlock.Add("MusicButton", b);

            Text minstructions = new Text("Select the Music button to change settings", smallfont, new Vector2(b.Position.X + (b.Texture.Width / 2) + 10, b.ButtonText.Position.Y));
            musicBlock.Add("MusicInstructions", minstructions);

            pos = new Vector2((int)(soundBlock.Dimensions.Left + inactiveButtonTexture.Width), (int)(soundBlock.Dimensions.Top + inactiveButtonTexture.Height));
            b = new Button(inactiveButtonTexture, pos,
                new Text(String.Format("Sound:{0}%", (int)(Settings.SoundVolume * 100)), font, new Vector2(pos.X - (inactiveButtonTexture.Width / 2) + 10, pos.Y - (inactiveButtonTexture.Height / 2))), Normal, this);
            b.LeftClickEvent += new EventHandler(sound_LeftClickEvent);
            soundBlock.Add("SoundButton", b);

            minstructions = new Text("Select the Sound button to change settings", smallfont, new Vector2(b.Position.X + (b.Texture.Width / 2) + 10, b.ButtonText.Position.Y));
            soundBlock.Add("SoundInstructions", minstructions);

            backmessage = "Press Escape to go back";
        }
Example #4
0
 public Button(Text text, Color c, object o)
 {
     ButtonText = text;
     ForeColor = c;
     StoredObject = o;
 }
Example #5
0
        private void InitializeSelectedTower(Tower t)
        {
            SelectedTower.ClearAll();

            Image icon = new Image(clickedTower.Texture, new Vector2(SelectedTower.Dimensions.Left, SelectedTower.Dimensions.Top + padding));
            SelectedTower.Add("TowerIcon", icon);

            SelectedTower.Add("TowerName", new Text(clickedTower.Name + " " + (clickedTower.Level + 1).ToString(), spriteFont, new Vector2(icon.Rectangle.Right + padding, SelectedTower.Dimensions.Top + padding)));
            SelectedTower.Add("TowerDescription", new Text(clickedTower.Description, spriteFont, new Vector2(icon.Rectangle.Right + padding, SelectedTower.Dimensions.Top + padding + spriteFont.LineSpacing)));

            Text stats = new Text(clickedTower.CurrentStatistics.ToShortString(), spriteFont, new Vector2(SelectedTower.Dimensions.Left + padding, icon.Rectangle.Bottom));
            SelectedTower.Add("Stats", stats);

            Text specials = new Text(String.Format("Specials: {0}", t.bulletBase.Type == BulletType.Normal ? "None" : t.bulletBase.Type.ToString()),
                spriteFont, new Vector2(SelectedTower.Dimensions.Left + padding, stats.Rectangle.Bottom));
            SelectedTower.Add("Specials", specials);

            Text price = new Text(String.Format("Price: {0}", clickedTower.TotalCost), spriteFont, new Vector2(SelectedTower.Dimensions.Left + padding, specials.Rectangle.Bottom));
            SelectedTower.Add("Price", price);

            if (t.IsPlaced)
            {
                int pb = AddUpgradeButton(price.Rectangle.Bottom + padding);
                //AddSellButton(pb + padding);
                //AddSellButton(padding);
            }
            else
            {
                AddPurchaseButton(price.Rectangle.Bottom + padding);
            }

            string s = t.IsPlaced ? "Anular Seleccion" : "Cancelar";
            Vector2 sdim = spriteFont.MeasureString(s);

            Vector2 cbpos = new Vector2((int)(SelectedTower.Dimensions.Left + (Session.Map.SmallNormalButtonTexture.Width / 2.0f) +
                (SelectedTower.Dimensions.Width - Session.Map.SmallNormalButtonTexture.Width) / 2.0f), (int)(SelectedTower.Dimensions.Bottom - (Session.Map.SmallNormalButtonTexture.Height / 2.0f) - padding));

            Vector2 ctpos = new Vector2((int)(cbpos.X - Session.Map.SmallNormalButtonTexture.Width / 2.0f + padding),
                (int)(SelectedTower.Dimensions.Bottom - (Session.Map.SmallNormalButtonTexture.Height + sdim.Y) / 2.0f - padding));

            Button cb = new Button(Session.Map.SmallNormalButtonTexture, cbpos, new Text(s, spriteFont, ctpos), Session.Map.ForeColor, null);
            cb.LeftClickEvent += new EventHandler(cancelButton_LeftClick);
            SelectedTower.Add("Cancel", cb);
        }
Example #6
0
 public void Add(string s, Text t)
 {
     Text.Add(s, t);
 }