示例#1
0
        private void GenerateMap(MapSize mapSize)
        {
            for (int i = 0; i < MapData.Capacity; i++)
            {
                var tempList = new List <ITile>((int)mapSize);
                for (int j = 0; j < tempList.Capacity; j++)
                {
                    if (i > 31)
                    {
                        tempList.Add(new Dirt());
                    }
                    else if (i == 31)
                    {
                        tempList.Add(new Grass());
                    }
                    else if (i == 30)
                    {
                        tempList.Add(new Slab());
                    }
                    else
                    {
                        tempList.Add(new Air());
                    }
                }

                MapData.Add(tempList);
            }
        }
示例#2
0
        private void LoadMapData(string FriendlyName, string FilePath, string FileName, string FileExtension)
        {
            // make sure resource exists
            var fullDirectory = ReadWrite.CreateIfNotExists(FilePath, FileName, FileExtension, false);

            if (!string.IsNullOrEmpty(fullDirectory))
            {
                var mapData = ReadWrite.ReadJson <LevelObj>(FilePath, FileName, FileExtension, false);
                if (mapData != null)
                {
                    MapData.Add(FriendlyName, mapData);
                }
                else
                {
                    ReadWrite.WriteToLog(String.Format("LoadMapData - Data is null. FriendlyName: {0}. Root: {1}. Path: {2}. FileName: {3}. FileExtension: {4}",
                                                       FriendlyName, ReadWrite.GetRoot, FilePath, FileName, FileExtension));
                    throw new FileLoadException("Could not Load resource");
                }
            }
            else
            {
                ReadWrite.WriteToLog(String.Format("LoadMapData - Could not load resource. FriendlyName: {0}. Root: {1}. Path: {2}. FileName: {3}. FileExtension: {4}",
                                                   FriendlyName, ReadWrite.GetRoot, FilePath, FileName, FileExtension));
                throw new FileLoadException("Could not Load resource");
            }
        }
示例#3
0
        public void ReadFile(string filename)
        {
            // Get each line of file as an entry in array lines.
            string[] lines = File.ReadAllLines(Utils.GetLevelFilePath(filename));

            // Iterate over lines and add data till the corresponding field
            // Adds tiles to MapData
            for (var i = 0; i < 24; i++)
            {
                foreach (var j in lines[i])
                {
                    MapData.Add(j);
                }
            }


            foreach (var i in lines)
            {
                if (i.StartsWith("Platforms"))
                {
                    var platforms = i.Split(':')[1].Split(',');
                    foreach (var j in platforms)
                    {
                        var elm      = lines.Where(el => el.StartsWith(j.Trim() + ") "));
                        var charKey  = elm.First().Split(' ', ')')[0].ToCharArray()[0];
                        var strValue = elm.First().Split(' ')[1];
                        MetaData.Add(charKey, strValue);
                    }
                }

                if (i.Contains(")"))
                {
                    char   charKey  = i.Split(')')[0][0];
                    string strValue = i.Split(')')[1].Trim();
                    LegendData.Add(charKey, strValue);
                }

                if (i.StartsWith("Customer"))
                {
                    var customers = i.Split(':')[1].Split(' ');
                    CustomerData.Add(customers);
                }
            }
        }
示例#4
0
    public static MapData Generate()
    {
        MapData md = new MapData();

        md.Add(new FenceHMI(36,74));
        md.Add(new FenceHMI(112,-65));
        md.Add(new FenceHMI(-22,-98));
        md.Add(new FenceHMI(-237,-33));
        md.Add(new FenceHMI(-182,-93));
        md.Add(new FenceVMI(-189,73));
        md.Add(new FenceVMI(-48,-76));
        md.Add(new FenceVMI(165,-14));
        md.Add(new FenceVMI(84,-96));
        md.Add(new FenceVMI(61,97));
        md.Add(new FenceVMI(273,29));
        md.Add(new House1MI(52,-49));
        md.Add(new House1MI(132,32));
        md.Add(new House1MI(-160,120));
        md.Add(new House1MI(-183,-16));
        md.Add(new StartPosMI(-62,-134));
        md.Add(new StartPosMI(-257,127));
        md.Add(new StartPosMI(-45,132));
        md.Add(new StartPosMI(156,128));
        md.Add(new StartPosMI(189,-115));
        md.Add(new StartPosMI(237,27));
        md.Add(new StartPosMI(-272,32));
        md.Add(new StartPosMI(-228,-124));

        return md;
    }
示例#5
0
    public static MapData Generate()
    {
        MapData md = new MapData();

        md.Add(new FenceHMI(36, 74));
        md.Add(new FenceHMI(112, -65));
        md.Add(new FenceHMI(-22, -98));
        md.Add(new FenceHMI(-237, -33));
        md.Add(new FenceHMI(-182, -93));
        md.Add(new FenceVMI(-189, 73));
        md.Add(new FenceVMI(-48, -76));
        md.Add(new FenceVMI(165, -14));
        md.Add(new FenceVMI(84, -96));
        md.Add(new FenceVMI(61, 97));
        md.Add(new FenceVMI(273, 29));
        md.Add(new House1MI(52, -49));
        md.Add(new House1MI(132, 32));
        md.Add(new House1MI(-160, 120));
        md.Add(new House1MI(-183, -16));
        md.Add(new StartPosMI(-62, -134));
        md.Add(new StartPosMI(-257, 127));
        md.Add(new StartPosMI(-45, 132));
        md.Add(new StartPosMI(156, 128));
        md.Add(new StartPosMI(189, -115));
        md.Add(new StartPosMI(237, 27));
        md.Add(new StartPosMI(-272, 32));
        md.Add(new StartPosMI(-228, -124));

        return(md);
    }