|
using System; |
|
|
|
namespace PepeGoesToProm |
|
{ |
|
public class Button |
|
{ |
|
public Texture2D texture {get; set;} |
|
public Rectangle positionSize {get; set;} |
|
public bool clickedOn {get; set;} |
|
public bool overButton {get; set;} |
|
public AABB collisionBox; |
|
|
|
private MouseState ms; |
|
private Color defaultColor; |
|
private Color hoverColor; |
|
private Color clickedColor; |
|
private Color color; |
|
|
|
public void LoadContent(Texture2D texture, Rectangle positionSize){ |
|
this.texture = texture; |
|
this.positionSize = positionSize; |
|
collisionBox.min = new Vector2(this.positionSize.X, this.positionSize.Y); |
|
collisionBox.max = new Vector2 (this.positionSize.X + this.positionSize.Width, this.positionSize.Y + this.positionSize.Height); |
|
} |
|
public void LoadContent(Texture2D texture, Rectangle sizePos, Color defualtColor, Color hoverColor, Color clickedColor){ |
|
this.texture = texture; |
|
this.positionSize = positionSize; |
|
this.defualtColor = defualtColor; |
|
this.hoverColor = hoverColor; |
|
this.clickedColor = clickedColor; |
|
collisionBox.min = new Vector2(this.positionSize.X, this.positionSize.Y); |
|
collisionBox.max = new Vector2 (this.positionSize.X + this.positionSize.Width, this.positionSize.Y + this.positionSize.Height); |
|
} |
|
|
|
public virtual void Update(){ |
|
|
|
} |
|
|
|
public void Draw(SpriteBatch sb){ |
|
sb.Draw(texture, positionSize, color); |
|
} |
|
|
|
public bool isOverButton(){ |
|
if(ms.Position.X > collisionBox.min.X && ms.Position.X < collisionBox.max.X && |
|
ms.Position.Y > collisionBox.min.Y && ms.Position.Y < collisionBox.max.Y) |
|
return = true; |
|
else |
|
return = false; |
|
} |
|
|
|
public bool isClickedOn(){ |
|
if (ms.Position.X > collisionBox.min.X && ms.Position.X < collisionBox.max.X && |
|
ms.Position.Y > collisionBox.min.Y && ms.Position.Y < collisionBox.max.Y && ms.LeftButton == ButtonState.Pressed) |
|
return true; |
|
else |
|
return false; |
|
} |
|
|
|
public void ResetCollision(){ |
|
collisionBox.min = new Vector2 (this.positionSize.X, this.positionSize.Y); |
|
collisionBox.max = new Vector2 (this.positionSize.X + this.positionSize.Width, this.positionSize.Y + this.positionSize.Height); |
|
} |
|
} |
|
} |