Added a rudimentary Inventory
This commit is contained in:
@@ -16,15 +16,14 @@ namespace Collector
|
|||||||
{
|
{
|
||||||
public class Main : Game
|
public class Main : Game
|
||||||
{
|
{
|
||||||
private GraphicsDeviceManager _graphics;
|
|
||||||
private SpriteBatch _spriteBatch;
|
private SpriteBatch _spriteBatch;
|
||||||
private InputController _inputController;
|
private InputController _inputController;
|
||||||
private Player _player;
|
private Player Player1 { get; set; }
|
||||||
private PlayerMouse _playerMouse;
|
private PlayerMouse _playerMouse;
|
||||||
private static OrthographicCamera _cam;
|
private OrthographicCamera _cam;
|
||||||
private static int _virtualWidth;
|
private int _virtualWidth;
|
||||||
private static int _virtualHeight;
|
private int _virtualHeight;
|
||||||
private Desktop _desktop;
|
private readonly Desktop _desktop;
|
||||||
private Gui _gui;
|
private Gui _gui;
|
||||||
private World _world;
|
private World _world;
|
||||||
private WorldRenderer WorldRenderer { get; set; }
|
private WorldRenderer WorldRenderer { get; set; }
|
||||||
@@ -33,12 +32,13 @@ namespace Collector
|
|||||||
|
|
||||||
public Main()
|
public Main()
|
||||||
{
|
{
|
||||||
_graphics = new GraphicsDeviceManager(this);
|
_desktop = new Desktop();
|
||||||
|
var graphics = new GraphicsDeviceManager(this);
|
||||||
Content.RootDirectory = "Content";
|
Content.RootDirectory = "Content";
|
||||||
|
|
||||||
IsMouseVisible = true;
|
IsMouseVisible = true;
|
||||||
IsFixedTimeStep = true;
|
IsFixedTimeStep = true;
|
||||||
_graphics.PreferMultiSampling = true;
|
graphics.PreferMultiSampling = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Initialize()
|
protected override void Initialize()
|
||||||
@@ -50,7 +50,7 @@ namespace Collector
|
|||||||
|
|
||||||
foreach (Blocks name in Enum.GetValues(typeof(Blocks)))
|
foreach (Blocks name in Enum.GetValues(typeof(Blocks)))
|
||||||
{
|
{
|
||||||
Materials.Add(name,Content.Load<Texture2D>(name.ToString()));
|
Materials.Add(name, Content.Load<Texture2D>(name.ToString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
_virtualWidth = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width;
|
_virtualWidth = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width;
|
||||||
@@ -58,14 +58,14 @@ namespace Collector
|
|||||||
|
|
||||||
var viewportAdapter = new BoxingViewportAdapter(Window, GraphicsDevice, _virtualWidth, _virtualHeight);
|
var viewportAdapter = new BoxingViewportAdapter(Window, GraphicsDevice, _virtualWidth, _virtualHeight);
|
||||||
_world = new World();
|
_world = new World();
|
||||||
_player = new Player(0, 0);
|
Player1 = new Player(0, 0);
|
||||||
_cam = new OrthographicCamera(viewportAdapter);
|
_cam = new OrthographicCamera(viewportAdapter);
|
||||||
_cam.LookAt(new Vector2(Player.X, Player.Y));
|
_cam.LookAt(new Vector2(Player.X, Player.Y));
|
||||||
_cam.Zoom = IRestrictions.Zoom;
|
_cam.Zoom = IRestrictions.Zoom;
|
||||||
|
|
||||||
_spriteBatch = new SpriteBatch(GraphicsDevice);
|
_spriteBatch = new SpriteBatch(GraphicsDevice);
|
||||||
_playerMouse = new PlayerMouse(Content, _spriteBatch, _cam);
|
_playerMouse = new PlayerMouse(Content, _spriteBatch, _cam);
|
||||||
_inputController = new InputController(_cam, _spriteBatch, Content,this);
|
_inputController = new InputController(_cam, _spriteBatch, Content, this);
|
||||||
WorldRenderer = new WorldRenderer(_playerMouse, _inputController, _spriteBatch, this);
|
WorldRenderer = new WorldRenderer(_playerMouse, _inputController, _spriteBatch, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -87,18 +87,20 @@ namespace Collector
|
|||||||
_gui.Update();
|
_gui.Update();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Quit(Game main)
|
public void Quit()
|
||||||
{
|
{
|
||||||
Exit();
|
Exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Draw(GameTime gameTime)
|
protected override void Draw(GameTime gameTime)
|
||||||
{// TODO: Add your drawing code here
|
{
|
||||||
|
// TODO: Add your drawing code here
|
||||||
var transformMatrix = _cam.GetViewMatrix();
|
var transformMatrix = _cam.GetViewMatrix();
|
||||||
base.Draw(gameTime);
|
base.Draw(gameTime);
|
||||||
GraphicsDevice.Clear(Color.CornflowerBlue);
|
GraphicsDevice.Clear(Color.CornflowerBlue);
|
||||||
//Turn on Anti-aliasing by changing SamplerState.PointClamp
|
//Turn on Anti-aliasing by changing SamplerState.PointClamp
|
||||||
_spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.None, RasterizerState.CullNone, transformMatrix: transformMatrix);
|
_spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp,
|
||||||
|
DepthStencilState.None, RasterizerState.CullNone, transformMatrix: transformMatrix);
|
||||||
_playerMouse.Draw();
|
_playerMouse.Draw();
|
||||||
WorldRenderer.Draw(gameTime);
|
WorldRenderer.Draw(gameTime);
|
||||||
_spriteBatch.End();
|
_spriteBatch.End();
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ namespace Collector.Character
|
|||||||
var mouseState = Mouse.GetState();
|
var mouseState = Mouse.GetState();
|
||||||
if (keyboardState.IsKeyDown(Keys.Escape))
|
if (keyboardState.IsKeyDown(Keys.Escape))
|
||||||
{
|
{
|
||||||
_main.Quit(main);
|
_main.Quit();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (keyboardState.IsKeyUp(Keys.W) && keyboardState.IsKeyUp(Keys.A) && keyboardState.IsKeyUp(Keys.S) &&
|
if (keyboardState.IsKeyUp(Keys.W) && keyboardState.IsKeyUp(Keys.A) && keyboardState.IsKeyUp(Keys.S) &&
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
|
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using Collector.Dimension;
|
using Collector.Dimension;
|
||||||
using Microsoft.Xna.Framework;
|
using Microsoft.Xna.Framework;
|
||||||
@@ -7,7 +5,8 @@ using Myra.Graphics2D.UI;
|
|||||||
|
|
||||||
namespace Collector.UI
|
namespace Collector.UI
|
||||||
{
|
{
|
||||||
public class Gui: IRestrictions {
|
public class Gui : IRestrictions
|
||||||
|
{
|
||||||
private Desktop _desktop;
|
private Desktop _desktop;
|
||||||
public static ComboBox _combo;
|
public static ComboBox _combo;
|
||||||
private TextButton _button;
|
private TextButton _button;
|
||||||
@@ -55,8 +54,9 @@ namespace Collector.UI
|
|||||||
|
|
||||||
_button.Click += (s, a) =>
|
_button.Click += (s, a) =>
|
||||||
{
|
{
|
||||||
var messageBox = Dialog.CreateMessageBox("Message", "Some message!");
|
var grid1 = InventoryGrid();
|
||||||
messageBox.ShowModal(_desktop);
|
var window = new Window {Content = grid1};
|
||||||
|
window.ShowModal(_desktop);
|
||||||
};
|
};
|
||||||
|
|
||||||
grid.Widgets.Add(_button);
|
grid.Widgets.Add(_button);
|
||||||
@@ -67,6 +67,62 @@ namespace Collector.UI
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Grid InventoryGrid()
|
||||||
|
{
|
||||||
|
var textBox1 = new TextBox {AcceptsKeyboardFocus = true};
|
||||||
|
var checkBox1 = new CheckBox {Text = "Item1", GridRow = 1, AcceptsKeyboardFocus = false};
|
||||||
|
var checkBox2 = new CheckBox {Text = "Item2", GridRow = 2, AcceptsKeyboardFocus = false};
|
||||||
|
var checkBox3 = new CheckBox {Text = "Item3", GridRow = 3, AcceptsKeyboardFocus = false};
|
||||||
|
var checkBox4 = new CheckBox {Text = "Item4", GridRow = 4, AcceptsKeyboardFocus = false};
|
||||||
|
var checkBox5 = new CheckBox {Text = "Item5", GridRow = 5, AcceptsKeyboardFocus = false};
|
||||||
|
var checkBox6 = new CheckBox {Text = "Item6", GridRow = 6, AcceptsKeyboardFocus = false};
|
||||||
|
var checkBox7 = new CheckBox {Text = "Item7", GridRow = 7, AcceptsKeyboardFocus = false};
|
||||||
|
var checkBox8 = new CheckBox {Text = "Item8", GridRow = 8, AcceptsKeyboardFocus = false};
|
||||||
|
var checkBox9 = new CheckBox {Text = "Item9", GridRow = 9, AcceptsKeyboardFocus = false};
|
||||||
|
var checkBox10 = new CheckBox {Text = "Item10", GridRow = 10, AcceptsKeyboardFocus = false};
|
||||||
|
var menuItem1 = new MenuItem {Text = "Drop"};
|
||||||
|
var menuItem2 = new MenuItem {Text = "Use"};
|
||||||
|
var menuItem3 = new MenuItem {Text = "Equip"};
|
||||||
|
var horizontalMenu1 = new HorizontalMenu {AcceptsKeyboardFocus = true, GridColumn = 1};
|
||||||
|
horizontalMenu1.Items.Add(menuItem1);
|
||||||
|
horizontalMenu1.Items.Add(menuItem2);
|
||||||
|
horizontalMenu1.Items.Add(menuItem3);
|
||||||
|
var label1 = new Label {Text = "Description1", GridColumn = 1, GridRow = 1, AcceptsKeyboardFocus = false};
|
||||||
|
var label2 = new Label {Text = "Description2", GridColumn = 1, GridRow = 2, AcceptsKeyboardFocus = false};
|
||||||
|
var label3 = new Label {Text = "Description3", GridColumn = 1, GridRow = 3, AcceptsKeyboardFocus = false};
|
||||||
|
var label4 = new Label {Text = "Description4", GridColumn = 1, GridRow = 4, AcceptsKeyboardFocus = false};
|
||||||
|
var label5 = new Label {Text = "Description5", GridColumn = 1, GridRow = 5, AcceptsKeyboardFocus = false};
|
||||||
|
var label6 = new Label {Text = "Description6", GridColumn = 1, GridRow = 6, AcceptsKeyboardFocus = false};
|
||||||
|
var label7 = new Label {Text = "Description7", GridColumn = 1, GridRow = 7, AcceptsKeyboardFocus = false};
|
||||||
|
var label8 = new Label {Text = "Description8", GridColumn = 1, GridRow = 8, AcceptsKeyboardFocus = false};
|
||||||
|
var label9 = new Label {Text = "Description9", GridColumn = 1, GridRow = 9, AcceptsKeyboardFocus = false};
|
||||||
|
var label10 = new Label {Text = "Description10", GridColumn = 1, GridRow = 10, AcceptsKeyboardFocus = false};
|
||||||
|
var grid1 = new Grid {ShowGridLines = true, AcceptsKeyboardFocus = false};
|
||||||
|
grid1.Widgets.Add(textBox1);
|
||||||
|
grid1.Widgets.Add(checkBox1);
|
||||||
|
grid1.Widgets.Add(checkBox2);
|
||||||
|
grid1.Widgets.Add(checkBox3);
|
||||||
|
grid1.Widgets.Add(checkBox4);
|
||||||
|
grid1.Widgets.Add(checkBox5);
|
||||||
|
grid1.Widgets.Add(checkBox6);
|
||||||
|
grid1.Widgets.Add(checkBox7);
|
||||||
|
grid1.Widgets.Add(checkBox8);
|
||||||
|
grid1.Widgets.Add(checkBox9);
|
||||||
|
grid1.Widgets.Add(checkBox10);
|
||||||
|
grid1.Widgets.Add(horizontalMenu1);
|
||||||
|
grid1.Widgets.Add(label1);
|
||||||
|
grid1.Widgets.Add(label2);
|
||||||
|
grid1.Widgets.Add(label3);
|
||||||
|
grid1.Widgets.Add(label4);
|
||||||
|
grid1.Widgets.Add(label5);
|
||||||
|
grid1.Widgets.Add(label6);
|
||||||
|
grid1.Widgets.Add(label7);
|
||||||
|
grid1.Widgets.Add(label8);
|
||||||
|
grid1.Widgets.Add(label9);
|
||||||
|
grid1.Widgets.Add(label10);
|
||||||
|
return grid1;
|
||||||
|
}
|
||||||
|
|
||||||
public void Update()
|
public void Update()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user