public MainWindow() { InitializeComponent(); string[] args = Environment.GetCommandLineArgs(); bool cmdpony = false; // find anypony that is available. PonyConfig.FindEverypony(); Trace.WriteLine(String.Format( "== Found {0} usable ponies", PonyConfig.List.Count )); // go pony go. // check to see if any ponies were specified on the command line. if (args.Length > 1) { foreach (string arg in args) { if (PonyConfig.List.Exists(delegate(PonyConfig pc) { return(pc.Name == arg); })) { cmdpony = true; Main.StartPony(arg); } } } // if the command line did not successfully spawn ponies then start one now. if (!cmdpony) { Main.StartPony("Twilight Sparkle"); } }
/// <summary> /// create a new pony from the configuration. it will initalize allthe /// required properties including building the lists of actions (active /// and passive) that this pony instance is capable of doing. /// </summary> public Pony(PonyConfig config) { this.RNG = new Random(); this.Name = config.Name; this.YOffset = config.YOffset; this.Ponyality = config.Ponyality; this.Energy = 400; this.SleepTOD = true; // prepare available action lists. copy on purpose. this.AvailableActions = new List<PonyAction>(config.Actions); this.AvailableActiveActions = new List<PonyAction>(); this.AvailablePassiveActions = new List<PonyAction>(); // for each available action, classify them as active or passive // for our decision making later. this.AvailableActions.ForEach(delegate(PonyAction action){ if(Enum.IsDefined(typeof(PonyActionActive), (int)action)) this.AvailableActiveActions.Add(action); if(Enum.IsDefined(typeof(PonyActionPassive), (int)action)) this.AvailablePassiveActions.Add(action); }); Trace.WriteLine(String.Format( "== {0} can perform {1} Active and {2} Passive actions", this.Name, this.AvailableActiveActions.Count, this.AvailablePassiveActions.Count )); Trace.WriteLine(String.Format( "== {0} Ponyality:\r\n {1}", this.Name, this.Ponyality.ToString() )); // prepare action properties. this.Mode = PonyMode.Free; this.Action = PonyAction.None; this.Direction = PonyDirection.None; // various timers. this.ChoiceTimer = null; this.WindowTimer = null; this.ClingTimer = null; // physical stuff. this.Window = new PonyWindow(this); this.Image = new List<PonyImage>(); // preload action images. this.LoadAllImages(); Trace.WriteLine(String.Format("// {0} says hello",this.Name)); // if a pony can teleport lets let them poof in. if(this.CanDo(PonyAction.Teleport)) { this.LoadImage(PonyAction.Teleport,PonyDirection.Right); this.TeleportStage(); } // else have them walk in from the edge. else { this.LoadImage(PonyAction.Trot, PonyDirection.Right); this.Window.Left = 0 - (this.Window.Width + 10); this.TellWhatDo(PonyAction.Trot,PonyDirection.Right); } this.Window.Show(); }
/// <summary> /// create a new pony from the configuration. it will initalize allthe /// required properties including building the lists of actions (active /// and passive) that this pony instance is capable of doing. /// </summary> public Pony(PonyConfig config) { this.RNG = new Random(); this.Name = config.Name; this.YOffset = config.YOffset; this.Ponyality = config.Ponyality; this.SleepTOD = true; this.EnergyMax = 600; this.EnergyReset(); // prepare available action lists. copy on purpose. this.AvailableActions = new List <PonyAction>(config.Actions); this.AvailableActiveActions = new List <PonyAction>(); this.AvailablePassiveActions = new List <PonyAction>(); // for each available action, classify them as active or passive // for our decision making later. this.AvailableActions.ForEach(delegate(PonyAction action){ if (Enum.IsDefined(typeof(PonyActionActive), (int)action)) { this.AvailableActiveActions.Add(action); } if (Enum.IsDefined(typeof(PonyActionPassive), (int)action)) { this.AvailablePassiveActions.Add(action); } }); Trace.WriteLine(String.Format( "== {0} can perform {1} Active and {2} Passive actions", this.Name, this.AvailableActiveActions.Count, this.AvailablePassiveActions.Count )); Trace.WriteLine(String.Format( "== {0} Ponyality:\r\n {1}", this.Name, this.Ponyality.ToString() )); // prepare action properties. this.Mode = PonyMode.Free; this.Action = PonyAction.None; this.Direction = PonyDirection.None; // various timers. this.ChoiceTimer = null; this.WindowTimer = null; this.ClingTimer = null; // physical stuff. this.Window = new PonyWindow(this); this.Image = new List <PonyImage>(); // preload action images. this.LoadAllImages(); Trace.WriteLine(String.Format("// {0} says hello", this.Name)); // if a pony can teleport lets let them poof in. if (this.CanDo(PonyAction.Teleport)) { this.LoadImage(PonyAction.Teleport, PonyDirection.Right); this.TeleportStage(); } // else have them walk in from the edge. else { this.LoadImage(PonyAction.Trot, PonyDirection.Right); this.Window.Left = 0 - (this.Window.Width + 10); this.TellWhatDo(PonyAction.Trot, PonyDirection.Right); } this.Window.Show(); }