Automatyczne dumpy

This commit is contained in:
Bartosz Chyzy 2019-05-14 23:04:07 +02:00
parent 7d4bdd1dfa
commit 865921411e

View File

@ -18,6 +18,13 @@ namespace MapEditor
var bitmap = (Bitmap)Bitmap.FromFile(Config.ImageFilePath);
var fieldInfos = GetFieldInfos(bitmap);
if (fieldInfos.Count(x => x.FieldType == FieldType.Dump) != 4)
{
Console.WriteLine("Na mapie nie znajdują się 4 wysypiska!");
Console.ReadKey();
return;
}
if(GenerateXML(fieldInfos))
Console.WriteLine("Done.");
else
@ -44,6 +51,7 @@ namespace MapEditor
}
private static bool GenerateXML(IEnumerable<FieldInfo> fieldInfos)
{
var dumpNumber = 0;
var random = new Random();
try
{
@ -121,6 +129,27 @@ namespace MapEditor
xmlWriter.WriteEndElement();
}
if (fieldInfo.FieldType == FieldType.Dump)
{
xmlWriter.WriteStartElement("Garbage");
if (dumpNumber == 0)
xmlWriter.WriteElementString("GarbageType","Paper");
if (dumpNumber == 1)
xmlWriter.WriteElementString("GarbageType", "Glass");
if (dumpNumber == 2)
xmlWriter.WriteElementString("GarbageType", "Organic");
if (dumpNumber == 3)
xmlWriter.WriteElementString("GarbageType", "PlasticMetal");
dumpNumber++;
xmlWriter.WriteEndElement();
}
xmlWriter.WriteEndElement();
}
xmlWriter.WriteEndElement();