Skip to content
Snippets Groups Projects
Commit 638e8289 authored by Trandinh Thien's avatar Trandinh Thien
Browse files

Added inventory buttons

parent 825b92f0
No related branches found
No related tags found
No related merge requests found
Showing
with 391 additions and 247 deletions
......@@ -51,7 +51,7 @@ namespace Model
private Texture2D spriteImage; // the char sprite
private Vector2 pixelCoordinates; // the pixel coordinate of the unit
private Tuple<int, int> position; // the tile location of the unit
private Button[] buttons = new Button[5]; // the buttons associated with the unit
private Button[] buttons = new Button[9]; // the buttons associated with the unit
private Texture2D charInfo, charAttackInfo; // The character and attack info textures
private int currentFrame; // the current frame the sprite is on
......@@ -68,16 +68,19 @@ namespace Model
* @param coordinates The unit's current coordinate on screen
* @param player The player of which the unit belongs to
*/
public Archer(Texture2D spriteImage, Button attackButton, Button moveButton,
Button itemButton, Button waitButton, Button confirmButton, Texture2D charInfo,
public Archer(Texture2D spriteImage, Button[] unitButtons, Texture2D charInfo,
Texture2D charAttackInfo, Vector2 coordinates)
{
this.spriteImage = spriteImage;
buttons[0] = attackButton;
buttons[1] = moveButton;
buttons[2] = itemButton;
buttons[3] = waitButton;
buttons[4] = confirmButton;
buttons[0] = unitButtons[0];
buttons[1] = unitButtons[1];
buttons[2] = unitButtons[2];
buttons[3] = unitButtons[3];
buttons[4] = unitButtons[4];
buttons[5] = unitButtons[5];
buttons[6] = unitButtons[6];
buttons[7] = unitButtons[7];
buttons[8] = unitButtons[8];
this.charInfo = charInfo;
this.charAttackInfo = charAttackInfo;
pixelCoordinates = coordinates;
......@@ -232,8 +235,16 @@ namespace Model
return buttons[2].getImage();
case ButtonType.Wait: // if wait is clicked
return buttons[3].getImage();
case ButtonType.AttackConfirm:
case ButtonType.AttackConfirm: // if attack confirm is clicked
return buttons[4].getImage();
case ButtonType.Inventory1: // if item1 clicked
return buttons[5].getImage();
case ButtonType.Inventory2: // if item2 is clicked
return buttons[6].getImage();
case ButtonType.Inventory3: // if item3 is clicked
return buttons[7].getImage();
case ButtonType.Inventory4: // if item4 is clicked
return buttons[8].getImage();
default:
return null;
}
......@@ -256,6 +267,14 @@ namespace Model
return buttons[3].Active;
case ButtonType.AttackConfirm:
return buttons[4].Active;
case ButtonType.Inventory1:
return buttons[5].Active;
case ButtonType.Inventory2:
return buttons[6].Active;
case ButtonType.Inventory3:
return buttons[7].Active;
case ButtonType.Inventory4:
return buttons[8].Active;
default:
return false;
......@@ -339,6 +358,14 @@ namespace Model
return buttons[3];
case ButtonType.AttackConfirm:
return buttons[4];
case ButtonType.Inventory1:
return buttons[5];
case ButtonType.Inventory2:
return buttons[6];
case ButtonType.Inventory3:
return buttons[7];
case ButtonType.Inventory4:
return buttons[8];
default:
return null;
......@@ -351,21 +378,20 @@ namespace Model
*/
public void setButtonCoordinates(Vector2 pixelCoordinates)
{
int increment = 0;
foreach (Button button in buttons)
int offsetInactive = 0;
for (int i = 0; i < 4; i++)
{
if (button.Active)
if (!buttons[i].Active)
{
if (button.getButtonType() != ButtonType.AttackConfirm)
{
button.setPixelCoordinates((int)(pixelCoordinates.X + 32), (int)(pixelCoordinates.Y + (increment * 32)));
increment++;
}
else if (GameState.attackConfirmOpen)
{
button.setPixelCoordinates((int)(pixelCoordinates.X + 32), (int)(pixelCoordinates.Y));
}
offsetInactive -= 32;
}
buttons[i].setPixelCoordinates((int)(pixelCoordinates.X + 32), (int)(pixelCoordinates.Y + (i * 32) + offsetInactive));
}
buttons[4].setPixelCoordinates(330, 120);
for (int i = 5; i < 9; i++)
{
buttons[i].setPixelCoordinates((int)(pixelCoordinates.X + 150), (int)(pixelCoordinates.Y + (i - 1 * 32)));
}
}
......@@ -441,7 +467,7 @@ namespace Model
{
if ((currentFrame < 6) || (currentFrame > 8)) // if unit isnt already going right, set the sprite to default facing right
{
currentFrame = 7;//increment walk cycle
currentFrame = 7;
}
else
{
......@@ -451,7 +477,7 @@ namespace Model
}
else
{
currentFrame++;
currentFrame++; //increment walk cycle
}
}
}
......
......@@ -122,6 +122,7 @@
<Content Include="GameThumbnail.png">
<XnaPlatformSpecific>true</XnaPlatformSpecific>
</Content>
<None Include="Resources\Inventory_Button.jpg" />
<None Include="Resources\exit_game.png" />
<None Include="Resources\main_menu_button.png" />
<None Include="Resources\warrior_stats.png" />
......
......@@ -6,30 +6,31 @@ Content\attack.xnb
Content\items.xnb
Content\move.xnb
Content\wait.xnb
Content\PixelFont.xnb
Content\warrior_stats.xnb
Content\PixelFontLarge.xnb
Content\warrior.xnb
Content\instructions1.xnb
Content\instructions2.xnb
Content\instructions3.xnb
Content\mage_stats.xnb
Content\archer_stats.xnb
Content\archer.xnb
Content\mage.xnb
Content\2archer.xnb
Content\2archer_attack.xnb
Content\2archer_stats.xnb
Content\2mage.xnb
Content\2mage_attack.xnb
Content\2mage_stats.xnb
Content\2warrior.xnb
Content\2warrior_attack.xnb
Content\2warrior_stats.xnb
Content\archer_attack.xnb
Content\mage_attack.xnb
Content\warrior_attack.xnb
Content\attack_confirm.xnb
Content\confirm_attack.xnb
Content\PixelFontLargest.xnb
Content\archer_stats.xnb
Content\2archer_stats.xnb
Content\2mage_stats.xnb
Content\2warrior_stats.xnb
Content\mage_stats.xnb
Content\warrior_stats.xnb
Content\exit_game.xnb
Content\PixelFont.xnb
Content\PixelFontLarge.xnb
Content\PixelFontLargest.xnb
Content\Inventory_Button.xnb
......@@ -4,6 +4,7 @@ using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Model;
namespace View
{
......@@ -15,7 +16,33 @@ namespace View
private ButtonType buttonType; // holds the button type
private Vector2 pixelCoordinates; // holds the coordinates of the menu button in question
private Texture2D buttonImage; // stores the texture for the button
public bool Active { get; set; } // sets and gets whether button is active
public bool Active { get; set; } // sets and gets whether button is active
public String item { get; set; } // sets and gets string name for item name
private Weapon weapons;
public bool hasItem { get; set; } // returns whether an item is currently bounded to button
/**
Sets and gets weapon associated with button
*/
public Weapon weapon
{
get
{
return weapons;
}
set
{
weapons = value;
if(value== null)
{
hasItem = false;// set item to false if null
}
else
{
hasItem = true;// set item to true if weapon is added
}
}
}
/**
Constructor for button
......@@ -31,6 +58,11 @@ namespace View
Active = true;
}
public void addItem(Weapon weapon)
{
}
/**
Returns the pixel coordinate of the button
*/
......@@ -76,6 +108,10 @@ namespace View
AttackConfirm,
Move,
Items,
Wait
Wait,
Inventory1,
Inventory2,
Inventory3,
Inventory4
}
}
This diff is collapsed.
......@@ -41,6 +41,10 @@ namespace Model
*/
public static bool attackConfirmOpen { get; set; }
/**
Sets and gets whether inventory menu should be open
*/
public static bool inventoryOpen { get; set; }
/**
Sets and gets if a unit has moved yet or not. beforeMOve is true before unit moves, false after it moves. Used to determine what tiles are highlighted
*/
public static bool beforeMove { get; set; }
......
......@@ -51,7 +51,7 @@ namespace Model
private Texture2D spriteImage; // the char sprite
private Vector2 pixelCoordinates; // the pixel coordinate of the unit
private Tuple<int, int> position; // the tile location of the unit
private Button[] buttons = new Button[5]; // the buttons associated with the unit
private Button[] buttons = new Button[9]; // the buttons associated with the unit
private Texture2D charInfo, charAttackInfo; // The character and attack info textures
private int currentFrame; // the current frame the sprite is on
......@@ -68,16 +68,19 @@ namespace Model
* @param coordinates The unit's current coordinate on screen
* @param player The player of which the unit belongs to
*/
public Mage(Texture2D spriteImage, Button attackButton, Button moveButton,
Button itemButton, Button waitButton, Button confirmButton, Texture2D charInfo,
public Mage(Texture2D spriteImage, Button[] unitButtons, Texture2D charInfo,
Texture2D charAttackInfo, Vector2 coordinates)
{
this.spriteImage = spriteImage;
buttons[0] = attackButton;
buttons[1] = moveButton;
buttons[2] = itemButton;
buttons[3] = waitButton;
buttons[4] = confirmButton;
buttons[0] = unitButtons[0];
buttons[1] = unitButtons[1];
buttons[2] = unitButtons[2];
buttons[3] = unitButtons[3];
buttons[4] = unitButtons[4];
buttons[5] = unitButtons[5];
buttons[6] = unitButtons[6];
buttons[7] = unitButtons[7];
buttons[8] = unitButtons[8];
this.charInfo = charInfo;
this.charAttackInfo = charAttackInfo;
pixelCoordinates = coordinates;
......@@ -232,8 +235,16 @@ namespace Model
return buttons[2].getImage();
case ButtonType.Wait: // if wait is clicked
return buttons[3].getImage();
case ButtonType.AttackConfirm:
case ButtonType.AttackConfirm: // if attack confirm is clicked
return buttons[4].getImage();
case ButtonType.Inventory1: // if item1 clicked
return buttons[5].getImage();
case ButtonType.Inventory2: // if item2 is clicked
return buttons[6].getImage();
case ButtonType.Inventory3: // if item3 is clicked
return buttons[7].getImage();
case ButtonType.Inventory4: // if item4 is clicked
return buttons[8].getImage();
default:
return null;
}
......@@ -256,6 +267,14 @@ namespace Model
return buttons[3].Active;
case ButtonType.AttackConfirm:
return buttons[4].Active;
case ButtonType.Inventory1:
return buttons[5].Active;
case ButtonType.Inventory2:
return buttons[6].Active;
case ButtonType.Inventory3:
return buttons[7].Active;
case ButtonType.Inventory4:
return buttons[8].Active;
default:
return false;
......@@ -339,6 +358,14 @@ namespace Model
return buttons[3];
case ButtonType.AttackConfirm:
return buttons[4];
case ButtonType.Inventory1:
return buttons[5];
case ButtonType.Inventory2:
return buttons[6];
case ButtonType.Inventory3:
return buttons[7];
case ButtonType.Inventory4:
return buttons[8];
default:
return null;
......@@ -351,21 +378,20 @@ namespace Model
*/
public void setButtonCoordinates(Vector2 pixelCoordinates)
{
int increment = 0;
foreach (Button button in buttons)
int offsetInactive = 0;
for (int i = 0; i < 4; i++)
{
if (button.Active)
if (!buttons[i].Active)
{
if (button.getButtonType() != ButtonType.AttackConfirm)
{
button.setPixelCoordinates((int)(pixelCoordinates.X + 32), (int)(pixelCoordinates.Y + (increment * 32)));
increment++;
}
else if (GameState.attackConfirmOpen)
{
button.setPixelCoordinates((int)(pixelCoordinates.X + 32), (int)(pixelCoordinates.Y));
}
offsetInactive -= 32;
}
buttons[i].setPixelCoordinates((int)(pixelCoordinates.X + 32), (int)(pixelCoordinates.Y + (i * 32) + offsetInactive));
}
buttons[4].setPixelCoordinates(330, 120);
for (int i = 5; i < 9; i++)
{
buttons[i].setPixelCoordinates((int)(pixelCoordinates.X + 150), (int)(pixelCoordinates.Y + (i - 1 * 32)));
}
}
......@@ -441,7 +467,7 @@ namespace Model
{
if ((currentFrame < 6) || (currentFrame > 8)) // if unit isnt already going right, set the sprite to default facing right
{
currentFrame = 7;//increment walk cycle
currentFrame = 7;
}
else
{
......@@ -451,7 +477,7 @@ namespace Model
}
else
{
currentFrame++;
currentFrame++; //increment walk cycle
}
}
}
......
......@@ -270,6 +270,16 @@ namespace Blaze_Brigade {
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap Inventory_Button {
get {
object obj = ResourceManager.GetObject("Inventory_Button", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
......
......@@ -214,4 +214,7 @@
<data name="exit_game" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>Resources\exit_game.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="Inventory_Button" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>Resources\Inventory_Button.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>
\ No newline at end of file
src/Blaze-Brigade/Blaze_Brigade/Resources/Inventory_Button.jpg

1.96 KiB

......@@ -52,7 +52,7 @@ namespace Model
private Texture2D spriteImage; // the char sprite
private Vector2 pixelCoordinates; // the pixel coordinate of the unit
private Tuple<int, int> position; // the tile location of the unit
private Button[] buttons = new Button[5]; // the buttons associated with the unit
private Button[] buttons = new Button[9]; // the buttons associated with the unit
private Texture2D charInfo, charAttackInfo; // The character and attack info textures
private int currentFrame; // the current frame the sprite is on
......@@ -69,16 +69,19 @@ namespace Model
* @param coordinates The unit's current coordinate on screen
* @param player The player of which the unit belongs to
*/
public Warrior(Texture2D spriteImage, Button attackButton, Button moveButton,
Button itemButton, Button waitButton, Button confirmButton, Texture2D charInfo,
public Warrior(Texture2D spriteImage, Button[] unitButtons, Texture2D charInfo,
Texture2D charAttackInfo, Vector2 coordinates)
{
this.spriteImage = spriteImage;
buttons[0] = attackButton;
buttons[1] = moveButton;
buttons[2] = itemButton;
buttons[3] = waitButton;
buttons[4] = confirmButton;
buttons[0] = unitButtons[0];
buttons[1] = unitButtons[1];
buttons[2] = unitButtons[2];
buttons[3] = unitButtons[3];
buttons[4] = unitButtons[4];
buttons[5] = unitButtons[5];
buttons[6] = unitButtons[6];
buttons[7] = unitButtons[7];
buttons[8] = unitButtons[8];
this.charInfo = charInfo;
this.charAttackInfo = charAttackInfo;
pixelCoordinates = coordinates;
......@@ -233,8 +236,16 @@ namespace Model
return buttons[2].getImage();
case ButtonType.Wait: // if wait is clicked
return buttons[3].getImage();
case ButtonType.AttackConfirm:
case ButtonType.AttackConfirm: // if attack confirm is clicked
return buttons[4].getImage();
case ButtonType.Inventory1: // if item1 clicked
return buttons[5].getImage();
case ButtonType.Inventory2: // if item2 is clicked
return buttons[6].getImage();
case ButtonType.Inventory3: // if item3 is clicked
return buttons[7].getImage();
case ButtonType.Inventory4: // if item4 is clicked
return buttons[8].getImage();
default:
return null;
}
......@@ -257,6 +268,14 @@ namespace Model
return buttons[3].Active;
case ButtonType.AttackConfirm:
return buttons[4].Active;
case ButtonType.Inventory1:
return buttons[5].Active;
case ButtonType.Inventory2:
return buttons[6].Active;
case ButtonType.Inventory3:
return buttons[7].Active;
case ButtonType.Inventory4:
return buttons[8].Active;
default:
return false;
......@@ -340,6 +359,14 @@ namespace Model
return buttons[3];
case ButtonType.AttackConfirm:
return buttons[4];
case ButtonType.Inventory1:
return buttons[5];
case ButtonType.Inventory2:
return buttons[6];
case ButtonType.Inventory3:
return buttons[7];
case ButtonType.Inventory4:
return buttons[8];
default:
return null;
......@@ -352,21 +379,23 @@ namespace Model
*/
public void setButtonCoordinates(Vector2 pixelCoordinates)
{
int increment = 0;
foreach (Button button in buttons)
int offsetInactive = 0;
for(int i=0; i<4; i++)
{
if (button.Active)
if (GameState.dropDownMenuOpen)
{
if (button.getButtonType() != ButtonType.AttackConfirm)
{
button.setPixelCoordinates((int)(pixelCoordinates.X + 32), (int)(pixelCoordinates.Y + (increment * 32)));
increment++;
}
else if (GameState.attackConfirmOpen)
if (buttons[i].Active)
{
button.setPixelCoordinates((int)(pixelCoordinates.X + 32), (int)(pixelCoordinates.Y));
offsetInactive -= 32;
}
buttons[i].setPixelCoordinates((int)(pixelCoordinates.X + 32), (int)(pixelCoordinates.Y + (i * 32)));
}
}
buttons[4].setPixelCoordinates(330, 120);
for (int i = 5; i < 9; i++)
{
buttons[i].setPixelCoordinates((int)(pixelCoordinates.X + 150), (int)(pixelCoordinates.Y + (i-1 * 32)));
}
}
......
......@@ -275,6 +275,13 @@
<Processor>TextureProcessor</Processor>
</Compile>
</ItemGroup>
<ItemGroup>
<Compile Include="Inventory_Button.jpg">
<Name>Inventory_Button</Name>
<Importer>TextureImporter</Importer>
<Processor>TextureProcessor</Processor>
</Compile>
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
......
src/Blaze-Brigade/Blaze_BrigadeContent/Inventory_Button.jpg

1.96 KiB

src/Blaze-Brigade/Blaze_BrigadeContent/buttons/Inventory_Button.jpg

1.96 KiB

0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment