Example #1
0
 private IEnumerable <IGameAction> GetPossibleMoveActions()
 {
     for (var index = 0; index < MyUnits.Count; index++)
     {
         var unit = MyUnits[index];
         if (unit.X < 0)
         {
             continue;
         }
         foreach (var moveDir in Directions.All8)
         {
             var dest = unit + moveDir;
             if (CanMove(unit, dest))
             {
                 foreach (var buildDir in Directions.All8)
                 {
                     var build = dest + buildDir;
                     if (build.InArea(Size) &&
                         HeightAt(build) < 4 &&
                         !AllUnits.Any(u => u != unit && u.Equals(build)))
                     {
                         var action = new MoveAndBuildAction(index, moveDir, buildDir);
                         EnsureMoveValid(action);
                         yield return(action);
                     }
                 }
             }
         }
     }
 }
 protected bool Equals(MoveAndBuildAction other)
 {
     return(BuildDirection == other.BuildDirection && MoveDirection == other.MoveDirection && UnitIndex == other.UnitIndex);
 }