/// <summary> /// Button constructor /// </summary> /// <param name="x">x position</param> /// <param name="y">y position</param> /// <param name="Buttons">texture of the button</param> /// <param name="name">name of the button</param> /// <param name="function">function the button calls when clicked</param> public Button(int x, int y, Texture2D Buttons, string name, OnclickFunction function) : base(Buttons) { Name = name; m_Texture = Buttons; Position.X = x; Position.Y = y; TowerDefenseManager.TDLayers[4].AddEntity(this); onClick = function; }
/// <summary> /// Button constructor /// </summary> /// <param name="x">x position</param> /// <param name="y">y position</param> /// <param name="Buttons">texture of the button</param> /// <param name="name">name of the button</param> /// <param name="function">function the button calls when clicked</param> public Button(int x, int y, Texture2D Buttons, string name, OnclickFunction function) : base(Buttons) { Name = name; m_Texture = Buttons; Position.X = x; Position.Y = y; TowerDefenseManager.TDLayers[4].AddEntity(this); onClick = function; }
/// <summary> /// Adds a button(s) to the window /// </summary> /// <param name="Buttons">the texture for the buttons</param> /// <param name="names">the name of the buttons(currently use for switch statements, see TowerBuilder</param> /// <param name="functions">the function the button should call when clicked</param> public void addButton(Texture2D button, string name, OnclickFunction function) { if (name != "BuyButton") { if (Xoffset + button.Width > Position.X + m_Texture.Width) { Xoffset = 10 + (int)Position.X; Yoffset += button.Width + 10; } ButtonList.Add(new Button(Xoffset, Yoffset, button, name, function)); Xoffset += button.Width + 10; } else // specific case for the buy button to go to the right { ButtonList.Add(new Button(m_Texture.Width - 10 - button.Width, (int)Position.Y + 10, button, name, function)); } }
/// <summary> /// Adds a button(s) to the window /// </summary> /// <param name="Buttons">the texture for the buttons</param> /// <param name="names">the name of the buttons(currently use for switch statements, see TowerBuilder</param> /// <param name="functions">the function the button should call when clicked</param> public void addButton( Texture2D button, string name, OnclickFunction function) { if (name != "BuyButton") { if (Xoffset + button.Width > Position.X + m_Texture.Width) { Xoffset = 10 + (int)Position.X; Yoffset += button.Width + 10; } ButtonList.Add(new Button(Xoffset, Yoffset, button, name, function)); Xoffset += button.Width + 10; } else // specific case for the buy button to go to the right { ButtonList.Add(new Button(m_Texture.Width - 10 - button.Width, (int)Position.Y + 10, button, name, function)); } }