Advertisement

C# XNA 4.0 How to serialize a 2D array?

Started by March 06, 2018 01:13 PM
44 comments, last by Shawn Naef 6 years, 9 months ago

If your problem is entering in all of your Tile ID's by hand into your array then make a simple Tilemap editor and have it export this binary file that your game can load in and convert to a SaveGame object at runtime. 

Oh no that's not the issue. I expect to have to hand edit my world. Its trying to list each arrays cell value manually that would be a bad way to do it, that is by separating certain information from the world map and saving that instead would require hard coding.

 

I'm getting a 0 overload method error when trying to fire off WriteSave()

Advertisement

Here is the MSDN article on Serialization, it uses FileStream and  BinaryFormatter. Its the VS 2010 version.

https://msdn.microsoft.com/en-us/library/b85344hz(v=vs.100).aspx

You should really convert to Monogame. 

My head feels like its going to explode right now lol

What about converting to a long string file like this

 

[0][1][2]

[1][2][3]

[2][3][4]

 

 

value 0 +,+value1+,+value2+,+value3  etc

 

So

 

string worldArray = new string "0,1,2,3,4,5,6,7,8"

I still need help with this issue if anyone knows the answer. Thanks

Hello Shawn Naef,

The solution was already provided. Convert your 2D array to Jagged, serialize, then when you bring it back unload your Jagged back into a 2D array.

Were you able to try the above? If so, did you run into more issues?

You also can use Jagged in the same form as 2D Arrays when printing tiles. Instead of myMap[y, x], use myMap[y][x]. You might want to consider just moving from 2D Arrays to Jagged all together if it's a problem.

Maybe I'm missing something here?

Programmer and 3D Artist

Advertisement

I tried and i couldn't figure out exactly how to do it. I did try converting the array and it seems to work as a jagged like this:

 


int[,] tileMap = new int[67,30]
        {
            { 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 1, 1, 1, 1, 4, 5, 1, 1, 1, 1, 1, 2, 3, 1, 1, 1, 1, 1, 1, 1, },
            { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, },
            { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, },
            { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, },
            { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, },
            { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, },
            { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, },
            { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, },
            { 1, 1, 1, 1, 1, 1, 1, 1, 1, 11, 1, 1, 1, 1, 1, 6, 1, 1, 1, 1, 1, 7, 8, 1, 1, 1, 1, 1, 1, 1, },
            { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 0, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, },
            { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, },
            { 10, 10, 10, 10, 0, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, },
            { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, },
            { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, },
            { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, },
            { 10, 10, 10, 10, 0, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, },
            { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, },
            { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, },
            { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, },
            { 10, 10, 10, 10, 0, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, },
            { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, },
            { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, },
            { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, },
            { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, },
            { 10, 10, 10, 10, 0, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, },
            { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, },
            { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, },
            { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, },
            { 10, 10, 10, 10, 0, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, },
            { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, },
            { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, },
            { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, },
            { 10, 10, 10, 10, 0, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, },
            { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, },
            { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, },
            { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, },
            { 10, 10, 10, 10, 0, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, },
            { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, },
            { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, },
            { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, },
            { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, },
            { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, },
            { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, },
            { 10, 10, 10, 10, 0, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, },
            { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, },
            { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, },
            { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, },
            { 10, 10, 10, 10, 0, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, },
            { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, },
            { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, },
            { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, },
            { 10, 10, 10, 10, 0, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, },
            { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, },
            { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, },
            { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, },
            { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, },
            { 10, 10, 10, 10, 0, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, },
            { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, },
            { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, },
            { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, },
            { 10, 10, 10, 10, 0, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, },
            { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, },
            { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, },
            { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, },
            { 10, 10, 10, 10, 0, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, },
            { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, },
            { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, },
        };

But again the int[,] that contains the jagged is still a problem.

 

I will go ahead and post my full code, can  you make the adjustments and then re post along with the sections you changed. This will help me to learn a bit although i know how saves work, this is one type of data i have not worked with in save files before.

 


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Storage;
using Microsoft.Xna.Framework.Media;
using System.IO;
using System.Xml.Serialization;
using System.Diagnostics;
//using System.Runtime.Serialization.Formatters.Binary;

