diff --git a/Collector/Content/Content.mgcb b/Collector/Content/Content.mgcb index f6fb229..9fcab5a 100644 --- a/Collector/Content/Content.mgcb +++ b/Collector/Content/Content.mgcb @@ -61,402 +61,6 @@ /processorParam:TextureFormat=Color /build:jungleGrass.png -#begin man.png -/importer:TextureImporter -/processor:TextureProcessor -/processorParam:ColorKeyColor=255,0,255,255 -/processorParam:ColorKeyEnabled=True -/processorParam:GenerateMipmaps=False -/processorParam:PremultiplyAlpha=True -/processorParam:ResizeToPowerOfTwo=False -/processorParam:MakeSquare=False -/processorParam:TextureFormat=Color -/build:man.png - -#begin man/man-0.png -/importer:TextureImporter -/processor:TextureProcessor -/processorParam:ColorKeyColor=255,0,255,255 -/processorParam:ColorKeyEnabled=True -/processorParam:GenerateMipmaps=False -/processorParam:PremultiplyAlpha=True -/processorParam:ResizeToPowerOfTwo=False -/processorParam:MakeSquare=False -/processorParam:TextureFormat=Color -/build:man/man-0.png - -#begin man/man-1.png -/importer:TextureImporter -/processor:TextureProcessor -/processorParam:ColorKeyColor=255,0,255,255 -/processorParam:ColorKeyEnabled=True -/processorParam:GenerateMipmaps=False -/processorParam:PremultiplyAlpha=True -/processorParam:ResizeToPowerOfTwo=False -/processorParam:MakeSquare=False -/processorParam:TextureFormat=Color -/build:man/man-1.png - -#begin man/man-10.png -/importer:TextureImporter -/processor:TextureProcessor -/processorParam:ColorKeyColor=255,0,255,255 -/processorParam:ColorKeyEnabled=True -/processorParam:GenerateMipmaps=False -/processorParam:PremultiplyAlpha=True -/processorParam:ResizeToPowerOfTwo=False -/processorParam:MakeSquare=False -/processorParam:TextureFormat=Color -/build:man/man-10.png - -#begin man/man-11.png -/importer:TextureImporter -/processor:TextureProcessor -/processorParam:ColorKeyColor=255,0,255,255 -/processorParam:ColorKeyEnabled=True -/processorParam:GenerateMipmaps=False -/processorParam:PremultiplyAlpha=True -/processorParam:ResizeToPowerOfTwo=False -/processorParam:MakeSquare=False -/processorParam:TextureFormat=Color -/build:man/man-11.png - -#begin man/man-12.png -/importer:TextureImporter -/processor:TextureProcessor -/processorParam:ColorKeyColor=255,0,255,255 -/processorParam:ColorKeyEnabled=True -/processorParam:GenerateMipmaps=False -/processorParam:PremultiplyAlpha=True -/processorParam:ResizeToPowerOfTwo=False -/processorParam:MakeSquare=False -/processorParam:TextureFormat=Color -/build:man/man-12.png - -#begin man/man-13.png -/importer:TextureImporter -/processor:TextureProcessor -/processorParam:ColorKeyColor=255,0,255,255 -/processorParam:ColorKeyEnabled=True -/processorParam:GenerateMipmaps=False -/processorParam:PremultiplyAlpha=True -/processorParam:ResizeToPowerOfTwo=False -/processorParam:MakeSquare=False -/processorParam:TextureFormat=Color -/build:man/man-13.png - -#begin man/man-14.png -/importer:TextureImporter -/processor:TextureProcessor -/processorParam:ColorKeyColor=255,0,255,255 -/processorParam:ColorKeyEnabled=True -/processorParam:GenerateMipmaps=False -/processorParam:PremultiplyAlpha=True -/processorParam:ResizeToPowerOfTwo=False -/processorParam:MakeSquare=False -/processorParam:TextureFormat=Color -/build:man/man-14.png - -#begin man/man-15.png -/importer:TextureImporter -/processor:TextureProcessor -/processorParam:ColorKeyColor=255,0,255,255 -/processorParam:ColorKeyEnabled=True -/processorParam:GenerateMipmaps=False -/processorParam:PremultiplyAlpha=True -/processorParam:ResizeToPowerOfTwo=False -/processorParam:MakeSquare=False -/processorParam:TextureFormat=Color -/build:man/man-15.png - -#begin man/man-16.png -/importer:TextureImporter -/processor:TextureProcessor -/processorParam:ColorKeyColor=255,0,255,255 -/processorParam:ColorKeyEnabled=True -/processorParam:GenerateMipmaps=False -/processorParam:PremultiplyAlpha=True -/processorParam:ResizeToPowerOfTwo=False -/processorParam:MakeSquare=False -/processorParam:TextureFormat=Color -/build:man/man-16.png - -#begin man/man-17.png -/importer:TextureImporter -/processor:TextureProcessor -/processorParam:ColorKeyColor=255,0,255,255 -/processorParam:ColorKeyEnabled=True -/processorParam:GenerateMipmaps=False -/processorParam:PremultiplyAlpha=True -/processorParam:ResizeToPowerOfTwo=False -/processorParam:MakeSquare=False -/processorParam:TextureFormat=Color -/build:man/man-17.png - -#begin man/man-18.png -/importer:TextureImporter -/processor:TextureProcessor -/processorParam:ColorKeyColor=255,0,255,255 -/processorParam:ColorKeyEnabled=True -/processorParam:GenerateMipmaps=False -/processorParam:PremultiplyAlpha=True -/processorParam:ResizeToPowerOfTwo=False -/processorParam:MakeSquare=False -/processorParam:TextureFormat=Color -/build:man/man-18.png - -#begin man/man-19.png -/importer:TextureImporter -/processor:TextureProcessor -/processorParam:ColorKeyColor=255,0,255,255 -/processorParam:ColorKeyEnabled=True -/processorParam:GenerateMipmaps=False -/processorParam:PremultiplyAlpha=True -/processorParam:ResizeToPowerOfTwo=False -/processorParam:MakeSquare=False -/processorParam:TextureFormat=Color -/build:man/man-19.png - -#begin man/man-2.png -/importer:TextureImporter -/processor:TextureProcessor -/processorParam:ColorKeyColor=255,0,255,255 -/processorParam:ColorKeyEnabled=True -/processorParam:GenerateMipmaps=False -/processorParam:PremultiplyAlpha=True -/processorParam:ResizeToPowerOfTwo=False -/processorParam:MakeSquare=False -/processorParam:TextureFormat=Color -/build:man/man-2.png - -#begin man/man-20.png -/importer:TextureImporter -/processor:TextureProcessor -/processorParam:ColorKeyColor=255,0,255,255 -/processorParam:ColorKeyEnabled=True -/processorParam:GenerateMipmaps=False -/processorParam:PremultiplyAlpha=True -/processorParam:ResizeToPowerOfTwo=False -/processorParam:MakeSquare=False -/processorParam:TextureFormat=Color -/build:man/man-20.png - -#begin man/man-21.png -/importer:TextureImporter -/processor:TextureProcessor -/processorParam:ColorKeyColor=255,0,255,255 -/processorParam:ColorKeyEnabled=True -/processorParam:GenerateMipmaps=False -/processorParam:PremultiplyAlpha=True -/processorParam:ResizeToPowerOfTwo=False -/processorParam:MakeSquare=False -/processorParam:TextureFormat=Color -/build:man/man-21.png - -#begin man/man-22.png -/importer:TextureImporter -/processor:TextureProcessor -/processorParam:ColorKeyColor=255,0,255,255 -/processorParam:ColorKeyEnabled=True -/processorParam:GenerateMipmaps=False -/processorParam:PremultiplyAlpha=True -/processorParam:ResizeToPowerOfTwo=False -/processorParam:MakeSquare=False -/processorParam:TextureFormat=Color -/build:man/man-22.png - -#begin man/man-23.png -/importer:TextureImporter -/processor:TextureProcessor -/processorParam:ColorKeyColor=255,0,255,255 -/processorParam:ColorKeyEnabled=True -/processorParam:GenerateMipmaps=False -/processorParam:PremultiplyAlpha=True -/processorParam:ResizeToPowerOfTwo=False -/processorParam:MakeSquare=False -/processorParam:TextureFormat=Color -/build:man/man-23.png - -#begin man/man-24.png -/importer:TextureImporter -/processor:TextureProcessor -/processorParam:ColorKeyColor=255,0,255,255 -/processorParam:ColorKeyEnabled=True -/processorParam:GenerateMipmaps=False -/processorParam:PremultiplyAlpha=True -/processorParam:ResizeToPowerOfTwo=False -/processorParam:MakeSquare=False -/processorParam:TextureFormat=Color -/build:man/man-24.png - -#begin man/man-25.png -/importer:TextureImporter -/processor:TextureProcessor -/processorParam:ColorKeyColor=255,0,255,255 -/processorParam:ColorKeyEnabled=True -/processorParam:GenerateMipmaps=False -/processorParam:PremultiplyAlpha=True -/processorParam:ResizeToPowerOfTwo=False -/processorParam:MakeSquare=False -/processorParam:TextureFormat=Color -/build:man/man-25.png - -#begin man/man-26.png -/importer:TextureImporter -/processor:TextureProcessor -/processorParam:ColorKeyColor=255,0,255,255 -/processorParam:ColorKeyEnabled=True -/processorParam:GenerateMipmaps=False -/processorParam:PremultiplyAlpha=True -/processorParam:ResizeToPowerOfTwo=False -/processorParam:MakeSquare=False -/processorParam:TextureFormat=Color -/build:man/man-26.png - -#begin man/man-27.png -/importer:TextureImporter -/processor:TextureProcessor -/processorParam:ColorKeyColor=255,0,255,255 -/processorParam:ColorKeyEnabled=True -/processorParam:GenerateMipmaps=False -/processorParam:PremultiplyAlpha=True -/processorParam:ResizeToPowerOfTwo=False -/processorParam:MakeSquare=False -/processorParam:TextureFormat=Color -/build:man/man-27.png - -#begin man/man-28.png -/importer:TextureImporter -/processor:TextureProcessor -/processorParam:ColorKeyColor=255,0,255,255 -/processorParam:ColorKeyEnabled=True -/processorParam:GenerateMipmaps=False -/processorParam:PremultiplyAlpha=True -/processorParam:ResizeToPowerOfTwo=False -/processorParam:MakeSquare=False -/processorParam:TextureFormat=Color -/build:man/man-28.png - -#begin man/man-29.png -/importer:TextureImporter -/processor:TextureProcessor -/processorParam:ColorKeyColor=255,0,255,255 -/processorParam:ColorKeyEnabled=True -/processorParam:GenerateMipmaps=False -/processorParam:PremultiplyAlpha=True -/processorParam:ResizeToPowerOfTwo=False -/processorParam:MakeSquare=False -/processorParam:TextureFormat=Color -/build:man/man-29.png - -#begin man/man-3.png -/importer:TextureImporter -/processor:TextureProcessor -/processorParam:ColorKeyColor=255,0,255,255 -/processorParam:ColorKeyEnabled=True -/processorParam:GenerateMipmaps=False -/processorParam:PremultiplyAlpha=True -/processorParam:ResizeToPowerOfTwo=False -/processorParam:MakeSquare=False -/processorParam:TextureFormat=Color -/build:man/man-3.png - -#begin man/man-30.png -/importer:TextureImporter -/processor:TextureProcessor -/processorParam:ColorKeyColor=255,0,255,255 -/processorParam:ColorKeyEnabled=True -/processorParam:GenerateMipmaps=False -/processorParam:PremultiplyAlpha=True -/processorParam:ResizeToPowerOfTwo=False -/processorParam:MakeSquare=False -/processorParam:TextureFormat=Color -/build:man/man-30.png - -#begin man/man-31.png -/importer:TextureImporter -/processor:TextureProcessor -/processorParam:ColorKeyColor=255,0,255,255 -/processorParam:ColorKeyEnabled=True -/processorParam:GenerateMipmaps=False -/processorParam:PremultiplyAlpha=True -/processorParam:ResizeToPowerOfTwo=False -/processorParam:MakeSquare=False -/processorParam:TextureFormat=Color -/build:man/man-31.png - -#begin man/man-4.png -/importer:TextureImporter -/processor:TextureProcessor -/processorParam:ColorKeyColor=255,0,255,255 -/processorParam:ColorKeyEnabled=True -/processorParam:GenerateMipmaps=False -/processorParam:PremultiplyAlpha=True -/processorParam:ResizeToPowerOfTwo=False -/processorParam:MakeSquare=False -/processorParam:TextureFormat=Color -/build:man/man-4.png - -#begin man/man-5.png -/importer:TextureImporter -/processor:TextureProcessor -/processorParam:ColorKeyColor=255,0,255,255 -/processorParam:ColorKeyEnabled=True -/processorParam:GenerateMipmaps=False -/processorParam:PremultiplyAlpha=True -/processorParam:ResizeToPowerOfTwo=False -/processorParam:MakeSquare=False -/processorParam:TextureFormat=Color -/build:man/man-5.png - -#begin man/man-6.png -/importer:TextureImporter -/processor:TextureProcessor -/processorParam:ColorKeyColor=255,0,255,255 -/processorParam:ColorKeyEnabled=True -/processorParam:GenerateMipmaps=False -/processorParam:PremultiplyAlpha=True -/processorParam:ResizeToPowerOfTwo=False -/processorParam:MakeSquare=False -/processorParam:TextureFormat=Color -/build:man/man-6.png - -#begin man/man-7.png -/importer:TextureImporter -/processor:TextureProcessor -/processorParam:ColorKeyColor=255,0,255,255 -/processorParam:ColorKeyEnabled=True -/processorParam:GenerateMipmaps=False -/processorParam:PremultiplyAlpha=True -/processorParam:ResizeToPowerOfTwo=False -/processorParam:MakeSquare=False -/processorParam:TextureFormat=Color -/build:man/man-7.png - -#begin man/man-8.png -/importer:TextureImporter -/processor:TextureProcessor -/processorParam:ColorKeyColor=255,0,255,255 -/processorParam:ColorKeyEnabled=True -/processorParam:GenerateMipmaps=False -/processorParam:PremultiplyAlpha=True -/processorParam:ResizeToPowerOfTwo=False -/processorParam:MakeSquare=False -/processorParam:TextureFormat=Color -/build:man/man-8.png - -#begin man/man-9.png -/importer:TextureImporter -/processor:TextureProcessor -/processorParam:ColorKeyColor=255,0,255,255 -/processorParam:ColorKeyEnabled=True -/processorParam:GenerateMipmaps=False -/processorParam:PremultiplyAlpha=True -/processorParam:ResizeToPowerOfTwo=False -/processorParam:MakeSquare=False -/processorParam:TextureFormat=Color -/build:man/man-9.png - #begin roof.png /importer:TextureImporter /processor:TextureProcessor diff --git a/Collector/Content/man/man-0.png b/Collector/Content/man/man-0.png deleted file mode 100644 index 3f2ee32..0000000 Binary files a/Collector/Content/man/man-0.png and /dev/null differ diff --git a/Collector/Content/man/man-1.png b/Collector/Content/man/man-1.png deleted file mode 100644 index bd111f1..0000000 Binary files a/Collector/Content/man/man-1.png and /dev/null differ diff --git a/Collector/Content/man/man-10.png b/Collector/Content/man/man-10.png deleted file mode 100644 index bcfe857..0000000 Binary files a/Collector/Content/man/man-10.png and /dev/null differ diff --git a/Collector/Content/man/man-11.png b/Collector/Content/man/man-11.png deleted file mode 100644 index 94c3b2f..0000000 Binary files a/Collector/Content/man/man-11.png and /dev/null differ diff --git a/Collector/Content/man/man-12.png b/Collector/Content/man/man-12.png deleted file mode 100644 index 6dddff9..0000000 Binary files a/Collector/Content/man/man-12.png and /dev/null differ diff --git a/Collector/Content/man/man-13.png b/Collector/Content/man/man-13.png deleted file mode 100644 index 0c84de9..0000000 Binary files a/Collector/Content/man/man-13.png and /dev/null differ diff --git a/Collector/Content/man/man-14.png b/Collector/Content/man/man-14.png deleted file mode 100644 index 6dddff9..0000000 Binary files a/Collector/Content/man/man-14.png and /dev/null differ diff --git a/Collector/Content/man/man-15.png b/Collector/Content/man/man-15.png deleted file mode 100644 index 53243c6..0000000 Binary files a/Collector/Content/man/man-15.png and /dev/null differ diff --git a/Collector/Content/man/man-16.png b/Collector/Content/man/man-16.png deleted file mode 100644 index e126b67..0000000 Binary files a/Collector/Content/man/man-16.png and /dev/null differ diff --git a/Collector/Content/man/man-17.png b/Collector/Content/man/man-17.png deleted file mode 100644 index 946c134..0000000 Binary files a/Collector/Content/man/man-17.png and /dev/null differ diff --git a/Collector/Content/man/man-18.png b/Collector/Content/man/man-18.png deleted file mode 100644 index e126b67..0000000 Binary files a/Collector/Content/man/man-18.png and /dev/null differ diff --git a/Collector/Content/man/man-19.png b/Collector/Content/man/man-19.png deleted file mode 100644 index 86abe9b..0000000 Binary files a/Collector/Content/man/man-19.png and /dev/null differ diff --git a/Collector/Content/man/man-2.png b/Collector/Content/man/man-2.png deleted file mode 100644 index 3f2ee32..0000000 Binary files a/Collector/Content/man/man-2.png and /dev/null differ diff --git a/Collector/Content/man/man-20.png b/Collector/Content/man/man-20.png deleted file mode 100644 index 18fe18e..0000000 Binary files a/Collector/Content/man/man-20.png and /dev/null differ diff --git a/Collector/Content/man/man-21.png b/Collector/Content/man/man-21.png deleted file mode 100644 index 3149474..0000000 Binary files a/Collector/Content/man/man-21.png and /dev/null differ diff --git a/Collector/Content/man/man-22.png b/Collector/Content/man/man-22.png deleted file mode 100644 index 18fe18e..0000000 Binary files a/Collector/Content/man/man-22.png and /dev/null differ diff --git a/Collector/Content/man/man-23.png b/Collector/Content/man/man-23.png deleted file mode 100644 index 2bc82ce..0000000 Binary files a/Collector/Content/man/man-23.png and /dev/null differ diff --git a/Collector/Content/man/man-24.png b/Collector/Content/man/man-24.png deleted file mode 100644 index bcfe857..0000000 Binary files a/Collector/Content/man/man-24.png and /dev/null differ diff --git a/Collector/Content/man/man-25.png b/Collector/Content/man/man-25.png deleted file mode 100644 index a28e72f..0000000 Binary files a/Collector/Content/man/man-25.png and /dev/null differ diff --git a/Collector/Content/man/man-26.png b/Collector/Content/man/man-26.png deleted file mode 100644 index bcfe857..0000000 Binary files a/Collector/Content/man/man-26.png and /dev/null differ diff --git a/Collector/Content/man/man-27.png b/Collector/Content/man/man-27.png deleted file mode 100644 index 94c3b2f..0000000 Binary files a/Collector/Content/man/man-27.png and /dev/null differ diff --git a/Collector/Content/man/man-28.png b/Collector/Content/man/man-28.png deleted file mode 100644 index 6dddff9..0000000 Binary files a/Collector/Content/man/man-28.png and /dev/null differ diff --git a/Collector/Content/man/man-29.png b/Collector/Content/man/man-29.png deleted file mode 100644 index 0c84de9..0000000 Binary files a/Collector/Content/man/man-29.png and /dev/null differ diff --git a/Collector/Content/man/man-3.png b/Collector/Content/man/man-3.png deleted file mode 100644 index cded3cf..0000000 Binary files a/Collector/Content/man/man-3.png and /dev/null differ diff --git a/Collector/Content/man/man-30.png b/Collector/Content/man/man-30.png deleted file mode 100644 index 6dddff9..0000000 Binary files a/Collector/Content/man/man-30.png and /dev/null differ diff --git a/Collector/Content/man/man-31.png b/Collector/Content/man/man-31.png deleted file mode 100644 index 53243c6..0000000 Binary files a/Collector/Content/man/man-31.png and /dev/null differ diff --git a/Collector/Content/man/man-4.png b/Collector/Content/man/man-4.png deleted file mode 100644 index 09a2a89..0000000 Binary files a/Collector/Content/man/man-4.png and /dev/null differ diff --git a/Collector/Content/man/man-5.png b/Collector/Content/man/man-5.png deleted file mode 100644 index 47e60f7..0000000 Binary files a/Collector/Content/man/man-5.png and /dev/null differ diff --git a/Collector/Content/man/man-6.png b/Collector/Content/man/man-6.png deleted file mode 100644 index 09a2a89..0000000 Binary files a/Collector/Content/man/man-6.png and /dev/null differ diff --git a/Collector/Content/man/man-7.png b/Collector/Content/man/man-7.png deleted file mode 100644 index f68f4a8..0000000 Binary files a/Collector/Content/man/man-7.png and /dev/null differ diff --git a/Collector/Content/man/man-8.png b/Collector/Content/man/man-8.png deleted file mode 100644 index bcfe857..0000000 Binary files a/Collector/Content/man/man-8.png and /dev/null differ diff --git a/Collector/Content/man/man-9.png b/Collector/Content/man/man-9.png deleted file mode 100644 index a28e72f..0000000 Binary files a/Collector/Content/man/man-9.png and /dev/null differ diff --git a/Collector/Main.cs b/Collector/Main.cs index defa175..50601d5 100644 --- a/Collector/Main.cs +++ b/Collector/Main.cs @@ -1,4 +1,6 @@ -using Collector.Character; +using System; +using System.IO; +using Collector.Character; using Collector.Dimension; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -20,34 +22,35 @@ namespace Collector private WorldRenderer WorldRenderer { get; set; } public Main() - { + { _graphics = new GraphicsDeviceManager(this); Content.RootDirectory = "Content"; IsMouseVisible = true; } protected override void Initialize() - {// TODO: Add your initialization logic here + { + // TODO: Add your initialization logic here base.Initialize(); BlockMaterials.Initialize(Content); var viewportAdapter = new BoxingViewportAdapter(Window, GraphicsDevice, 800, 480); - _player = new Player(0,0); + _player = new Player(0, 0); _cam = new OrthographicCamera(viewportAdapter); - _cam.LookAt(new Vector2(Player.X,Player.Y)); + _cam.LookAt(new Vector2(Player.X, Player.Y)); _spriteBatch = new SpriteBatch(GraphicsDevice); - _mouse = new Mouse(Content,_spriteBatch,_cam); - _inputController = new InputController(_player,_mouse,_cam,_spriteBatch,Content); - WorldRenderer = new WorldRenderer(_mouse,_inputController,_player,_spriteBatch,this,_cam); + _mouse = new Mouse(Content, _spriteBatch, _cam); + _inputController = new InputController(_player, _mouse, _cam, _spriteBatch, Content); + WorldRenderer = new WorldRenderer(_mouse, _inputController, _player, _spriteBatch, this, _cam); } protected override void Update(GameTime gameTime) - {// TODO: Add your update logic here/* + { + // TODO: Add your update logic here/* base.Update(gameTime); - _inputController.PlayerInput(this,_spriteBatch); - + World.LoadChunks(); World.UnloadChunks(); } @@ -59,7 +62,7 @@ namespace Collector GraphicsDevice.Clear(Color.CornflowerBlue); _spriteBatch.Begin(transformMatrix: transformMatrix); _mouse.Draw(); - WorldRenderer.Draw(); + WorldRenderer.Draw(gameTime); _spriteBatch.End(); } } diff --git a/Collector/src/Character/InputController.cs b/Collector/src/Character/InputController.cs index 243332d..fd1000f 100644 --- a/Collector/src/Character/InputController.cs +++ b/Collector/src/Character/InputController.cs @@ -9,35 +9,93 @@ using Microsoft.Xna.Framework.Input; using MonoGame.Extended; using Mouse = Collector.Character.Mouse; -public class InputController : IRestrictions { - +public class InputController : IRestrictions +{ private Player _player; private Mouse _mouse; private OrthographicCamera _cam; - private Dictionary animations; - public string Input { get; set; } - private SpriteBatch _spriteBatch; - private ContentManager _content; + private Dictionary _animations; + private string Input { get; set; } + private readonly SpriteBatch _spriteBatch; + private readonly Texture2D _texture; + private int frameNumber; + private int timeSinceLastFrame; - public InputController(Player player, Mouse mouse, OrthographicCamera cam, SpriteBatch spriteBatch, ContentManager contentManager) + + public InputController(Player player, Mouse mouse, OrthographicCamera cam, SpriteBatch spriteBatch, + ContentManager contentManager) { _player = player; _mouse = mouse; _cam = cam; _spriteBatch = spriteBatch; - _content = contentManager; + frameNumber = 0; + _texture = contentManager.Load("man"); Input = "Down"; - animations = new Dictionary + + _animations = new Dictionary { - ["Up"] = new Rectangle(0, 0, 32, 32), - ["Right"] = new Rectangle(0, 0, 32, 32), - ["Left"] = new Rectangle(0, 0, 32, 32), - ["Right"] = new Rectangle(0, 0, 32, 32) + ["Up"] = new Rectangle[4] + { + new Rectangle(32*0, 0, 32, 32), + new Rectangle(32*1, 0, 32, 32), + new Rectangle(32*2, 0, 32, 32), + new Rectangle(32*3, 0, 32, 32) + }, + ["Right"] = new Rectangle[4] + { + new Rectangle(32*0 + 32*4, 32, 32, 32), + new Rectangle(32*1 + 32*4, 32, 32, 32), + new Rectangle(32*2 + 32*4, 32, 32, 32), + new Rectangle(32*3 + 32*4, 32, 32, 32) + }, + ["UpRight"] = new Rectangle[4] + { + new Rectangle(32*0 + 32*4, 32*2, 32, 32), + new Rectangle(32*1 + 32*4, 32*2, 32, 32), + new Rectangle(32*2 + 32*4, 32*2, 32, 32), + new Rectangle(32*3 + 32*4, 32*2, 32, 32) + }, + ["DownRight"] = new Rectangle[4] + { + new Rectangle(32*0 + 32*4, 32*3, 32, 32), + new Rectangle(32*1 + 32*4, 32*3, 32, 32), + new Rectangle(32*2 + 32*4, 32*3, 32, 32), + new Rectangle(32*3 + 32*4, 32*3, 32, 32) + }, + ["Left"] = new Rectangle[4] + { + new Rectangle(32*0, 32, 32, 32), + new Rectangle(32*1, 32, 32, 32), + new Rectangle(32*2, 32, 32, 32), + new Rectangle(32*3, 32, 32, 32) + }, + ["UpLeft"] = new Rectangle[4] + { + new Rectangle(32*0, 32*2, 32, 32), + new Rectangle(32*1, 32*2, 32, 32), + new Rectangle(32*2, 32*2, 32, 32), + new Rectangle(32*3, 32*2, 32, 32) + }, + ["DownLeft"] = new Rectangle[4] + { + new Rectangle(32*0, 32, 32, 32), + new Rectangle(32*1, 32, 32, 32), + new Rectangle(32*2, 32, 32, 32), + new Rectangle(32*3, 32, 32, 32) + }, + ["Down"] = new Rectangle[4] + { + new Rectangle(32*0 + 32*4, 0, 32, 32), + new Rectangle(32*1 + 32*4, 0, 32, 32), + new Rectangle(32*2 + 32*4, 0, 32, 32), + new Rectangle(32*3 + 32*4, 0, 32, 32) + }, }; } - public void PlayerInput(Main main, SpriteBatch spriteBatch) + public void PlayerInput(Main main, Mouse mouse, GameTime gameTime) { var keyboardState = Keyboard.GetState(); const int movementSpeed = IRestrictions.MovementSpeed; @@ -45,135 +103,105 @@ public class InputController : IRestrictions { { Quit(main); } - if (keyboardState.IsKeyDown(Keys.W)) + + if (keyboardState.IsKeyUp(Keys.W) && keyboardState.IsKeyUp(Keys.A) && keyboardState.IsKeyUp(Keys.S) && keyboardState.IsKeyUp(Keys.D)) { - Input = "Up"; - Player.Y += -movementSpeed; - _cam.Move(new Vector2(0,-movementSpeed)); - } - if (keyboardState.IsKeyDown(Keys.A)) - { - Player.X += -movementSpeed; - _cam.Move(new Vector2(-movementSpeed,0)); - Input = "Left"; - } - if (keyboardState.IsKeyDown(Keys.S)) - { - Player.Y += movementSpeed; - _cam.Move(new Vector2(0,movementSpeed)); Input = "Down"; + frameNumber = 0; + _mouse.Draw(); } - if (keyboardState.IsKeyDown(Keys.D)) + if (keyboardState.IsKeyDown(Keys.W) && keyboardState.IsKeyDown(Keys.D)) { + updateAnimationFrame(gameTime); + Input = "UpRight"; + Player.Y += -movementSpeed; + Player.X += movementSpeed; + _cam.Move(new Vector2(movementSpeed, -movementSpeed)); + } + + else if (keyboardState.IsKeyDown(Keys.W) && keyboardState.IsKeyDown(Keys.A)) + { + updateAnimationFrame(gameTime); + Input = "UpLeft"; + Player.Y += -movementSpeed; + Player.X += -movementSpeed; + _cam.Move(new Vector2(-movementSpeed, -movementSpeed)); + } + + else if (keyboardState.IsKeyDown(Keys.S) && keyboardState.IsKeyDown(Keys.D)) + { + updateAnimationFrame(gameTime); + Input = "DownRight"; + Player.Y += movementSpeed; + Player.X += movementSpeed; + _cam.Move(new Vector2(movementSpeed, movementSpeed)); + } + else if (keyboardState.IsKeyDown(Keys.S) && keyboardState.IsKeyDown(Keys.A)) + { + updateAnimationFrame(gameTime); + Input = "DownLeft"; + Player.Y += movementSpeed; + Player.X += -movementSpeed; + _cam.Move(new Vector2(-movementSpeed, movementSpeed)); + } + else if (keyboardState.IsKeyDown(Keys.W)) + { + updateAnimationFrame(gameTime); + Input = "Up"; + Player.Y += -movementSpeed; + _cam.Move(new Vector2(0, -movementSpeed)); + } + else if (keyboardState.IsKeyDown(Keys.A)) + { + updateAnimationFrame(gameTime); + Player.X += -movementSpeed; + _cam.Move(new Vector2(-movementSpeed, 0)); + Input = "Left"; + } + else if (keyboardState.IsKeyDown(Keys.S)) + { + updateAnimationFrame(gameTime); + Player.Y += movementSpeed; + _cam.Move(new Vector2(0, movementSpeed)); + Input = "Down"; + } + else if (keyboardState.IsKeyDown(Keys.D)) + { + updateAnimationFrame(gameTime); Player.X += movementSpeed; _cam.Move(new Vector2(movementSpeed, 0)); Input = "Right"; } - if (keyboardState.IsKeyDown(Keys.Q)) { _cam.ZoomIn(0.01f); } - if (keyboardState.IsKeyDown(Keys.E)) { _cam.ZoomOut(0.01f); } + } + private void updateAnimationFrame(GameTime gameTime) + { + timeSinceLastFrame += gameTime.ElapsedGameTime.Milliseconds; + if (timeSinceLastFrame <= 99) return; + frameNumber++; + timeSinceLastFrame = 0; + if (frameNumber > 3) + { + frameNumber = 0; + } } private static void Quit(Game main) { main.Exit(); } - - /* - -public void handleInput() { - i++; - if (Gdx.input.isKeyPressed(Input.Keys.Q)) { - Main.cam.zoom += 5; - } - if (Gdx.input.isKeyPressed(Input.Keys.E)) { - Main.cam.zoom -= 5; - } - if ((Gdx.input.isButtonJustPressed(Input.Buttons.LEFT) || Gdx.input.isButtonJustPressed(Input.Buttons.RIGHT) )&& i > KEY_DELAY) { - Vector3 mousePos = new Vector3(Gdx.input.getX(), Gdx.input.getY(), 0); - Main.cam.unproject(mousePos); - int x = mouse.getSelectedX(mousePos) >> TILE_SHIFT; - int y = mouse.getSelectedY(mousePos) >> TILE_SHIFT; - if(Gdx.input.isButtonJustPressed(Input.Buttons.LEFT)) { - i = 0; - Chunks.placeBlock(x, y, "wood"); - } - if (Gdx.input.isButtonJustPressed(Input.Buttons.RIGHT)) { - i = 0; - Chunks.removeBlock(x,y); - } - } - - if (Gdx.input.isKeyPressed(Input.Keys.W) && Gdx.input.isKeyPressed(Input.Keys.A) && i > KEY_DELAY) { - i = 0; - player.setAnimation(animations.get("UpLeft")); - Player.addX(-MOVEMENT_SPEED); - Player.addY(MOVEMENT_SPEED); - Main.cam.translate(-MOVEMENT_SPEED, MOVEMENT_SPEED); - } - else if (Gdx.input.isKeyPressed(Input.Keys.W) && Gdx.input.isKeyPressed(Input.Keys.D) && i > KEY_DELAY) { - i = 0; - player.setAnimation(animations.get("UpRight")); - Player.addX(MOVEMENT_SPEED); - Player.addY(MOVEMENT_SPEED); - Main.cam.translate(MOVEMENT_SPEED, MOVEMENT_SPEED); - } - else if (Gdx.input.isKeyPressed(Input.Keys.S) && Gdx.input.isKeyPressed(Input.Keys.A) && i > KEY_DELAY) { - i = 0; - player.setAnimation(animations.get("DownLeft")); - Player.addX(-MOVEMENT_SPEED); - Player.addY(-MOVEMENT_SPEED); - Main.cam.translate(-MOVEMENT_SPEED, -MOVEMENT_SPEED); - } - else if (Gdx.input.isKeyPressed(Input.Keys.S) && Gdx.input.isKeyPressed(Input.Keys.D) && i > KEY_DELAY) { - i = 0; - player.setAnimation(animations.get("DownRight")); - Player.addX(MOVEMENT_SPEED); - Player.addY(-MOVEMENT_SPEED); - - Main.cam.translate(MOVEMENT_SPEED, -MOVEMENT_SPEED); - } - else if (Gdx.input.isKeyPressed(Input.Keys.A) && i > KEY_DELAY) { - i = 0; - player.setAnimation(animations.get("Left")); - Player.addX(-MOVEMENT_SPEED); - Main.cam.translate(-MOVEMENT_SPEED, 0); - } - else if (Gdx.input.isKeyPressed(Input.Keys.D) && i > KEY_DELAY) { - i = 0; - player.setAnimation(animations.get("Right")); - Player.addX(MOVEMENT_SPEED); - Main.cam.translate(MOVEMENT_SPEED, 0); - } - else if (Gdx.input.isKeyPressed(Input.Keys.S) && i > KEY_DELAY) { - i = 0; - player.setAnimation(animations.get("Down")); - Player.addY(-MOVEMENT_SPEED); - Main.cam.translate(0, -MOVEMENT_SPEED); - } - if (Gdx.input.isKeyPressed(Input.Keys.W) && i > KEY_DELAY) { - i = 0; - player.setAnimation(animations.get("Up")); - Player.addY(MOVEMENT_SPEED); - Main.cam.translate(0, MOVEMENT_SPEED); - } - Main.cam.update(); - - } - */ public void Draw() { - var texture = _content.Load("man/man-0"); - _spriteBatch.Draw(texture,new Vector2(Player.X,Player.Y),Color.White); + _spriteBatch.Draw(_texture, new Vector2(Player.X, Player.Y), _animations[Input][frameNumber], Color.White); } -} +} \ No newline at end of file diff --git a/Collector/src/Dimension/BlockMaterials.cs b/Collector/src/Dimension/BlockMaterials.cs index b38699e..08a93f8 100644 --- a/Collector/src/Dimension/BlockMaterials.cs +++ b/Collector/src/Dimension/BlockMaterials.cs @@ -5,12 +5,12 @@ using Microsoft.Xna.Framework.Graphics; namespace Collector.Dimension { - public class BlockMaterials { - public static Dictionary Materials = new Dictionary(); - public static Dictionary Textures = new Dictionary(); + public static class BlockMaterials { + public static readonly Dictionary Materials = new Dictionary(); + public static readonly Dictionary Textures = new Dictionary(); //Private so the singleton can't be instantiated - internal BlockMaterials() {} + static BlockMaterials() {} public static void Initialize(ContentManager content){ Materials.Add("grass",new Block("grass")); @@ -27,11 +27,6 @@ namespace Collector.Dimension { Textures.Add(name,content.Load(name)); } - - } - - public static void Draw(string name,SpriteBatch _spriteBatch,int x, int y) - { } } } diff --git a/Collector/src/Dimension/WorldRenderer.cs b/Collector/src/Dimension/WorldRenderer.cs index d16aab3..3aac292 100644 --- a/Collector/src/Dimension/WorldRenderer.cs +++ b/Collector/src/Dimension/WorldRenderer.cs @@ -15,8 +15,10 @@ namespace Collector.Dimension private SpriteBatch _spriteBatch; private Main _main; private OrthographicCamera _orthographicCamera; + private double _elapsedTime; - public WorldRenderer(Mouse mouse, InputController inputController, Player player, SpriteBatch spriteBatch, Main main, OrthographicCamera orthographicCamera) + public WorldRenderer(Mouse mouse, InputController inputController, Player player, SpriteBatch spriteBatch, + Main main, OrthographicCamera orthographicCamera) { _mouse = mouse; _inputController = inputController; @@ -24,6 +26,7 @@ namespace Collector.Dimension _spriteBatch = spriteBatch; _main = main; _orthographicCamera = orthographicCamera; + _elapsedTime = 0; } private static void DrawWorld(SpriteBatch batch, int layer) @@ -53,14 +56,13 @@ namespace Collector.Dimension } */ - public void Draw() + public void Draw(GameTime gameTime) { //Higher means draws in a lower layer DrawWorld(_spriteBatch, 0); _inputController.Draw(); + _inputController.PlayerInput(_main,_mouse,gameTime); DrawWorld(_spriteBatch, 1); - _mouse.Draw(); - _inputController.PlayerInput(_main,_spriteBatch); } } } \ No newline at end of file