private void InitializeTablas() { int y = StatsAndControls.Dimensions.Top + padding; Vector2 d = spriteFont.MeasureString(Session.HealthDisplay); y += (int)(d.Y + spriteFont.LineSpacing); string bt = "Lanzar siguiente ola"; Vector2 btdim = spriteFont.MeasureString(bt); Texture2D tex = Session.Map.State == MapState.WaveDelay ? Session.Map.SmallNormalButtonTexture : Session.Map.SmallErrorButtonTexture; Color c = Session.Map.State == MapState.WaveDelay ? Session.Map.ForeColor : Session.Map.ErrorColor; Vector2 bpos = new Vector2((int)(SelectedTower.Dimensions.Left + (tex.Width / 2.0f) + (SelectedTower.Dimensions.Width - tex.Width) / 2.0f), (int)(y + (tex.Height / 2.0f))); Vector2 tpos = new Vector2((int)(bpos.X - tex.Width / 2.0f + padding), (int)(y + (tex.Height - btdim.Y) / 2.0f)); Button btnT1 = new Button(tex, new Vector2(bpos.X, 150), new Text("Tabla del 1", spriteFont, new Vector2(bpos.X - 62, 135)), c, clickedTower); Button btnT2 = new Button(tex, new Vector2(bpos.X, 200), new Text("Tabla del 2", spriteFont, new Vector2(bpos.X - 62, 185)), c, clickedTower); Button btnT3 = new Button(tex, new Vector2(bpos.X, 250), new Text("Tabla del 3", spriteFont, new Vector2(bpos.X - 62, 235)), c, clickedTower); Button btnT4 = new Button(tex, new Vector2(bpos.X, 300), new Text("Tabla del 4", spriteFont, new Vector2(bpos.X - 62, 285)), c, clickedTower); Button btnT5 = new Button(tex, new Vector2(bpos.X, 350), new Text("Tabla del 5", spriteFont, new Vector2(bpos.X - 62, 335)), c, clickedTower); Button btnT6 = new Button(tex, new Vector2(bpos.X, 400), new Text("Tabla del 6", spriteFont, new Vector2(bpos.X - 62, 385)), c, clickedTower); Button btnT7 = new Button(tex, new Vector2(bpos.X, 450), new Text("Tabla del 7", spriteFont, new Vector2(bpos.X - 62, 435)), c, clickedTower); Button btnT8 = new Button(tex, new Vector2(bpos.X, 500), new Text("Tabla del 8", spriteFont, new Vector2(bpos.X - 62, 485)), c, clickedTower); Button btnT9 = new Button(tex, new Vector2(bpos.X, 550), new Text("Tabla del 9", spriteFont, new Vector2(bpos.X - 62, 535)), c, clickedTower); Button btnT10 = new Button(tex, new Vector2(bpos.X, 650), new Text("Iniciar", spriteFont, new Vector2(bpos.X - 62, 635)), c, clickedTower); btnT1.LeftClickEvent += new EventHandler(tablasSeleccionda1_LeftClick); btnT2.LeftClickEvent += new EventHandler(tablasSeleccionda2_LeftClick); btnT3.LeftClickEvent += new EventHandler(tablasSeleccionda3_LeftClick); btnT4.LeftClickEvent += new EventHandler(tablasSeleccionda4_LeftClick); btnT5.LeftClickEvent += new EventHandler(tablasSeleccionda5_LeftClick); btnT6.LeftClickEvent += new EventHandler(tablasSeleccionda6_LeftClick); btnT7.LeftClickEvent += new EventHandler(tablasSeleccionda7_LeftClick); btnT8.LeftClickEvent += new EventHandler(tablasSeleccionda8_LeftClick); btnT9.LeftClickEvent += new EventHandler(tablasSeleccionda9_LeftClick); btnT10.LeftClickEvent += new EventHandler(iniciarJuego_LeftClick); SelectTablas.Add("Tabla1", btnT1); SelectTablas.Add("Tabla2", btnT2); SelectTablas.Add("Tabla3", btnT3); SelectTablas.Add("Tabla4", btnT4); SelectTablas.Add("Tabla5", btnT5); SelectTablas.Add("Tabla6", btnT6); SelectTablas.Add("Tabla7", btnT7); SelectTablas.Add("Tabla8", btnT8); SelectTablas.Add("Tabla9", btnT9); SelectTablas.Add("Iniciar", btnT10); }
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"; }
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); }
private void InitializeStatsAndControls() { //Text t; int y = StatsAndControls.Dimensions.Top + padding; //StatsAndControls.Add("Ola", new Text(String.Format("Ola {0} de {1}", waveindex + 1, Session.Map.WaveList.Count), new Vector2(StatsAndControls.Dimensions.Left + padding, y))); Vector2 d = spriteFont.MeasureString(Session.HealthDisplay); StatsAndControls.Add("Lonches", new Text(Session.HealthDisplay, new Vector2(StatsAndControls.Dimensions.Right - d.X - padding, y))); y += (int)(d.Y + spriteFont.LineSpacing); string bt = "Lanzar siguiente ola"; Vector2 btdim = spriteFont.MeasureString(bt); Texture2D tex = Session.Map.State == MapState.WaveDelay ? Session.Map.SmallNormalButtonTexture : Session.Map.SmallErrorButtonTexture; Color c = Session.Map.State == MapState.WaveDelay ? Session.Map.ForeColor : Session.Map.ErrorColor; Vector2 bpos = new Vector2((int)(SelectedTower.Dimensions.Left + (tex.Width / 2.0f) + (SelectedTower.Dimensions.Width - tex.Width) / 2.0f), (int)(y + (tex.Height / 2.0f))); Vector2 tpos = new Vector2((int)(bpos.X - tex.Width / 2.0f + padding), (int)(y + (tex.Height - btdim.Y) / 2.0f)); Button b = new Button(tex, bpos, new Text(bt, spriteFont, tpos), c, clickedTower); b.LeftClickEvent += new EventHandler(nextWave_LeftClick); StatsAndControls.Add("SiguienteOla", b); TablasMultiplicar.Add("Pregunta", new Text("", new Vector2(1017,607))); TablasMultiplicar.Add("Respuesta", new Text("", new Vector2(1117, 607))); TablasMultiplicar.Add("Poder", new Text(""+PoderesTotales, new Vector2(1000, 501))); CambiarTabla(); //x += tex.Width; //bt = "Enviar"; //btdim = spriteFont.MeasureString(bt); //bpos = new Vector2(x, (int)(y + (tex.Height / 2.0f))); //tpos = new Vector2((int)(bpos.X - tex.Width / 2.0f + padding), // (int)(y + (tex.Height - btdim.Y) / 2.0f)); //b = new Button(tex, bpos, new Text(bt, spriteFont, tpos), c, null); //b.LeftClickEvent += new EventHandler(decreaseSpeed_LeftClick); //StatsAndControls.Add("Enviar", b); /////////////////////////////////////////////////////////////////////////////////7 }
private void InitializePurchaseTower() { PurchaseTower.Add("Comprar", new Text("Comprar Torre", new Vector2(PurchaseTower.Dimensions.Left + padding, PurchaseTower.Dimensions.Top + padding))); Vector2 pos = new Vector2(PurchaseTower.Dimensions.Left + padding, PurchaseTower.Dimensions.Top + padding + (spriteFont.LineSpacing * 2)); foreach (Tower t in Session.Map.TowerList) { Button b = new Button(t.Thumbnail, Vector2.Add(pos, new Vector2(t.Thumbnail.Width / 2.0f, t.Thumbnail.Height / 2.0f)), t); b.LeftClickEvent += new EventHandler(selectTower_LeftClick); PurchaseTower.Add(t.Name, b); pos.X += t.Thumbnail.Width + padding; if (pos.X + t.Thumbnail.Width >= PurchaseTower.Dimensions.Right) { pos = new Vector2(PurchaseTower.Dimensions.Left + padding, pos.Y + t.Thumbnail.Height + padding); } } }
private int AddUpgradeButton(int y) { Button b = null; if (clickedTower.UpgradeCost <= PoderesTotales) { string bt = String.Format("Poderes: {0}", clickedTower.UpgradeCost); Vector2 btdim = spriteFont.MeasureString(bt); Vector2 bpos = new Vector2((int)(SelectedTower.Dimensions.Left + (Session.Map.SmallNormalButtonTexture.Width / 2.0f) + (SelectedTower.Dimensions.Width - Session.Map.SmallNormalButtonTexture.Width) / 2.0f), (int)(y + (Session.Map.SmallNormalButtonTexture.Height / 2.0f))); Vector2 tpos = new Vector2((int)(bpos.X - Session.Map.SmallNormalButtonTexture.Width / 2.0f + padding), (int)(y + (Session.Map.SmallNormalButtonTexture.Height - btdim.Y) / 2.0f)); b = new Button(Session.Map.SmallNormalButtonTexture, bpos, new Text(bt, spriteFont, tpos), Session.Map.ForeColor, clickedTower); b.LeftClickEvent += new EventHandler(powerTower_LeftClick); SelectedTower.Add("UpgradeTower", b); } else { string bt = String.Format("Poderes: {0}", clickedTower.UpgradeCost); Vector2 btdim = spriteFont.MeasureString(bt); Vector2 bpos = new Vector2((int)(SelectedTower.Dimensions.Left + (Session.Map.SmallErrorButtonTexture.Width / 2.0f) + (SelectedTower.Dimensions.Width - Session.Map.SmallErrorButtonTexture.Width) / 2.0f), (int)(y + (Session.Map.SmallErrorButtonTexture.Height / 2.0f))); Vector2 tpos = new Vector2((int)(bpos.X - Session.Map.SmallErrorButtonTexture.Width / 2.0f + padding), (int)(y + (Session.Map.SmallErrorButtonTexture.Height - btdim.Y) / 2.0f)); b = new Button(Session.Map.SmallErrorButtonTexture, bpos, new Text(bt, spriteFont, tpos), Session.Map.ErrorColor, clickedTower); b.Deactivate(); SelectedTower.Add("UpgradeTower", b); } return (int)(b.Position.Y - b.Origin.Y) + b.Texture.Height; }
private void AddSellButton(int y) { Button b = null; Button c = null; string st = String.Format("Vender Torre (Recibe {0})", (int)(clickedTower.TotalCost * clickedTower.SellScalar)); Vector2 stdim = spriteFont.MeasureString(st); Vector2 bpos = new Vector2((int)(SelectedTower.Dimensions.Left + (Session.Map.SmallNormalButtonTexture.Width / 2.0f) + (SelectedTower.Dimensions.Width - Session.Map.SmallNormalButtonTexture.Width) / 2.0f), (int)(y + (Session.Map.SmallNormalButtonTexture.Height / 2.0f))); Vector2 tpos = new Vector2((int)(bpos.X - Session.Map.SmallNormalButtonTexture.Width / 2.0f + padding), (int)(y + (Session.Map.SmallNormalButtonTexture.Height - stdim.Y) / 2.0f)); tpos.Y = 425; bpos.Y = tpos.Y-2; tpos.Y = 410; b = new Button(Session.Map.SmallNormalButtonTexture, bpos, new Text(st, spriteFont, tpos), Session.Map.ForeColor, clickedTower); tpos.Y = 390; bpos.Y = tpos.Y - 2; tpos.Y = 375; c = new Button(Session.Map.SmallNormalButtonTexture, bpos, new Text("Poder", spriteFont, tpos), Session.Map.ForeColor, clickedTower); b.LeftClickEvent += new EventHandler(sellTower_LeftClick); c.LeftClickEvent += new EventHandler(powerTower_LeftClick); SelectedTower.Add("SellTower", b); SelectedTower.Add("PowerTower", c); }
private void AddPurchaseButton(int y) { if (clickedTower.Cost <= Session.ActivePlayer.Money && clickedTower.Level < clickedTower.MaxLevel) { string bt = String.Format("Comprar (Cuesta {0})", clickedTower.Cost); Vector2 btdim = spriteFont.MeasureString(bt); Vector2 bpos = new Vector2((int)(SelectedTower.Dimensions.Left + (Session.Map.SmallNormalButtonTexture.Width / 2.0f) + (SelectedTower.Dimensions.Width - Session.Map.SmallNormalButtonTexture.Width) / 2.0f), (int)(y + (Session.Map.SmallNormalButtonTexture.Height / 2.0f))); Vector2 tpos = new Vector2((int)(bpos.X - Session.Map.SmallNormalButtonTexture.Width / 2.0f + padding), (int)(y + (Session.Map.SmallNormalButtonTexture.Height - btdim.Y) / 2.0f)); Button b = new Button(Session.Map.SmallNormalButtonTexture, bpos, new Text(bt, spriteFont, tpos), Session.Map.ForeColor, clickedTower); b.LeftClickEvent += new EventHandler(buyTower_LeftClick); Tower t = b.StoredObject as Tower; if (t != null) { Session.SelectTower(t); } } else { string bt = String.Format("Comprar (Cuesta {0})", clickedTower.Cost); Vector2 btdim = spriteFont.MeasureString(bt); Vector2 bpos = new Vector2((int)(SelectedTower.Dimensions.Left + (Session.Map.SmallErrorButtonTexture.Width / 2.0f) + (SelectedTower.Dimensions.Width - Session.Map.SmallErrorButtonTexture.Width) / 2.0f), (int)(y + (Session.Map.SmallErrorButtonTexture.Height / 2.0f))); Vector2 tpos = new Vector2((int)(bpos.X - Session.Map.SmallErrorButtonTexture.Width / 2.0f + padding), (int)(y + (Session.Map.SmallErrorButtonTexture.Height - btdim.Y) / 2.0f)); Button b = new Button(Session.Map.SmallErrorButtonTexture, bpos, new Text(bt, spriteFont, tpos), Session.Map.ErrorColor, clickedTower); b.Deactivate(); SelectedTower.Add("BuyTower", b); } }
public void Add(string s, Button b) { Buttons.Add(s, b); }