namespace Vertical_Miner_Infinity
{
    [Serializable]
    public struct SaveGame
    {
        // Player Variables
        public int PlayerScore;
        public int PlayerFuel;
        public int PlayerMaxFuel;
        public int PlayerPickTier;
        public int PlayerInvTier;
        public int PlayerFuelTier;
        public int PlayerMaxDepth;
        public int PlayerCoin;
        public int PlayerInv;
        public int PlayerMaxInv;
        public int PlayerDepth;
        public int PlayerPosition;
        // Player Inventory Variables
        public int PlayerInventoryCoalOre;
        public int PlayerInventoryCopperOre;
        public int PlayerInventoryTinOre;
        public int PlayerInventoryIronOre;
        public int PlaceHolder;
        // Player Statistics
        public int TotalMoneyAquired;
        public int TotalUpgradesAquired;
        public int TotalMovesMade;
        public int TotalFuelUsed;
        public int TotalBlocksMined;
        public int TotalDirtBlocksMined;
        public int TotalCoalOre;
        public int TotalCopperOre;
        public int TotalTinOre;
        public int TotalIronOre;
        // Game Map Array
        //public int[,] tileMap0;
    }
    public enum GameState
    {
        // Game Screens
        ControlScreen,
        CreditScreen,
        GameMenuScreen,
        GameScreen,
        MainMenuScreen, 
        SplashScreen,
    }
    public class Game1 : Microsoft.Xna.Framework.Game{
#region Textures & Music
        // Default Windows Code
        GraphicsDeviceManager graphics;
        SpriteBatch spriteBatch;
        // Gamestate Current Window
        GameState gameState;
        // Keyboard State Variables
        KeyboardState oldKeyboardState,
                  currentKeyboardState;
        // Storage Device
        StorageDevice device;
        // Sprite Font
        SpriteFont guitextfont;
        SpriteFont titlefont;
        SpriteFont titlefont2;
        SpriteFont version;
        // Game Textures
        Texture2D splashscreen;
        Texture2D guimenu;
        Texture2D playerminer;
        Texture2D guilantern;
        Texture2D guiinventory;
        Texture2D guistatus;
        Texture2D guigasstatus;
        Texture2D guismelteryscreen;
        Texture2D guiupgradeshopscreen;
        Texture2D guipickaxe;
        Texture2D fuelguagefullbar;
        Texture2D fuelguageemptybar;
        // Texture Tiles List (Blocks)
        List<Texture2D> tileTextures = new List<Texture2D>();
        // Game Music & Sound Effects
        SoundEffectInstance thememusic;
        SoundEffectInstance fuelstationfillup;
        SoundEffectInstance smelterysale;
        SoundEffectInstance upgradesale;
#endregion
#region Global Player Variables
        // [SAVE NEEDED]
        // Player Variables
        int PlayerScore = 0;
        int PlayerFuel = 100;
        int PlayerMaxFuel = 100;
        int PlayerPickTier = 1;
        int PlayerInvTier = 1;
        int PlayerFuelTier = 1;
        int PlayerMaxDepth = 50;
        int PlayerCoin = 5250;
        int PlayerInv = 0;
        int PlayerMaxInv = 10;
        int PlayerDepth = 8;
        int PlayerPosition = 15;
        // Player Inventory Variables
        int PlayerInventoryCoalOre = 0;
        int PlayerInventoryCopperOre = 0;
        int PlayerInventoryTinOre = 0;
        int PlayerInventoryIronOre = 0;
        int PlaceHolder = 0;
        // Player Statistics
        int TotalMoneyAquired = 0;
        int TotalUpgradesAquired = 0;
        int TotalMovesMade = 0;
        int TotalFuelUsed = 0;
        int TotalBlocksMined = 0;
        int TotalDirtBlocksMined = 0;
        int TotalCoalOre = 0;
        int TotalCopperOre = 0;
        int TotalTinOre = 0;
        int TotalIronOre = 0;
        // [NO SAVE NEEDED]
        // GUI Display Variables
        int PlayerDisplayDepth = 8;
        int PlayerDisplayMaxDepth;
        int PlayerFuelCostDisplay;
        int PlayerPickTierCostDisplay;
        int PlayerInvTierCostDisplay;
        int PlayerFuelTierCostDisplay;
        int PlayerInventoryDisplayValue = 0;
        // Camera Position
        int cameraPositionY;
        int cameraPositionX;
        // Tile Size For Tile Engine
        int tileWidth = 64;
        int tileHeight = 64;
        // Movement Controls Bool
        bool GoAgain = true;
        // Dev Information
        string Version = "Version: 0.09";
        string Build = "Build: 21518";
        bool DevMode = true;
        // Save Game
        string containerName = "MyGamesStorage";
        string filename = "mysave.txt";
#endregion
#region Main Game Map Array
        //  0 = Stone          1 = Sky       2 = Cloud       3 = Cloud    4 = Sun 5 = Sun 6 = Fuel Station 7 = Upgrade Shop 8 = Upgrade Shop 9 = Air 10 = Dirt
        //  11 = Smeltery     12 = Coal     12 = Copper     13 = Tin     14 = Iron
        int[,] tileMap = new int[67,30]
        {
            { 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 1, 1, 1, 1, 4, 5, 1, 1, 1, 1, 1, 2, 3, 1, 1, 1, 1, 1, 1, 1, },
            { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, },
            { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, },
            { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, },
            { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, },
            { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, },
            { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, },
            { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, },
            { 1, 1, 1, 1, 1, 1, 1, 1, 1, 11, 1, 1, 1, 1, 1, 6, 1, 1, 1, 1, 1, 7, 8, 1, 1, 1, 1, 1, 1, 1, },
            { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 0, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, },
            { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, },
            { 10, 10, 10, 10, 0, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, },
            { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, },
            { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, },
            { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, },
            { 10, 10, 10, 10, 0, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, },
            { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, },
            { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, },
            { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, },
            { 10, 10, 10, 10, 0, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, },
            { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, },
            { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, },
            { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, },
            { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, },
            { 10, 10, 10, 10, 0, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, },
            { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, },
            { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, },
            { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, },
            { 10, 10, 10, 10, 0, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, },
            { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, },
            { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, },
            { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, },
            { 10, 10, 10, 10, 0, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, },
            { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, },
            { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, },
            { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, },
            { 10, 10, 10, 10, 0, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, },
            { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, },
            { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, },
            { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, },
            { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, },
            { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, },
            { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, },
            { 10, 10, 10, 10, 0, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, },
            { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, },
            { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, },
            { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, },
            { 10, 10, 10, 10, 0, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, },
            { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, },
            { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, },
            { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, },
            { 10, 10, 10, 10, 0, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, },
            { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, },
            { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, },
            { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, },
            { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, },
            { 10, 10, 10, 10, 0, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, },
            { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, },
            { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, },
            { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, },
            { 10, 10, 10, 10, 0, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, },
            { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, },
            { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, },
            { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, },
            { 10, 10, 10, 10, 0, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, },
            { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, },
            { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, },
        };
#endregion
        public Game1()
        {
            // Save Game
            this.Components.Add(new GamerServicesComponent(this));
            // Sets Graphics Display Size
            graphics = new GraphicsDeviceManager(this);
            graphics.IsFullScreen = false;
            graphics.PreferredBackBufferWidth = 1920;
            graphics.PreferredBackBufferHeight = 1080;
            Content.RootDirectory = "Content";
        }
        protected override void Initialize()
        {
            // Read keyboard state
            currentKeyboardState = new KeyboardState();
            // Gamestate window manager
            gameState = new GameState();
            gameState = GameState.SplashScreen;
            // Makes mouse visible
            this.IsMouseVisible = true;
            base.Initialize();
        }
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);
            // Load Music
            thememusic = Content.Load<SoundEffect>("Audio/ThemeMusic").CreateInstance();
            thememusic.Volume = 0.5f;
            thememusic.IsLooped = true;
            fuelstationfillup = Content.Load<SoundEffect>("Audio/FuelStationFillUp").CreateInstance();
            smelterysale = Content.Load<SoundEffect>("Audio/SmelterySale").CreateInstance();
            upgradesale = Content.Load<SoundEffect>("Audio/UpgradeSale").CreateInstance();
            Texture2D texture;
            guitextfont = Content.Load<SpriteFont>("GUITextFont");
            titlefont = Content.Load<SpriteFont>("TitleFont");
            titlefont2 = Content.Load<SpriteFont>("TitleFont2");
            version = Content.Load<SpriteFont>("Version");
            splashscreen = Content.Load<Texture2D>("SplashScreen");
            guimenu = Content.Load<Texture2D>("GUIMenu");
            playerminer = Content.Load<Texture2D>("PlayerMiner");
            guilantern = Content.Load<Texture2D>("GUILantern");
            guiinventory = Content.Load<Texture2D>("GUIInventory");
            guistatus = Content.Load<Texture2D>("GUIStatus");
            guigasstatus = Content.Load<Texture2D>("GUIGasStatus");
            guismelteryscreen = Content.Load<Texture2D>("GUISmelteryScreen");
            guiupgradeshopscreen = Content.Load<Texture2D>("GUIUpgradeShopScreen");
            guipickaxe = Content.Load<Texture2D>("GUIPickAxe");
            fuelguagefullbar = Content.Load<Texture2D>("FuelGaugeFullBar");
            fuelguageemptybar = Content.Load<Texture2D>("FuelGuageEmptyBar");
            // Texture list below. Sequentially Sensitive Order
            texture = Content.Load<Texture2D>("Tiles/TileStone");
            tileTextures.Add(texture);
            texture = Content.Load<Texture2D>("Tiles/TileSky");
            tileTextures.Add(texture);
            texture = Content.Load<Texture2D>("Tiles/TileCloud1");
            tileTextures.Add(texture);
            texture = Content.Load<Texture2D>("Tiles/TileCloud2");
            tileTextures.Add(texture);
            texture = Content.Load<Texture2D>("Tiles/TileSun1");
            tileTextures.Add(texture);
            texture = Content.Load<Texture2D>("Tiles/TileSun2");
            tileTextures.Add(texture);
            texture = Content.Load<Texture2D>("Tiles/TileFuelShop");
            tileTextures.Add(texture);
            texture = Content.Load<Texture2D>("Tiles/TileUpgradeShop1");
            tileTextures.Add(texture);
            texture = Content.Load<Texture2D>("Tiles/TileUpgradeShop2");
            tileTextures.Add(texture);
            texture = Content.Load<Texture2D>("Tiles/TileAir");
            tileTextures.Add(texture);
            texture = Content.Load<Texture2D>("Tiles/TileDirt");
            tileTextures.Add(texture);
            texture = Content.Load<Texture2D>("Tiles/TileSmeltery");
            tileTextures.Add(texture);
            texture = Content.Load<Texture2D>("Tiles/TileCoal");
            tileTextures.Add(texture);
        }
        protected override void UnloadContent()
        {
            // TODO: Unload any non ContentManager content here
        }
        protected override void Update(GameTime gameTime)
        {
            // Allows the game to exit
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
                this.Exit();
            if (gameState == GameState.ControlScreen)
            {
            }
            if (gameState == GameState.CreditScreen)
            {
            }
            if (gameState == GameState.GameMenuScreen)
            {
                // Get Keyboard State
                oldKeyboardState = currentKeyboardState;
                currentKeyboardState = Keyboard.GetState();
                if ((currentKeyboardState.IsKeyUp(Keys.D1)) && (oldKeyboardState.IsKeyDown(Keys.D1)))
                {
                    InitiateSave();
                }
                if ((currentKeyboardState.IsKeyUp(Keys.D2)) && (oldKeyboardState.IsKeyDown(Keys.D2)))
                {
                    InitiateLoad();
                }
                if ((currentKeyboardState.IsKeyUp(Keys.D3)) && (oldKeyboardState.IsKeyDown(Keys.D3)))
                {
                    gameState = GameState.ControlScreen;
                }
                if ((currentKeyboardState.IsKeyUp(Keys.Space)) && (oldKeyboardState.IsKeyDown(Keys.Space)))
                {
                    this.Exit();
                }
                if ((currentKeyboardState.IsKeyUp(Keys.Escape)) && (oldKeyboardState.IsKeyDown(Keys.Escape)))
                {
                    gameState = GameState.GameScreen;
                }
            }
            if (gameState == GameState.GameScreen)
            {
                // Get Keyboard State
                oldKeyboardState = currentKeyboardState;
                currentKeyboardState = Keyboard.GetState();
                // Controls
                if ((currentKeyboardState.IsKeyUp(Keys.W)) && (oldKeyboardState.IsKeyDown(Keys.W)) && (PlayerDepth >= 9))
                {
                    GoAgain = true;
                    DoMoveUp();
                }
                if ((currentKeyboardState.IsKeyUp(Keys.S)) && (oldKeyboardState.IsKeyDown(Keys.S)) && (PlayerDepth < PlayerMaxDepth))
                {
                    GoAgain = true;
                    DoMoveDown();
                }
                if ((currentKeyboardState.IsKeyUp(Keys.A)) && (oldKeyboardState.IsKeyDown(Keys.A)) && (PlayerPosition > 0))
                {
                    GoAgain = true;
                    DoMoveLeft();
                }
                if ((currentKeyboardState.IsKeyUp(Keys.D)) && (oldKeyboardState.IsKeyDown(Keys.D)) && (PlayerPosition < 29))
                {
                    GoAgain = true;
                    DoMoveRight();
                }
                if ((currentKeyboardState.IsKeyUp(Keys.Space)) && (oldKeyboardState.IsKeyDown(Keys.Space)) && (PlayerPosition == 15) && (PlayerDepth == 8))
                {
                    DoFuelUp();
                }
                if ((currentKeyboardState.IsKeyUp(Keys.Space)) && (oldKeyboardState.IsKeyDown(Keys.Space)) && (PlayerPosition == 9) && (PlayerDepth == 8))
                {
                    DoSellOres();
                }
                if ((currentKeyboardState.IsKeyUp(Keys.D1)) && (oldKeyboardState.IsKeyDown(Keys.D1)) && (PlayerPosition == 21) && (PlayerDepth == 8))
                {
                    DoUpgradePick();
                }
                if ((currentKeyboardState.IsKeyUp(Keys.D1)) && (oldKeyboardState.IsKeyDown(Keys.D1)) && (PlayerPosition == 22) && (PlayerDepth == 8))
                {
                    DoUpgradePick();
                }
                if ((currentKeyboardState.IsKeyUp(Keys.D2)) && (oldKeyboardState.IsKeyDown(Keys.D2)) && (PlayerPosition == 21) && (PlayerDepth == 8))
                {
                    DoUpgradeInv();
                }
                if ((currentKeyboardState.IsKeyUp(Keys.D2)) && (oldKeyboardState.IsKeyDown(Keys.D2)) && (PlayerPosition == 22) && (PlayerDepth == 8))
                {
                    DoUpgradeInv();
                }
                if ((currentKeyboardState.IsKeyUp(Keys.D3)) && (oldKeyboardState.IsKeyDown(Keys.D3)) && (PlayerPosition == 21) && (PlayerDepth == 8))
                {
                    DoUpgradeFuel();
                }
                if ((currentKeyboardState.IsKeyUp(Keys.D3)) && (oldKeyboardState.IsKeyDown(Keys.D3)) && (PlayerPosition == 22) && (PlayerDepth == 8))
                {
                    DoUpgradeFuel();
                }
                if ((currentKeyboardState.IsKeyUp(Keys.Escape)) && (oldKeyboardState.IsKeyDown(Keys.Escape)))
                {
                    gameState = GameState.GameMenuScreen;
                }
                if (cameraPositionX < 0)
                    cameraPositionX = 0;
                if (cameraPositionY < 0)
                    cameraPositionY = 0;

                int screenWidth = GraphicsDevice.Viewport.Width;
                int screenHeight = GraphicsDevice.Viewport.Height;

                int tileMapWidth = tileMap.GetLength(1) * tileWidth;
                int tileMapHeight = tileMap.GetLength(0) * tileHeight;

                if (cameraPositionX > tileMapWidth - screenWidth)
                    cameraPositionX = tileMapWidth - screenWidth;
                if (cameraPositionY > tileMapHeight - screenHeight)
                    cameraPositionY = tileMapHeight - screenHeight;
                // Ore Calculations
                // Coal Ore = $25
                // Copper Ore = $50
                // Tin Ore = $100
                // Iron Ore = $150
                int coalvalue = 0;
                int coppervalue = 0;
                int tinvalue = 0;
                int ironvalue = 0;
                coalvalue = PlayerInventoryCoalOre * 25;
                coppervalue = PlayerInventoryCopperOre * 50;
                tinvalue = PlayerInventoryTinOre * 100;
                ironvalue = PlayerInventoryIronOre * 150;
                PlayerInventoryDisplayValue = coalvalue + coppervalue + tinvalue + ironvalue;
                // Upgrade Tiers Cost Display Calculations
                PlayerPickTierCostDisplay = PlayerPickTier * 1500;
                PlayerInvTierCostDisplay = PlayerInvTier * 1500;
                PlayerFuelTierCostDisplay = PlayerFuelTier * 1500;
                ////////////////////////////
                ////   DEV FUEL OVERRIDE
                ////////////////////////////
                if ((PlayerFuel == 0) && (DevMode))
                {
                    PlayerFuel = PlayerMaxFuel;
                }
                // Out Of Fuel
                if (PlayerFuel == 0)
                {
                    // Reset Player
                    PlayerFuel = 10;
                    PlayerPosition = 15;
                    PlayerDepth = 8;
                    cameraPositionX = 0;
                    cameraPositionY = 0;
                    // Reset Inventory
                    PlayerInventoryCoalOre = 0;
                    PlayerInventoryCopperOre = 0;
                    PlayerInventoryTinOre = 0;
                    PlayerInventoryIronOre = 0;
                    PlayerInv = 0;
                }
                // Offsets 8 Tiles Of Sky
                PlayerDisplayDepth = PlayerDepth - 8;
                PlayerDisplayMaxDepth = PlayerMaxDepth - 8;

                // Fuel Cost Display
                PlayerFuelCostDisplay = PlayerMaxFuel - PlayerFuel;

                // Play Music
                thememusic.Volume = 0.5f;
                thememusic.Play();
            }
            if (gameState == GameState.MainMenuScreen)
            {
                // Get Keyboard State
                oldKeyboardState = currentKeyboardState;
                currentKeyboardState = Keyboard.GetState();
                if ((currentKeyboardState.IsKeyUp(Keys.D1)) && (oldKeyboardState.IsKeyDown(Keys.D1)))
                {
                    // Starts New Game
                    gameState = GameState.GameScreen;
                }
                if ((currentKeyboardState.IsKeyUp(Keys.D2)) && (oldKeyboardState.IsKeyDown(Keys.D2)))
                {
                    // Loads Saved Game
                    InitiateLoad();
                }
                if ((currentKeyboardState.IsKeyUp(Keys.D3)) && (oldKeyboardState.IsKeyDown(Keys.D3)))
                {
                    // Controls Help Screen
                    gameState = GameState.ControlScreen;
                }
                if ((currentKeyboardState.IsKeyUp(Keys.D4)) && (oldKeyboardState.IsKeyDown(Keys.D4)))
                {
                    // Credits Screen
                    gameState = GameState.CreditScreen;
                }
                if ((currentKeyboardState.IsKeyUp(Keys.Escape)) && (oldKeyboardState.IsKeyDown(Keys.Escape)))
                {
                    // Exits Game
                    this.Exit();
                }
            }
            if (gameState == GameState.SplashScreen)
            {
                // Get Keyboard State
                oldKeyboardState = currentKeyboardState;
                currentKeyboardState = Keyboard.GetState();
                if ((currentKeyboardState.IsKeyUp(Keys.Enter)) && (oldKeyboardState.IsKeyDown(Keys.Enter)))
                {
                    gameState = GameState.MainMenuScreen;
                }
            }
            base.Update(gameTime);
        }
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);

            if (gameState == GameState.ControlScreen)
            {
                GraphicsDevice.Clear(Color.Blue);
            }
            if (gameState == GameState.CreditScreen)
            {
                GraphicsDevice.Clear(Color.Red);
            }
            if (gameState == GameState.GameMenuScreen)
            {
                GraphicsDevice.Clear(Color.Black);
                spriteBatch.Begin();
                spriteBatch.DrawString(titlefont, "VERTICAL MINER INFINITY", new Vector2(800, 64), Color.Blue);
                spriteBatch.DrawString(version, Version.ToString(), new Vector2(900, 95), Color.White);
                spriteBatch.DrawString(version, Build.ToString(), new Vector2(900, 110), Color.White);
                spriteBatch.Draw(guimenu, new Vector2(736, 128), Color.White);
                spriteBatch.DrawString(titlefont2, "'1'      Save Game", new Vector2(875, 192), Color.White);
                spriteBatch.DrawString(titlefont2, "'2'      Load Game", new Vector2(875, 320), Color.White);
                spriteBatch.DrawString(titlefont2, "'3'      Controls", new Vector2(875, 448), Color.White);
                spriteBatch.DrawString(titlefont2, "'Space'  Exit Game", new Vector2(875, 570), Color.White);
                spriteBatch.DrawString(titlefont2, "'Esc' Return To Game", new Vector2(875, 698), Color.White);
                spriteBatch.End();
            }
            if (gameState == GameState.GameScreen)
            {
                spriteBatch.Begin();
                int tileMapWidth = tileMap.GetLength(1);
                int tileMapHeight = tileMap.GetLength(0);

                for (int x = 0; x < tileMapWidth; x++)
                {
                    for (int y = 0; y < tileMapHeight; y++)
                    {
                        int textureIndex = tileMap[y, x];
                        Texture2D texture = tileTextures[textureIndex];

                        spriteBatch.Draw(
                            texture,
                            new Rectangle(
                                x * tileWidth - cameraPositionX,
                                y * tileHeight - cameraPositionY,
                                tileWidth,
                                tileHeight),
                            Color.White);
                    }
                }
                spriteBatch.End();
                spriteBatch.Begin();
                spriteBatch.Draw(guistatus, new Vector2(8, 384), Color.White);
                spriteBatch.DrawString(guitextfont, "SCORE: " + PlayerScore.ToString(), new Vector2(18, 390), Color.White);
                spriteBatch.DrawString(guitextfont, "COIN : $" + PlayerCoin.ToString(), new Vector2(18, 415), Color.White);
                spriteBatch.End();
                spriteBatch.Begin();
                // Fuel Guage
                spriteBatch.Draw(fuelguagefullbar, new Vector2(24, 70), Color.White);
                spriteBatch.DrawString(guitextfont, "Fuel", new Vector2(18, 8), Color.White);
                spriteBatch.DrawString(guitextfont, PlayerFuel.ToString(), new Vector2(21, 30), Color.White);
                spriteBatch.DrawString(guitextfont, "Max", new Vector2(20, 344), Color.White);
                spriteBatch.DrawString(guitextfont, PlayerMaxFuel.ToString(), new Vector2(21, 324), Color.White);
                // Inventory Guage
                spriteBatch.Draw(fuelguagefullbar, new Vector2(124, 70), Color.White);
                spriteBatch.DrawString(guitextfont, "Inv", new Vector2(122, 8), Color.White);
                spriteBatch.DrawString(guitextfont, PlayerInv.ToString(), new Vector2(130, 30), Color.White);
                spriteBatch.DrawString(guitextfont, "Max", new Vector2(122, 344), Color.White);
                spriteBatch.DrawString(guitextfont, PlayerMaxInv.ToString(), new Vector2(126, 324), Color.White);
                // Player Depth Guage
                spriteBatch.Draw(fuelguagefullbar, new Vector2(224, 70), Color.White);
                spriteBatch.DrawString(guitextfont, "Depth", new Vector2(222, 8), Color.White);
                spriteBatch.DrawString(guitextfont, PlayerDisplayDepth.ToString(), new Vector2(230, 30), Color.White);
                spriteBatch.DrawString(guitextfont, "Max", new Vector2(222, 344), Color.White);
                spriteBatch.DrawString(guitextfont, PlayerDisplayMaxDepth.ToString(), new Vector2(226, 324), Color.White);
                spriteBatch.End();
                if (PlayerFuel == (100 * PlayerFuelTier))
                {
                    // Draw Nothing Fuel Is Full
                }
                if (PlayerFuel < (90 * PlayerFuelTier))
                {
                    spriteBatch.Begin();
                    spriteBatch.Draw(fuelguageemptybar, new Vector2(24, 70), Color.White);
                    spriteBatch.End();
                }
                if (PlayerFuel < (80 * PlayerFuelTier))
                {
                    spriteBatch.Begin();
                    spriteBatch.Draw(fuelguageemptybar, new Vector2(24, 94), Color.White);
                    spriteBatch.End();
                }
                if (PlayerFuel < (70 * PlayerFuelTier))
                {
                    spriteBatch.Begin();
                    spriteBatch.Draw(fuelguageemptybar, new Vector2(24, 118), Color.White);
                    spriteBatch.End();
                }
                if (PlayerFuel < (60 * PlayerFuelTier))
                {
                    spriteBatch.Begin();
                    spriteBatch.Draw(fuelguageemptybar, new Vector2(24, 142), Color.White);
                    spriteBatch.End();
                }
                if (PlayerFuel < (50 * PlayerFuelTier))
                {
                    spriteBatch.Begin();
                    spriteBatch.Draw(fuelguageemptybar, new Vector2(24, 166), Color.White);
                    spriteBatch.End();
                }
                if (PlayerFuel < (40 * PlayerFuelTier))
                {
                    spriteBatch.Begin();
                    spriteBatch.Draw(fuelguageemptybar, new Vector2(24, 190), Color.White);
                    spriteBatch.End();
                }
                if (PlayerFuel < (30 * PlayerFuelTier))
                {
                    spriteBatch.Begin();
                    spriteBatch.Draw(fuelguageemptybar, new Vector2(24, 214), Color.White);
                    spriteBatch.End();
                }
                if (PlayerFuel < (20 * PlayerFuelTier))
                {
                    spriteBatch.Begin();
                    spriteBatch.Draw(fuelguageemptybar, new Vector2(24, 238), Color.White);
                    spriteBatch.End();
                }
                if (PlayerFuel < (10 * PlayerFuelTier))
                {
                    spriteBatch.Begin();
                    spriteBatch.Draw(fuelguageemptybar, new Vector2(24, 262), Color.White);
                    spriteBatch.End();
                }
                // Player Inventory Gauge
                if (PlayerInv < (10 * PlayerInvTier))
                {
                    spriteBatch.Begin();
                    spriteBatch.Draw(fuelguageemptybar, new Vector2(124, 286), Color.White);
                    spriteBatch.End();
                }
                if (PlayerInv < (9 * PlayerInvTier))
                {
                    spriteBatch.Begin();
                    spriteBatch.Draw(fuelguageemptybar, new Vector2(124, 262), Color.White);
                    spriteBatch.End();
                }
                if (PlayerInv < (8 * PlayerInvTier))
                {
                    spriteBatch.Begin();
                    spriteBatch.Draw(fuelguageemptybar, new Vector2(124, 238), Color.White);
                    spriteBatch.End();
                }
                if (PlayerInv < (7 * PlayerInvTier))
                {
                    spriteBatch.Begin();
                    spriteBatch.Draw(fuelguageemptybar, new Vector2(124, 214), Color.White);
                    spriteBatch.End();
                }
                if (PlayerInv < (6 * PlayerInvTier))
                {
                    spriteBatch.Begin();
                    spriteBatch.Draw(fuelguageemptybar, new Vector2(124, 190), Color.White);
                    spriteBatch.End();
                }
                if (PlayerInv < (5 * PlayerInvTier))
                {
                    spriteBatch.Begin();
                    spriteBatch.Draw(fuelguageemptybar, new Vector2(124, 166), Color.White);
                    spriteBatch.End();
                }
                if (PlayerInv < (4 * PlayerInvTier))
                {
                    spriteBatch.Begin();
                    spriteBatch.Draw(fuelguageemptybar, new Vector2(124, 142), Color.White);
                    spriteBatch.End();
                }
                if (PlayerInv < (3 * PlayerInvTier))
                {
                    spriteBatch.Begin();
                    spriteBatch.Draw(fuelguageemptybar, new Vector2(124, 118), Color.White);
                    spriteBatch.End();
                }
                if (PlayerInv < (2 * PlayerInvTier))
                {
                    spriteBatch.Begin();
                    spriteBatch.Draw(fuelguageemptybar, new Vector2(124, 94), Color.White);
                    spriteBatch.End();
                }
                if (PlayerInv < (1 * PlayerInvTier))
                {
                    spriteBatch.Begin();
                    spriteBatch.Draw(fuelguageemptybar, new Vector2(124, 70), Color.White);
                    spriteBatch.End();
                }
                // Player Depth Gauge
                if (PlayerDisplayDepth < (50 * PlayerPickTier - 8))
                {
                    spriteBatch.Begin();
                    spriteBatch.Draw(fuelguageemptybar, new Vector2(224, 286), Color.White);
                    spriteBatch.End();
                }
                if (PlayerDisplayDepth < (45 * PlayerPickTier - 7))
                {
                    spriteBatch.Begin();
                    spriteBatch.Draw(fuelguageemptybar, new Vector2(224, 262), Color.White);
                    spriteBatch.End();
                }
                if (PlayerDisplayDepth < (33 * PlayerPickTier))
                {
                    spriteBatch.Begin();
                    spriteBatch.Draw(fuelguageemptybar, new Vector2(224, 238), Color.White);
                    spriteBatch.End();
                }
                if (PlayerDisplayDepth < (28 * PlayerPickTier))
                {
                    spriteBatch.Begin();
                    spriteBatch.Draw(fuelguageemptybar, new Vector2(224, 214), Color.White);
                    spriteBatch.End();
                }
                if (PlayerDisplayDepth < (24 * PlayerPickTier))
                {
                    spriteBatch.Begin();
                    spriteBatch.Draw(fuelguageemptybar, new Vector2(224, 190), Color.White);
                    spriteBatch.End();
                }
                if (PlayerDisplayDepth < (20 * PlayerPickTier))
                {
                    spriteBatch.Begin();
                    spriteBatch.Draw(fuelguageemptybar, new Vector2(224, 166), Color.White);
                    spriteBatch.End();
                }
                if (PlayerDisplayDepth < (16 * PlayerPickTier))
                {
                    spriteBatch.Begin();
                    spriteBatch.Draw(fuelguageemptybar, new Vector2(224, 142), Color.White);
                    spriteBatch.End();
                }
                if (PlayerDisplayDepth < (12 * PlayerPickTier))
                {
                    spriteBatch.Begin();
                    spriteBatch.Draw(fuelguageemptybar, new Vector2(224, 118), Color.White);
                    spriteBatch.End();
                }
                if (PlayerDisplayDepth < (8 * PlayerPickTier))
                {
                    spriteBatch.Begin();
                    spriteBatch.Draw(fuelguageemptybar, new Vector2(224, 94), Color.White);
                    spriteBatch.End();
                }
                if (PlayerDisplayDepth < (4 * PlayerPickTier))
                {
                    spriteBatch.Begin();
                    spriteBatch.Draw(fuelguageemptybar, new Vector2(224, 70), Color.White);
                    spriteBatch.End();
                }

                if ((PlayerPosition == 9) && (PlayerDepth == 8))
                {
                    spriteBatch.Begin();
                    // Smeltery Screen
                    spriteBatch.Draw(guismelteryscreen, new Vector2(320, 64), Color.White);
                    spriteBatch.DrawString(guitextfont, "Coal  Ore  : " + PlayerInventoryCoalOre.ToString(), new Vector2(328, 72), Color.White);
                    spriteBatch.DrawString(guitextfont, "Copper Ore : " + PlayerInventoryCopperOre.ToString(), new Vector2(328, 92), Color.White);
                    spriteBatch.DrawString(guitextfont, "Iron Ore   : " + PlayerInventoryIronOre.ToString(), new Vector2(328, 112), Color.White);
                    spriteBatch.DrawString(guitextfont, "Tin Ore    : " + PlayerInventoryTinOre.ToString(), new Vector2(328, 132), Color.White);
                    spriteBatch.DrawString(guitextfont, "Placeholder: " + PlaceHolder.ToString(), new Vector2(328, 152), Color.White);
                    spriteBatch.DrawString(guitextfont, "Placeholder: " + PlaceHolder.ToString(), new Vector2(328, 172), Color.White);
                    spriteBatch.DrawString(guitextfont, "Placeholder: " + PlaceHolder.ToString(), new Vector2(328, 192), Color.White);
                    spriteBatch.DrawString(guitextfont, "Placeholder: " + PlaceHolder.ToString(), new Vector2(328, 212), Color.White);
                    spriteBatch.DrawString(guitextfont, "Placeholder: " + PlaceHolder.ToString(), new Vector2(328, 232), Color.White);
                    spriteBatch.DrawString(guitextfont, "Placeholder: " + PlaceHolder.ToString(), new Vector2(328, 252), Color.White);
                    spriteBatch.DrawString(guitextfont, "Placeholder: " + PlaceHolder.ToString(), new Vector2(328, 272), Color.White);
                    spriteBatch.DrawString(guitextfont, "Placeholder: " + PlaceHolder.ToString(), new Vector2(328, 292), Color.White);
                    spriteBatch.DrawString(guitextfont, "Placeholder: " + PlaceHolder.ToString(), new Vector2(328, 312), Color.White);
                    spriteBatch.DrawString(guitextfont, "Placeholder: " + PlaceHolder.ToString(), new Vector2(328, 332), Color.White);
                    spriteBatch.DrawString(guitextfont, "Placeholder: " + PlaceHolder.ToString(), new Vector2(328, 352), Color.White);
                    // Column 2
                    spriteBatch.DrawString(guitextfont, "Placeholder: " + PlaceHolder.ToString(), new Vector2(616, 72), Color.White);
                    spriteBatch.DrawString(guitextfont, "Placeholder: " + PlaceHolder.ToString(), new Vector2(616, 92), Color.White);
                    spriteBatch.DrawString(guitextfont, "Placeholder: " + PlaceHolder.ToString(), new Vector2(616, 112), Color.White);
                    spriteBatch.DrawString(guitextfont, "Placeholder: " + PlaceHolder.ToString(), new Vector2(616, 132), Color.White);
                    spriteBatch.DrawString(guitextfont, "Placeholder: " + PlaceHolder.ToString(), new Vector2(616, 152), Color.White);
                    spriteBatch.DrawString(guitextfont, "Placeholder: " + PlaceHolder.ToString(), new Vector2(616, 172), Color.White);
                    spriteBatch.DrawString(guitextfont, "Placeholder: " + PlaceHolder.ToString(), new Vector2(616, 192), Color.White);
                    spriteBatch.DrawString(guitextfont, "Placeholder: " + PlaceHolder.ToString(), new Vector2(616, 212), Color.White);
                    spriteBatch.DrawString(guitextfont, "Placeholder: " + PlaceHolder.ToString(), new Vector2(616, 232), Color.White);
                    spriteBatch.DrawString(guitextfont, "Placeholder: " + PlaceHolder.ToString(), new Vector2(616, 252), Color.White);
                    spriteBatch.DrawString(guitextfont, "Placeholder: " + PlaceHolder.ToString(), new Vector2(616, 272), Color.White);
                    spriteBatch.DrawString(guitextfont, "Placeholder: " + PlaceHolder.ToString(), new Vector2(616, 292), Color.White);
                    spriteBatch.DrawString(guitextfont, "Placeholder: " + PlaceHolder.ToString(), new Vector2(616, 312), Color.White);
                    spriteBatch.DrawString(guitextfont, "Placeholder: " + PlaceHolder.ToString(), new Vector2(616, 332), Color.White);
                    spriteBatch.DrawString(guitextfont, "Placeholder: " + PlaceHolder.ToString(), new Vector2(616, 352), Color.White);
                    spriteBatch.DrawString(guitextfont, "VALUE OF ORES: $" + PlayerInventoryDisplayValue.ToString(), new Vector2(516, 392), Color.White);
                    spriteBatch.DrawString(guitextfont, "Press 'Space Key' To Sell Ores", new Vector2(436, 417), Color.White);
                    spriteBatch.End();
                }
                if ((PlayerPosition == 15) && (PlayerDepth == 8))
                {
                    spriteBatch.Begin();
                    // Fuel Shop Screen
                    spriteBatch.Draw(guigasstatus, new Vector2(832, 384), Color.White);
                    spriteBatch.DrawString(guitextfont, "Fuel Cost: $" + PlayerFuelCostDisplay.ToString(), new Vector2(860, 390), Color.White);
                    spriteBatch.DrawString(guitextfont, "Press 'Space Key' To Buy", new Vector2(860, 420), Color.White);
                    spriteBatch.End();
                }
                if ((PlayerPosition == 21) && (PlayerDepth == 8))
                {
                    spriteBatch.Begin();
                    // Upgrade Shop Screen
                    spriteBatch.Draw(guiupgradeshopscreen, new Vector2(1088, 64), Color.White);
                    spriteBatch.Draw(guipickaxe, new Vector2(1215, 72), Color.White);
                    spriteBatch.DrawString(guitextfont, "Pick Tier", new Vector2(1195, 136), Color.White);
                    spriteBatch.DrawString(guitextfont, PlayerPickTier.ToString(), new Vector2(1242, 161), Color.White);
                    spriteBatch.DrawString(guitextfont, "Max Depth", new Vector2(1195, 201), Color.White);
                    spriteBatch.DrawString(guitextfont, "+50", new Vector2(1225, 221), Color.White);
                    spriteBatch.DrawString(guitextfont, "Upgrade?", new Vector2(1205, 290), Color.White);
                    spriteBatch.DrawString(guitextfont, "$" + PlayerPickTierCostDisplay.ToString(), new Vector2(1220, 330), Color.White);
                    spriteBatch.DrawString(guitextfont, "Press '1 Key'", new Vector2(1175, 386), Color.White);
                    spriteBatch.DrawString(guitextfont, "To Purchase", new Vector2(1185, 406), Color.White);
                    spriteBatch.Draw(guiinventory, new Vector2(1370, 72), Color.White);
                    spriteBatch.DrawString(guitextfont, "Inv Tier", new Vector2(1358, 136), Color.White);
                    spriteBatch.DrawString(guitextfont, PlayerInvTier.ToString(), new Vector2(1396, 161), Color.White);
                    spriteBatch.DrawString(guitextfont, "Max Inv", new Vector2(1363, 201), Color.White);
                    spriteBatch.DrawString(guitextfont, "+10", new Vector2(1378, 221), Color.White);
                    spriteBatch.DrawString(guitextfont, "Upgrade?", new Vector2(1358, 290), Color.White);
                    spriteBatch.DrawString(guitextfont, "$" + PlayerInvTierCostDisplay.ToString(), new Vector2(1368, 330), Color.White);
                    spriteBatch.DrawString(guitextfont, "Press '2 Key'", new Vector2(1338, 386), Color.White);
                    spriteBatch.DrawString(guitextfont, "To Purchase", new Vector2(1348, 406), Color.White);
                    spriteBatch.Draw(guilantern, new Vector2(1536, 72), Color.White);
                    spriteBatch.DrawString(guitextfont, "Fuel Tier", new Vector2(1519, 136), Color.White);
                    spriteBatch.DrawString(guitextfont, PlayerFuelTier.ToString(), new Vector2(1566, 161), Color.White);
                    spriteBatch.DrawString(guitextfont, "Max Fuel", new Vector2(1526, 201), Color.White);
                    spriteBatch.DrawString(guitextfont, "+100", new Vector2(1543, 221), Color.White);
                    spriteBatch.DrawString(guitextfont, "Upgrade?", new Vector2(1523, 290), Color.White);
                    spriteBatch.DrawString(guitextfont, "$" + PlayerFuelTierCostDisplay.ToString(), new Vector2(1533, 330), Color.White);
                    spriteBatch.DrawString(guitextfont, "Press '3 Key'", new Vector2(1503, 386), Color.White);
                    spriteBatch.DrawString(guitextfont, "To Purchase", new Vector2(1513, 406), Color.White);
                    spriteBatch.End();
                }
                if ((PlayerPosition == 22) && (PlayerDepth == 8))
                {
                    spriteBatch.Begin();
                    // Upgrade Shop Screen
                    spriteBatch.Draw(guiupgradeshopscreen, new Vector2(1088, 64), Color.White);
                    spriteBatch.Draw(guipickaxe, new Vector2(1215, 72), Color.White);
                    spriteBatch.DrawString(guitextfont, "Pick Tier", new Vector2(1195, 136), Color.White);
                    spriteBatch.DrawString(guitextfont, PlayerPickTier.ToString(), new Vector2(1242, 161), Color.White);
                    spriteBatch.DrawString(guitextfont, "Max Depth", new Vector2(1195, 201), Color.White);
                    spriteBatch.DrawString(guitextfont, "+50", new Vector2(1225, 221), Color.White);
                    spriteBatch.DrawString(guitextfont, "Upgrade?", new Vector2(1205, 290), Color.White);
                    spriteBatch.DrawString(guitextfont, "$" + PlayerPickTierCostDisplay.ToString(), new Vector2(1220, 330), Color.White);
                    spriteBatch.DrawString(guitextfont, "Press '1 Key'", new Vector2(1175, 386), Color.White);
                    spriteBatch.DrawString(guitextfont, "To Purchase", new Vector2(1185, 406), Color.White);
                    spriteBatch.Draw(guiinventory, new Vector2(1370, 72), Color.White);
                    spriteBatch.DrawString(guitextfont, "Inv Tier", new Vector2(1358, 136), Color.White);
                    spriteBatch.DrawString(guitextfont, PlayerInvTier.ToString(), new Vector2(1396, 161), Color.White);
                    spriteBatch.DrawString(guitextfont, "Max Inv", new Vector2(1363, 201), Color.White);
                    spriteBatch.DrawString(guitextfont, "+10", new Vector2(1378, 221), Color.White);
                    spriteBatch.DrawString(guitextfont, "Upgrade?", new Vector2(1358, 290), Color.White);
                    spriteBatch.DrawString(guitextfont, "$" + PlayerInvTierCostDisplay.ToString(), new Vector2(1368, 330), Color.White);
                    spriteBatch.DrawString(guitextfont, "Press '2 Key'", new Vector2(1338, 386), Color.White);
                    spriteBatch.DrawString(guitextfont, "To Purchase", new Vector2(1348, 406), Color.White);
                    spriteBatch.Draw(guilantern, new Vector2(1536, 72), Color.White);
                    spriteBatch.DrawString(guitextfont, "Fuel Tier", new Vector2(1519, 136), Color.White);
                    spriteBatch.DrawString(guitextfont, PlayerFuelTier.ToString(), new Vector2(1566, 161), Color.White);
                    spriteBatch.DrawString(guitextfont, "Max Fuel", new Vector2(1526, 201), Color.White);
                    spriteBatch.DrawString(guitextfont, "+100", new Vector2(1543, 221), Color.White);
                    spriteBatch.DrawString(guitextfont, "Upgrade?", new Vector2(1523, 290), Color.White);
                    spriteBatch.DrawString(guitextfont, "$" + PlayerFuelTierCostDisplay.ToString(), new Vector2(1533, 330), Color.White);
                    spriteBatch.DrawString(guitextfont, "Press '3 Key'", new Vector2(1503, 386), Color.White);
                    spriteBatch.DrawString(guitextfont, "To Purchase", new Vector2(1513, 406), Color.White);
                    spriteBatch.End();
                }
                // Dev Mode
                spriteBatch.Begin();
                spriteBatch.DrawString(guitextfont, "[Dev Mode]", new Vector2(8, 460), Color.Red);
                spriteBatch.DrawString(guitextfont, DevMode.ToString(), new Vector2(130, 460), Color.Black);
                spriteBatch.End();
                // Draw Player Sprite
                spriteBatch.Begin();
                spriteBatch.Draw(playerminer, new Vector2(PlayerPosition * 64, 512), Color.White);
                spriteBatch.End();
            }
            if (gameState == GameState.MainMenuScreen)
            {
                GraphicsDevice.Clear(Color.Black);
                spriteBatch.Begin();
                spriteBatch.DrawString(titlefont, "VERTICAL MINER INFINITY", new Vector2(800, 64), Color.Blue);
                spriteBatch.DrawString(version, Version.ToString(), new Vector2(900, 95), Color.White);
                spriteBatch.DrawString(version, Build.ToString(), new Vector2(900, 110), Color.White);
                spriteBatch.Draw(guimenu, new Vector2(736, 128), Color.White);
                spriteBatch.DrawString(titlefont2, "'1'  New Game", new Vector2(880, 192), Color.White);
                spriteBatch.DrawString(titlefont2, "'2'  Load Game", new Vector2(875, 320), Color.White);
                spriteBatch.DrawString(titlefont2, "'3'  Controls", new Vector2(875, 448), Color.White);
                spriteBatch.DrawString(titlefont2, "'4'  Credits", new Vector2(875, 570), Color.White);
                spriteBatch.DrawString(titlefont2, "'Esc'  Exit Game", new Vector2(875, 698), Color.White);
                spriteBatch.End();
            }
            if (gameState == GameState.SplashScreen)
            {
                spriteBatch.Begin();
                spriteBatch.Draw(splashscreen, new Vector2(0, 0), Color.White);
                spriteBatch.End();
            }
            base.Draw(gameTime);
        }
        public void DoMoveUp()
        {
            int CheckSpot = PlayerDepth - 1;
            if ((tileMap[CheckSpot, PlayerPosition] == 0) && (GoAgain))
            {
                // Can't Move Here Its Stone
                GoAgain = false;
            }
            else if ((tileMap[CheckSpot, PlayerPosition] == 1) && (GoAgain))
            {
                // Sky so moving is fine.
                cameraPositionY = cameraPositionY - 64;
                PlayerDepth--;
                GoAgain = false;
                TotalMovesMade++;
            }
            else if ((tileMap[CheckSpot, PlayerPosition] == 6) && (GoAgain))
            {
                // Building so moving is fine.
                cameraPositionY = cameraPositionY - 64;
                PlayerDepth--;
                GoAgain = false;
                TotalMovesMade++;
            }
            else if ((tileMap[CheckSpot, PlayerPosition] == 7) && (GoAgain))
            {
                // Building so moving is fine.
                cameraPositionY = cameraPositionY - 64;
                PlayerDepth--;
                GoAgain = false;
                TotalMovesMade++;
            }
            else if ((tileMap[CheckSpot, PlayerPosition] == 8) && (GoAgain))
            {
                // Building so moving is fine.
                cameraPositionY = cameraPositionY - 64;
                PlayerDepth--;
                GoAgain = false;
                TotalMovesMade++;
            }

            else if ((tileMap[CheckSpot, PlayerPosition] == 9) && (GoAgain) && (PlayerFuel > 0))
            {
                // Its just air so moving is fine.
                cameraPositionY = cameraPositionY - 64;
                PlayerDepth--;
                PlayerFuel--;
                GoAgain = false;
                TotalMovesMade++;
                TotalFuelUsed++;
            }
            else if ((tileMap[CheckSpot, PlayerPosition] == 10) && (GoAgain) && (PlayerFuel > 0))
            {
                // Its just air so moving is fine.
                cameraPositionY = cameraPositionY - 64;
                tileMap[CheckSpot, PlayerPosition] = 9;
                PlayerDepth--;
                PlayerFuel--;
                GoAgain = false;
                TotalMovesMade++;
                TotalFuelUsed++;
                TotalBlocksMined++;
                TotalDirtBlocksMined++;
            }
            else if ((tileMap[CheckSpot, PlayerPosition] == 11) && (GoAgain))
            {
                // Building so moving is fine.
                cameraPositionY = cameraPositionY - 64;
                PlayerDepth--;
                GoAgain = false;
                TotalMovesMade++;
            }
            else
            {
            }
        }
        public void DoMoveDown()
        {
            int CheckSpot = PlayerDepth + 1;
            if ((tileMap[CheckSpot, PlayerPosition] == 0) && (GoAgain))
            {
                // Cant Move Here Its Stone
                GoAgain = false;
            }
            else if ((tileMap[CheckSpot, PlayerPosition] == 9) && (GoAgain) && (PlayerFuel > 0))
            {
                // Its just air so moving is fine.
                cameraPositionY = cameraPositionY + 64;
                PlayerDepth++;
                PlayerFuel--;
                GoAgain = false;
                TotalMovesMade++;
                TotalFuelUsed++;
            }
            else if ((tileMap[CheckSpot, PlayerPosition] == 10) && (GoAgain) && (PlayerFuel > 0))
            {
                // Its dirt. Moving is fine here.
                cameraPositionY = cameraPositionY + 64;
                tileMap[CheckSpot, PlayerPosition] = 9;
                PlayerDepth++;
                PlayerFuel--;
                GoAgain = false;
                TotalMovesMade++;
                TotalFuelUsed++;
                TotalBlocksMined++;
                TotalDirtBlocksMined++;
                PlayerInv++;
            }
            else
            {
            }
        }
        public void DoMoveLeft()
        {
            int CheckSpot = PlayerPosition - 1;
            if ((tileMap[PlayerDepth, CheckSpot] == 0) && (GoAgain))
            {
                // Cant Move Here Its Stone
                GoAgain = false;
            }
            else if ((tileMap[PlayerDepth, CheckSpot] == 1) && (GoAgain))
            {
                // Sky so moving is fine.
                cameraPositionX = cameraPositionX - 64;
                PlayerPosition--;
                GoAgain = false;
                TotalMovesMade++;
            }
            else if ((tileMap[PlayerDepth, CheckSpot] == 6) && (GoAgain))
            {
                // Building so moving is fine.
                cameraPositionX = cameraPositionX - 64;
                PlayerPosition--;
                GoAgain = false;
                TotalMovesMade++;
            }
            else if ((tileMap[PlayerDepth, CheckSpot] == 7) && (GoAgain))
            {
                // Building so moving is fine.
                cameraPositionX = cameraPositionX - 64;
                PlayerPosition--;
                GoAgain = false;
                TotalMovesMade++;
            }
            else if ((tileMap[PlayerDepth, CheckSpot] == 8) && (GoAgain))
            {
                // Building so moving is fine.
                cameraPositionX = cameraPositionX - 64;
                PlayerPosition--;
                GoAgain = false;
                TotalMovesMade++;
            }
            else if ((tileMap[PlayerDepth, CheckSpot] == 9) && (GoAgain) && (PlayerFuel > 0))
            {
                // Its just air so moving is fine.
                cameraPositionX = cameraPositionX - 64;
                PlayerPosition--;
                PlayerFuel--;
                GoAgain = false;
                TotalMovesMade++;
                TotalFuelUsed++;
            }
            else if ((tileMap[PlayerDepth, CheckSpot] == 10) && (GoAgain) && (PlayerFuel > 0))
            {
                // Its dirt. Moving is fine here.
                cameraPositionX = cameraPositionX - 64;
                tileMap[PlayerDepth, CheckSpot] = 9;
                PlayerPosition--;
                PlayerFuel--;
                GoAgain = false;
                TotalMovesMade++;
                TotalFuelUsed++;
                TotalBlocksMined++;
                TotalDirtBlocksMined++;
            }
            else if ((tileMap[PlayerDepth, CheckSpot] == 11) && (GoAgain))
            {
                // Building so moving is fine.
                cameraPositionX = cameraPositionX - 64;
                PlayerPosition--;
                GoAgain = false;
                TotalMovesMade++;
            }
        }
        public void DoMoveRight()
        {
            int CheckSpot = PlayerPosition + 1;
            if ((tileMap[PlayerDepth, CheckSpot] == 0) && (GoAgain))
            {
                // Cant Move Here Its Stone
                GoAgain = false;
            }
            else if ((tileMap[PlayerDepth, CheckSpot] == 1) && (GoAgain))
            {
                // Sky so moving is fine.
                cameraPositionX = cameraPositionX + 64;
                PlayerPosition++;
                GoAgain = false;
                TotalMovesMade++;
            }
            else if ((tileMap[PlayerDepth, CheckSpot] == 6) && (GoAgain))
            {
                // Building so moving is fine.
                cameraPositionX = cameraPositionX + 64;
                PlayerPosition++;
                GoAgain = false;
                TotalMovesMade++;
            }
            else if ((tileMap[PlayerDepth, CheckSpot] == 7) && (GoAgain))
            {
                // Building so moving is fine.
                cameraPositionX = cameraPositionX + 64;
                PlayerPosition++;
                GoAgain = false;
                TotalMovesMade++;
            }
            else if ((tileMap[PlayerDepth, CheckSpot] == 8) && (GoAgain))
            {
                // Building so moving is fine.
                cameraPositionX = cameraPositionX + 64;
                PlayerPosition++;
                GoAgain = false;
                TotalMovesMade++;
            }
            else if ((tileMap[PlayerDepth, CheckSpot] == 9) && (GoAgain) && (PlayerFuel > 0))
            {
                // Its just air so moving is fine.
                cameraPositionX = cameraPositionX + 64;
                PlayerPosition++;
                PlayerFuel--;
                GoAgain = false;
                TotalMovesMade++;
                TotalFuelUsed++;
            }
            else if ((tileMap[PlayerDepth, CheckSpot] == 10) && (GoAgain) && (PlayerFuel > 0))
            {
                // Its dirt. Moving is fine here.
                cameraPositionX = cameraPositionX + 64;
                tileMap[PlayerDepth, CheckSpot] = 9;
                PlayerPosition++;
                PlayerFuel--;
                GoAgain = false;
                TotalMovesMade++;
                TotalFuelUsed++;
                TotalBlocksMined++;
                TotalDirtBlocksMined++;
            }
            else if ((tileMap[PlayerDepth, CheckSpot] == 11) && (GoAgain))
            {
                // Building so moving is fine.
                cameraPositionX = cameraPositionX + 64;
                PlayerPosition++;
                GoAgain = false;
                TotalMovesMade++;
            }
        }
        public void DoSellOres()
        {
            if (PlayerInv > 0)
            {
                // Ore Values
                int CoalOreValue = 25;
                int CopperOreValue = 50;
                int TinOreValue = 100;
                int IronOreValue = 150;
                // Ore Value Temp Variables
                int Ore1Value;
                int Ore2Value;
                int Ore3Value;
                int Ore4Value;
                // Calculate Value Of Ores
                Ore1Value = PlayerInventoryCoalOre * CoalOreValue;
                Ore2Value = PlayerInventoryCopperOre * CopperOreValue;
                Ore3Value = PlayerInventoryTinOre * TinOreValue;
                Ore4Value = PlayerInventoryIronOre * IronOreValue;
                // Pay Player & Remove Ores
                PlayerCoin = PlayerCoin + Ore1Value + Ore2Value + Ore3Value + Ore4Value;
                PlayerInventoryCoalOre = 0;
                PlayerInventoryCopperOre = 0;
                PlayerInventoryTinOre = 0;
                PlayerInventoryIronOre = 0;
                PlayerInv = 0;
                smelterysale.Play();
            }
            else
            {
                // We Don't Have Anything To Sell
            }
        }
        public void DoFuelUp()
        {
            int newfuel;
            if ((PlayerPosition == 15) && (PlayerDepth == 8))
            {
                if (PlayerFuel < PlayerMaxFuel)
                {
                    newfuel = PlayerMaxFuel - PlayerFuel;


                    if (PlayerCoin >= newfuel * PlayerFuelTier)
                    {
                        PlayerFuel = PlayerMaxFuel;
                        PlayerCoin = PlayerCoin - newfuel;
                        fuelstationfillup.Play();
                    }
                    else
                    {
                        // Can't Afford Fuel
                    }
                }
            }
            else
            {
                // Player Not At Fuel Station
            }
        }
        public void DoUpgradePick()
        {
            if (PlayerCoin >= PlayerPickTierCostDisplay)
            {
                PlayerCoin = PlayerCoin - PlayerPickTierCostDisplay;
                PlayerPickTier++;
                PlayerMaxDepth = PlayerMaxDepth + 50;
                upgradesale.Play();
            }
        }
        public void DoUpgradeInv()
        {
            if (PlayerCoin >= PlayerInvTierCostDisplay)
            {
                PlayerCoin = PlayerCoin - PlayerInvTierCostDisplay;
                PlayerInvTier++;
                PlayerMaxInv = PlayerMaxInv + 10;
                upgradesale.Play();
            }
        }
        public void DoUpgradeFuel()
        {
            if (PlayerCoin >= PlayerFuelTierCostDisplay)
            {
                PlayerCoin = PlayerCoin - PlayerFuelTierCostDisplay;
                PlayerFuelTier++;
                PlayerMaxFuel = PlayerMaxFuel + 100;
                upgradesale.Play();
            }
        }
        private void InitiateSave()
        {
            if (!Guide.IsVisible)
            {
                device = null;
                StorageDevice.BeginShowSelector(PlayerIndex.One, this.SaveToDevice, null);
            }
        }
        void SaveToDevice(IAsyncResult result)
        {
            device = StorageDevice.EndShowSelector(result);
            if (device != null && device.IsConnected)
            {
                SaveGame SaveData = new SaveGame()
                {
                    // Player Variables
                    PlayerScore = PlayerScore,           
                    PlayerFuel = PlayerFuel,
                    PlayerMaxFuel = PlayerMaxFuel,
                    PlayerPickTier = PlayerPickTier,
                    PlayerInvTier = PlayerInvTier,
                    PlayerFuelTier = PlayerFuelTier,
                    PlayerMaxDepth = PlayerMaxDepth,
                    PlayerCoin = PlayerCoin,
                    PlayerInv = PlayerInv,
                    PlayerMaxInv = PlayerMaxInv,
                    PlayerDepth = PlayerDepth,
                    PlayerPosition = PlayerPosition,
                    // Player Inventory Variables
                    PlayerInventoryCoalOre = PlayerInventoryCoalOre,
                    PlayerInventoryCopperOre = PlayerInventoryCopperOre,
                    PlayerInventoryTinOre = PlayerInventoryTinOre,
                    PlayerInventoryIronOre = PlayerInventoryIronOre,
                    PlaceHolder = PlaceHolder,
                    // Player Statistics
                    TotalMoneyAquired = TotalMoneyAquired,
                    TotalUpgradesAquired = TotalUpgradesAquired,
                    TotalMovesMade =  TotalMovesMade,
                    TotalFuelUsed = TotalFuelUsed,
                    TotalBlocksMined = TotalBlocksMined,
                    TotalDirtBlocksMined = TotalDirtBlocksMined,
                    TotalCoalOre = TotalCoalOre,
                    TotalCopperOre = TotalCopperOre,
                    TotalTinOre = TotalTinOre,
                    TotalIronOre = TotalIronOre,
                    // Game Map Array
                    //tileMap0 = ,
                };
                IAsyncResult r = device.BeginOpenContainer(containerName, null, null);
                result.AsyncWaitHandle.WaitOne();
                StorageContainer container = device.EndOpenContainer(r);
                if (container.FileExists(filename))
                    container.DeleteFile(filename);
                Stream stream = container.CreateFile(filename);
                XmlSerializer serializer = new XmlSerializer(typeof(SaveGame));
                serializer.Serialize(stream, SaveData);
                stream.Close();
                container.Dispose();
                result.AsyncWaitHandle.Close();
                gameState = GameState.GameScreen;
            }
            else
            {
                gameState = GameState.GameMenuScreen;
            }
        }
        private void InitiateLoad()
        {
            if (!Guide.IsVisible)
            {
                device = null;
                StorageDevice.BeginShowSelector(PlayerIndex.One, this.LoadFromDevice, null);
            }
        }
        void LoadFromDevice(IAsyncResult result)
        {
            device = StorageDevice.EndShowSelector(result);
            IAsyncResult r = device.BeginOpenContainer(containerName, null, null);
            result.AsyncWaitHandle.WaitOne();
            StorageContainer container = device.EndOpenContainer(r);
            result.AsyncWaitHandle.Close();
            if (container.FileExists(filename))
            {
                Stream stream = container.OpenFile(filename, FileMode.Open);
                XmlSerializer serializer = new XmlSerializer(typeof(SaveGame));
                SaveGame SaveData = (SaveGame)serializer.Deserialize(stream);
                stream.Close();
                container.Dispose();
                //Update the game based on the save game file
                // Player Variables
                PlayerScore  = SaveData.PlayerScore;
                PlayerFuel = SaveData.PlayerFuel;
                PlayerMaxFuel = SaveData.PlayerMaxFuel;
                PlayerPickTier = SaveData.PlayerPickTier;
                PlayerInvTier = SaveData.PlayerInvTier;
                PlayerFuelTier = SaveData.PlayerFuelTier;
                PlayerMaxDepth = SaveData.PlayerMaxDepth;
                PlayerCoin = SaveData.PlayerCoin;
                PlayerInv = SaveData.PlayerInv;
                PlayerMaxInv = SaveData.PlayerMaxInv;
                PlayerDepth = SaveData.PlayerDepth;
                PlayerPosition = SaveData.PlayerPosition;
                // Player Inventory Variables
                PlayerInventoryCoalOre = SaveData.PlayerInventoryCoalOre;
                PlayerInventoryCopperOre = SaveData.PlayerInventoryCopperOre;
                PlayerInventoryTinOre = SaveData.PlayerInventoryTinOre;
                PlayerInventoryIronOre = SaveData.PlayerInventoryIronOre;
                PlaceHolder = SaveData.PlaceHolder;
                // Player Statistics
                TotalMoneyAquired = SaveData.TotalMoneyAquired;
                TotalUpgradesAquired = SaveData.TotalUpgradesAquired;
                TotalMovesMade = SaveData.TotalMovesMade;
                TotalFuelUsed = SaveData.TotalFuelUsed;
                TotalBlocksMined = SaveData.TotalBlocksMined;
                TotalDirtBlocksMined = SaveData.TotalDirtBlocksMined;
                TotalCoalOre = SaveData.TotalCoalOre;
                TotalCopperOre = SaveData.TotalCopperOre;
                TotalTinOre  = SaveData.TotalTinOre;
                TotalIronOre = SaveData.TotalIronOre;
                // Game Map Array
                gameState = GameState.GameScreen;
            }
            else
            {
                gameState = GameState.MainMenuScreen;
            }
        }
    }
}

 

I cannot go over all your code right now, but are you saying you attempted to convert your 2D array into a Jagged and it didn't work? Did you use my example from page 1 where I show you how to feed in and out?

Just in case you don't know but: 


int[,] tileMap = new int[67,30]

is not a Jagged format, that's just a standard 2D Array. You need to actually feed your 2D array into the Jagged like I had shown on Page 1.

Can you show me where you converted the 2D Array into a Jagged and it didn't work?

I really think you should just keep your maps as Jagged and forget 2D Arrays.

Programmer and 3D Artist

That will present a problem of stacking arrays in rows and will make my movement code not work without having to hardcore it. Right now it calculates off the array.

Is there a way to make an array go vertical since once direction is fixed i could just do 30 arrays positioned the other direction and viola i have infinite length.

1 hour ago, Shawn Naef said:

That will present a problem of stacking arrays in rows and will make my movement code not work without having to hardcore it. Right now it calculates off the array.

Is there a way to make an array go vertical since once direction is fixed i could just do 30 arrays positioned the other direction and viola i have infinite length.

If you need full dynamic features for columns and rows use a List.

Programmer and 3D Artist

This topic is closed to new replies.

Advertisement