Game-Design / Sprint3_actual / Inventory / VisitedRooms.cs
VisitedRooms.cs
Raw
using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic;
using System.Text;

namespace Sprint3_actual
{
    public class VisitedRooms
    {
        private Inventory inventory;
        public VisitedRooms(Inventory inventory) 
        {
            this.inventory = inventory;
        }

        public void UpdateVisitedRooms(bool hasMap, bool[,] visited, ISprite[,] mapTiles, ISprite[,] minimapTiles, Vector2 inventoryTopCoords, Vector2 inventoryBottomCoords)
        {
            for (int r = 0; r < 8; r++)
            {
                for (int c = 0; c < 8; c++)
                {
                    if (visited[r, c])
                    {
                        mapTiles[r, c] = InventorySpriteFactory.Instance.CreateMapGridBox((int)inventoryTopCoords.X + 384 + (c * 24), (int)inventoryTopCoords.Y + 288 + (r * 24));
                    }
                    else
                    {
                        mapTiles[r, c] = InventorySpriteFactory.Instance.CreateOrangeMapSquare((int)inventoryTopCoords.X + 384 + (c * 24), (int)inventoryTopCoords.Y + 288 + (r * 24));
                    }

                    if (hasMap)
                    {
                        if(inventory.levelCount == 1) 
                        { 
                            if (GlobalVars.roomArray1[r, c] != null)
                            {
                                minimapTiles[r, c] = InventorySpriteFactory.Instance.CreateBlueGridBox((int)inventoryBottomCoords.X + 48 + (c * 24), (int)inventoryBottomCoords.Y + 48 + (r * 12));
                            }
                            else
                            {
                                minimapTiles[r, c] = InventorySpriteFactory.Instance.CreateBlackGridBox((int)inventoryBottomCoords.X + 48 + (c * 24), (int)inventoryBottomCoords.Y + 48 + (r * 12));
                            }
                        }
                        else if (inventory.levelCount == 2)
                        {
                            if (GlobalVars.roomArray2[r, c] != null)
                            {
                                minimapTiles[r, c] = InventorySpriteFactory.Instance.CreateBlueGridBox((int)inventoryBottomCoords.X + 48 + (c * 24), (int)inventoryBottomCoords.Y + 48 + (r * 12));
                            }
                            else
                            {
                                minimapTiles[r, c] = InventorySpriteFactory.Instance.CreateBlackGridBox((int)inventoryBottomCoords.X + 48 + (c * 24), (int)inventoryBottomCoords.Y + 48 + (r * 12));
                            }
                        }
                        else
                        {
                            if (r < 7 && c < 7)
                            {
                                if (inventory.Rooms[r, c] != null)
                                {
                                    minimapTiles[r, c] = InventorySpriteFactory.Instance.CreateBlueGridBox((int)inventoryBottomCoords.X + 48 + (c * 24), (int)inventoryBottomCoords.Y + 48 + (r * 12));
                                }
                                else
                                {
                                    minimapTiles[r, c] = InventorySpriteFactory.Instance.CreateBlackGridBox((int)inventoryBottomCoords.X + 48 + (c * 24), (int)inventoryBottomCoords.Y + 48 + (r * 12));
                                }
                            }
                        }
                    }
                }
            }
        }

        public void DrawVisitedRoomsInInventory(ISprite[,] mapTiles)
        {
            for (int r = 0; r < 8; r++)
            {
                for (int c = 0; c < 8; c++)
                {
                    mapTiles[r, c].draw();
                }
            }
        }

        public void DrawVisitedRoomsInHotbar(ISprite[,] minimapTiles)
        {
            for (int r = 0; r < 8; r++)
            {
                for (int c = 0; c < 8; c++)
                {
                    if(minimapTiles[r,c] != null)
                    minimapTiles[r, c].draw();
                }
            }
        } 
    }
}