Beispiel #1
0
 private IEnumerable <IGameAction> GetPossiblePushActions()
 {
     for (var index = 0; index < MyUnits.Count; index++)
     {
         var unit = MyUnits[index];
         if (unit.X < 0)
         {
             continue;
         }
         foreach (var targetDir in Directions.All8)
         {
             var target = unit + targetDir;
             if (HisUnits.Any(u => u.X >= 0 && u.Equals(target)))
             {
                 foreach (var pushDir in targetDir.PushDirections())
                 {
                     if (CanMove(target, target + pushDir))
                     {
                         var action = new PushAndBuildAction(index, targetDir, pushDir);
                         EnsureMoveValid(action);
                         yield return(action);
                     }
                 }
             }
         }
     }
 }
 protected bool Equals(PushAndBuildAction other)
 {
     return(PushDirection == other.PushDirection && TargetDirection == other.TargetDirection && UnitIndex == other.UnitIndex);
 }