class Battle
{
private List<City> cityRandomReplace(List<City> beforeCities)
{
var r = Singleton.GetRandom();
List<City> afterCities = new List<City>();
int max = beforeCities.Count;
for (int i = 0; i < max; i++)
{
int index = r.Next(0, beforeCities.Count - 1);
afterCities.Add(beforeCities[index]);
beforeCities.RemoveAt(index);
}
return afterCities;
}
class HokkaidoWar
{
public void Run()
{
_battle = new Battle(cities);
while (asd.Engine.DoEvents())
{
if (asd.Engine.Mouse.LeftButton.ButtonState == asd.ButtonState.Push)
{
_battle.NextTurn();
}
asd.Engine.Update();
}
asd.Engine.Terminate();
class Battle
{
private List<City> _cities = null;
private int turn;
private int cityCnt;
public Battle(List<City> cities)
{
turn = 1;
cityCnt = 0;
_cities = new List<City>();
foreach(var c in cities)
{
_cities.Add(c);
}
_cities = cityRandomReplace(_cities);
}
public void NextTurn()
{
cityCnt++;
if(cityCnt >= _cities.Count)
{
_cities = cityRandomReplace(_cities);
cityCnt = 0;
turn++;
}
var info = Singleton.GetGameProcessInfomation();
info.ShowText(_cities[cityCnt].GetPosition(), string.Format("{0} turn {1} / {2} {3}", turn, cityCnt, _cities.Count, _cities[cityCnt].Name));
}
class AutoTest
{
private const string QuestionFolder = "q";
private const string AnswerFolder = "a";
private const string ResultFolder = "r";
private const string QuestionFile = "save";
private const string AnswerFile = "output";
private const string ResultFile = "result";
public AutoTest()
{
}
public void Run()
{
var files = Directory.EnumerateFiles(QuestionFolder, "*");
foreach(var file in files)
{
string answerFile = file.Replace(QuestionFolder, AnswerFolder).Replace(QuestionFile, AnswerFile);
string resultFile = file.Replace(QuestionFolder, ResultFolder).Replace(QuestionFile, ResultFile);
if (File.Exists(resultFile))
{
File.Delete(resultFile);
}
if (File.Exists(answerFile))
{
List<List<NumberSquare>> rowNumberSquare = new List<List<NumberSquare>>();
List<List<NumberSquare>> colNumberSquare = new List<List<NumberSquare>>();
FileAccess.Load(file, ref rowNumberSquare, ref colNumberSquare);
PicrossAnalyze picross = new PicrossAnalyze(rowNumberSquare, colNumberSquare);
var ret = picross.Run();
string answer = string.Empty;
for(int r = 0; r < rowNumberSquare.Count; r++)
{
for(int c = 0; c < colNumberSquare.Count; c++)
{
if (ret[r, c].IsPainted())
{
answer += "1";
}
else
{
answer += "0";
}
}
answer += "\r\n";
}
string compare = FileAccess.AnswerLoad(answerFile);
string result;
if(compare.CompareTo(answer) == 0)
{
result = "OK";
}
else
{
result = answer;
}
using (var stream = new StreamWriter(resultFile, true))
{
stream.Write(result);
}
}
}
}
}
class PicrossUI
{
public void Run()
{
// テストボタン
var testButton = new Button(10, 170, "テスト");
testButton.Show();
asd.Engine.AddObject2D(testButton.getBackTexture());
asd.Engine.AddObject2D(testButton.getTextObject());
buttons.Add(testButton);
testButton.SetAction(() =>
{
var test = new AutoTest();
test.Run();
});