Example #1
0
        public void showCharacterPanel(Entity player, Map map)
        {
            string[] characterPanel = FileManager.loadPanel("character.txt");
            int panelStartX = map.width + characterPanel[0].Length;

            displayPanel(characterPanel, panelStartX);
        }
Example #2
0
        public static void saveMap(string fileName, Map map)
        {
            List<string> temp = new List<string>();

            for (int i = 0; i < map.height; i++)
            {
                String line = "";
                for (int j = 0; j < map.width; j++)
                {
                    line += map.entityArray[j][i].symbol;
                }
                temp.Add(line);
            }
            saveTextFile(getPath(PATH_ROOT, PATH_MAP, fileName), temp.ToArray());
        }
Example #3
0
        public static Map loadMap(string fileName)
        {
            Map map = new Map();
            string[] lines = loadTextFile(getPath(PATH_ROOT, PATH_MAP, fileName));

            map.width = lines[0].Length;
            map.height = lines.Length;

            map.entityArray = new Entity[map.width][];

            for(int i = 0; i < map.width; ++i)
            {
                map.entityArray[i] = new Entity[map.height];
            }

            int j = 0;

            foreach(string line in lines)
            {
                int i = 0;

                foreach(char ch in line)
                {
                    // make sure to skip over the newline
                    if(i < map.width)
                    {
                        map.entityArray[i][j] = EntityManager.getInstance.getEntity(EntityManager.getInstance.createEntity(ch.ToString()));
                        map.entityArray[i][j].previousPosition.x = map.entityArray[i][j].currentPosition.x = i;
                        map.entityArray[i][j].previousPosition.y = map.entityArray[i][j].currentPosition.y = j;
                        i++;
                    }
                }
                j++;
            }
            return map;
        }