static void loadVictories(string folder) { foreach (string file in System.IO.Directory.GetFiles(System.IO.Path.Combine( ContentManager.RootDirectory, folder))) { string fName = System.IO.Path.GetFileNameWithoutExtension(file); UnitsAndBuilduings.VictoryTypeInfo info = ContentManager.Load <UnitsAndBuilduings.VictoryTypeInfo>( folder + "\\" + fName); Resources.Add(fName, MakeVicChecker(info)); } }
public static VictoryChecker MakeVicChecker(UnitsAndBuilduings.VictoryTypeInfo info) { VictoryChecker vicChecker = new VictoryChecker(); vicChecker.CheckTime = (CheckTime)info.CheckType; vicChecker.TimerTime = info.CheckTime; string winCode = "using System; using Omron; using Omron.Framework; using Omron.Actors; using System.Linq;" + "namespace Omron { public class CHKR { public static bool Win(World world, Faction faction) {" + info.WinCondition + "} } }"; string loseCode = "using System; using Omron; using Omron.Framework; using Omron.Actors; using System.Linq;" + "namespace Omron { public class CHKR { public static bool Lose(World world, Faction faction) {" + info.LoseCondition + "} } }"; vicChecker.FactionWon = getDelegate(winCode, "Win"); vicChecker.FactionLost = getDelegate(loseCode, "Lose"); return(vicChecker); }