This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public void Tick(IAgentUpdateInfo agentUpdate) | |
| { | |
| if (agentUpdate.Node.OpposingAgents.Any()) FightOrFlight(agentUpdate); | |
| else SeekEnemiesAndBuffUp(agentUpdate); | |
| } | |
| private void FightOrFlight(IAgentInfo agentInfo) | |
| { | |
| if (IsOutnumbered(agentInfo) || IsOutgunned(agentInfo)) Move(agentInfo, FleeStrategy); | |
| else Fight(agentInfo); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| if (EnemiesOf(self).Any()) | |
| if (!IsConfident(self) && CanMove(self)) Move(self, Fleeing); | |
| else Fight(EnemiesOf(self)); | |
| else if (IsInjured(self)) Heal(); | |
| else if (IsBuffed(self) && CanMove(self)) Move(self, Hunting); | |
| else Buff(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| using System.Threading; | |
| namespace MagicUI.Framework | |
| { | |
| public static class Execute | |
| { | |
| [ThreadStatic] | |
| private static bool _isUiThread; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| interface IUpdaterUI { | |
| void UpdateStatus(int? progress = null, string message = null); | |
| void SoftwareUpdateComplete(); | |
| void DataUpdateComplete(); | |
| } | |
| class MyForm : IUpdaterUI { | |
| public void UpdateStatus(int? progress = null, string message = null) { | |
| if(progress.HasValue) SetProgress(progress.Value); | |
| if(message != null) MessageLabel.Do(ctl => ctl.Text = message); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public interface ISequencerToken | |
| { | |
| bool IsCurrent { get; } | |
| } | |
| public class Sequencer | |
| { | |
| private long _currentToken = 0; | |
| private long Bump() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public interface IConfig | |
| { | |
| string Get(string key); | |
| } | |
| public class Config : IConfig | |
| { | |
| public string Get(string key) | |
| { | |
| var fromConfig = ConfigurationManager.AppSettings[key]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var inputFile = @"whatever.xml"; | |
| var outputFile = @"whatever.updated.xml"; | |
| BlogMLBlog blog; | |
| using (var reader = new StreamReader(inputFile)) | |
| blog = BlogMLSerializer.Deserialize(reader); | |
| var usedNames = new List<string>(); | |
| foreach(var post in blog.Posts.OrderBy(p => p.DateCreated)) | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static class Extensions | |
| { | |
| public static IEnumerable<IEnumerable<T>> Permute<T>(this IEnumerable<T> items) | |
| { | |
| var isEmpty = true; | |
| foreach (var item in items) | |
| { | |
| isEmpty = false; | |
| foreach (var p in items.Except(item.Yield()).Permute()) | |
| yield return item.Yield().Concat(p); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static class Async | |
| { | |
| public static Func<Task<T>> Make<T>(Action<TaskCompletionSource<T>> action) | |
| { | |
| var completionSource = new TaskCompletionSource<T>(); | |
| action(completionSource); | |
| return completionSource.Task; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?xml version="1.0" encoding="UTF-8"?> | |
| <Extract> | |
| <Orders> | |
| <Order DateCreated="2012-03-21" CustomerNumber="1234"> | |
| <OrderLine Qty="2" UnitPrice="15.00" ProductCode="TAC123" /> | |
| <OrderLine Qty="45" UnitPrice="0.15" ProductCode="TAC321" /> | |
| </Order> | |
| <Order DateCreated="2012-03-21" CustomerNumber="5678"> | |
| <OrderLine Qty="9" UnitPrice="27.00" ProductCode="TAC987" /> | |
| </Order> |
OlderNewer