Added a rudimentary Inventory

This commit is contained in:
2020-06-30 13:17:50 -06:00
parent ead3b84728
commit a98b44b7bd
3 changed files with 87 additions and 29 deletions

View File

@@ -16,15 +16,14 @@ namespace Collector
{
public class Main : Game
{
private GraphicsDeviceManager _graphics;
private SpriteBatch _spriteBatch;
private InputController _inputController;
private Player _player;
private Player Player1 { get; set; }
private PlayerMouse _playerMouse;
private static OrthographicCamera _cam;
private static int _virtualWidth;
private static int _virtualHeight;
private Desktop _desktop;
private OrthographicCamera _cam;
private int _virtualWidth;
private int _virtualHeight;
private readonly Desktop _desktop;
private Gui _gui;
private World _world;
private WorldRenderer WorldRenderer { get; set; }
@@ -33,12 +32,13 @@ namespace Collector
public Main()
{
_graphics = new GraphicsDeviceManager(this);
_desktop = new Desktop();
var graphics = new GraphicsDeviceManager(this);
Content.RootDirectory = "Content";
IsMouseVisible = true;
IsFixedTimeStep = true;
_graphics.PreferMultiSampling = true;
graphics.PreferMultiSampling = true;
}
protected override void Initialize()
@@ -50,7 +50,7 @@ namespace Collector
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;
@@ -58,14 +58,14 @@ namespace Collector
var viewportAdapter = new BoxingViewportAdapter(Window, GraphicsDevice, _virtualWidth, _virtualHeight);
_world = new World();
_player = new Player(0, 0);
Player1 = new Player(0, 0);
_cam = new OrthographicCamera(viewportAdapter);
_cam.LookAt(new Vector2(Player.X, Player.Y));
_cam.Zoom = IRestrictions.Zoom;
_spriteBatch = new SpriteBatch(GraphicsDevice);
_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);
}
@@ -87,18 +87,20 @@ namespace Collector
_gui.Update();
}
public void Quit(Game main)
public void Quit()
{
Exit();
}
protected override void Draw(GameTime gameTime)
{// TODO: Add your drawing code here
{
// TODO: Add your drawing code here
var transformMatrix = _cam.GetViewMatrix();
base.Draw(gameTime);
GraphicsDevice.Clear(Color.CornflowerBlue);
//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();
WorldRenderer.Draw(gameTime);
_spriteBatch.End();

View File

@@ -104,7 +104,7 @@ namespace Collector.Character
var mouseState = Mouse.GetState();
if (keyboardState.IsKeyDown(Keys.Escape))
{
_main.Quit(main);
_main.Quit();
}
if (keyboardState.IsKeyUp(Keys.W) && keyboardState.IsKeyUp(Keys.A) && keyboardState.IsKeyUp(Keys.S) &&

View File

@@ -1,5 +1,3 @@
using System;
using Collector.Dimension;
using Microsoft.Xna.Framework;
@@ -7,7 +5,8 @@ using Myra.Graphics2D.UI;
namespace Collector.UI
{
public class Gui: IRestrictions {
public class Gui : IRestrictions
{
private Desktop _desktop;
public static ComboBox _combo;
private TextButton _button;
@@ -55,8 +54,9 @@ namespace Collector.UI
_button.Click += (s, a) =>
{
var messageBox = Dialog.CreateMessageBox("Message", "Some message!");
messageBox.ShowModal(_desktop);
var grid1 = InventoryGrid();
var window = new Window {Content = grid1};
window.ShowModal(_desktop);
};
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()
{
}