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); }
public void SetVictory(VictoryChecker victry) { vicChecker = victry; switch (vicChecker.CheckTime) { case CheckTime.Timer: vicTimer = new Timer(vicChecker.TimerTime); vicTimer.Start(); vicTimer.Triggered += new TimerEventHandler(vicTimer_Triggered); break; case CheckTime.Creation: world.NotifyActorAdded += new ActorRemoved(ActorAddedVictoryCheck); break; case CheckTime.Death: world.NotifyActorRemoved += new ActorRemoved(ActorRemovedVictoryCheck); break; } }