private void cmdDeleteLevel_Click(object sender, EventArgs e)
        {
            if (world.Count > 1)
            {
                DialogResult dialogResult = MessageBox.Show("Are you sure you want to delete this level. This action is irreversible.", "Delete Level", MessageBoxButtons.YesNo);
                if (dialogResult == DialogResult.Yes)
                {
                    //Delte the layer
                    world.RemoveAt(FloorNum);

                    if (FloorNum == world.Count) FloorNum = FloorNum - 1;
                    ThisFloor = world[FloorNum];

                    cmbLevelSelect.Items.Clear();
                    for (int i = 1; i <= world.Count; i++)
                    {
                        cmbLevelSelect.Items.Add("Level " + i);
                    }
                    cmbLevelSelect.Items.Add("Add New Level...");
                    tblWorldLevel.Refresh();
                    cmbLevelSelect.SelectedIndex = FloorNum;
                }
            }
            else MessageBox.Show("You cannot have a world with no floors,");
        }
        //Expand Dong

        private void cmdAddCol_Click(object sender, EventArgs e)
        {
            //function to increase currentfloor array by 1
            DataTypes.Floor ExpandFloor = AddWorldCol();
            ThisFloor.CurrentFloor = ExpandFloor.CurrentFloor;

            AddCol();
            AddTableLabels();
            tblWorldLevel.Refresh();
        }
        private void cmdRemoveCol_Click(object sender, EventArgs e)
        {
            tblWorldLevel.Controls.Clear();

            //function to increase currentfloor array by 1
            DataTypes.Floor ExpandFloor = RemoveWorldCol();
            ThisFloor.CurrentFloor = ExpandFloor.CurrentFloor;

            RemoveCol();
            AddTableLabels();
            tblWorldLevel.Refresh();
        }
        private void cmbLevelSelect_SelectionChangeCommitted(object sender, EventArgs e)
        {
            int index = cmbLevelSelect.SelectedIndex;

            //MessageBox.Show(index.ToString());
            //MessageBox.Show(cmbLevelSelect.Items.Count.ToString());

            world[FloorNum] = ThisFloor; //Save Current Floor - unnecessary but why not eh?

            if ((index + 1) == cmbLevelSelect.Items.Count)   //Adding new floor
            {
                FloorNum = index;
                cmbLevelSelect.Items[index] = "Level " + (index + 1);
                cmbLevelSelect.Items.Add("Add New Level...");

                ThisFloor = new DataTypes.Floor();
                ThisFloor.CurrentFloor = new DataTypes.roomInfo[10, 10];
                for (int x = 0; x < 10; x++)
                {
                    for (int y = 0; y < 10; y++)
                    {
                        ThisFloor.CurrentFloor[x, y].CanMove = true;
                    }
                }

                for (int x = 0; x < 10; x++)
                {
                    ThisFloor.CurrentFloor[x, 0].CanMove = false;
                    ThisFloor.CurrentFloor[x, 9].CanMove = false;
                }

                for (int y = 0; y < 10; y++)
                {
                    ThisFloor.CurrentFloor[0, y].CanMove = false;
                    ThisFloor.CurrentFloor[9, y].CanMove = false;
                }
                world.Add(ThisFloor);
                txtFloorName.Text = "Level " + (index + 1);
            }
            else
            {
                FloorNum = index;   //Set floor number to selected index
                ThisFloor = world[index];   //Load in the floor
                txtFloorName.Text = ThisFloor.FloorName;
                txtMusicPath.Text = ThisFloor.FloorSong;
            }
            tblWorldLevel.Visible = false;
            SetWorldSize();
            AddTableLabels();
            tblWorldLevel.Refresh(); //Draw the grid
            tblWorldLevel.Visible = true;

        }
        public DataTypes.Floor RemoveWorldCol()
        {
            DataTypes.Floor NewFloor = new DataTypes.Floor();

            NewFloor.CurrentFloor = new DataTypes.roomInfo[ThisFloor.CurrentFloor.GetLength(0), ThisFloor.CurrentFloor.GetLength(1) - 1];
            
            DataTypes dt = new DataTypes();
            for (int row = 0; row < ThisFloor.CurrentFloor.GetLength(0); row++)
            {
                for (int col = 0; col < ThisFloor.CurrentFloor.GetLength(1) -1; col++)
                {
                    NewFloor.CurrentFloor[row, col] = dt.CloneRoom(ThisFloor.CurrentFloor[row, col]);
                }
            }

            return NewFloor;
        }
        public frmWorldDesigner(bool LoadWorld, string WorldName)
        {

            InitializeComponent();

            //Check If New World
            if (LoadWorld == true)
            {
                string LoadPath = string.Concat(Directory.GetCurrentDirectory(), "\\Worlds\\", WorldName);
                //MessageBox.Show(LoadPath);


                DataTypes.WorldFile WorldState = new DataTypes.WorldFile();
                using (Stream stream = File.Open(LoadPath, FileMode.Open))
                {
                    BinaryFormatter bin = new BinaryFormatter();
                    WorldState = (DataTypes.WorldFile)bin.Deserialize(stream);

                }
                txtWorldName.Text = WorldState.WorldName;
                txtAuthor.Text = WorldState.WorldAuthor;
                world = WorldState.WorldState;

                if (WorldState.Credits != null) foreach (string credit in WorldState.Credits) { Credits.Add(credit); }

                ThisFloor = world[0];
                txtFloorName.Text = ThisFloor.FloorName;
                txtMusicPath.Text = ThisFloor.FloorSong;
                ThisPlayer = WorldState.DefaultPlayer;
                cmbLevelSelect.Items.Clear();
                for (int i = 1; i <= world.Count; i++)
                {
                    cmbLevelSelect.Items.Add("Level " + i);
                }
                cmbLevelSelect.Items.Add("Add New Level...");
                this.tblWorldLevel.CellPaint += new TableLayoutCellPaintEventHandler(tblWorldLevel_CellPaint);
                lblEditor.Text = "Default Starting Position is B:2";
            }
            else
            {
                world = new List<DataTypes.Floor>();
                ThisFloor = new DataTypes.Floor();
                ThisFloor.CurrentFloor = new DataTypes.roomInfo[10, 10];

                for (int x = 0; x < 10; x++)
                {
                    for (int y = 0; y < 10; y++)
                    {
                        ThisFloor.CurrentFloor[x, y].CanMove = true;
                    }
                }

                for (int x = 0; x < 10; x++)
                {
                    ThisFloor.CurrentFloor[x, 0].CanMove = false;
                    ThisFloor.CurrentFloor[x, 9].CanMove = false;
                }

                for (int y = 0; y < 10; y++)
                {
                    ThisFloor.CurrentFloor[0, y].CanMove = false;
                    ThisFloor.CurrentFloor[9, y].CanMove = false;
                }
                ThisFloor.CurrentFloor[1, 1].Description = "This is the starting position. When the player spawns this is the first thing they will read";

                world.Add(ThisFloor);
                this.tblWorldLevel.CellPaint += new TableLayoutCellPaintEventHandler(tblWorldLevel_CellPaint);
                txtFloorName.Text = "Level 1";
                lblEditor.Text = "Default Starting Position is B:2";
                ThisPlayer = DefaultPlayer();
            }
            SetWorldSize();
            AddTableLabels();
        }