Exemple #1
0
        public static Entity PushableItemAt(this Pool pool, TilePos position, TilePos moveDirection)
        {
            var newPosition             = position + moveDirection;
            var entitiesAtPosition      = pool.GetEntitiesAt(position, x => x.isBox).ToList();
            var openSpaceAtNextPosition = pool.OpenTileAt(newPosition);
            var stillInsidePuzzle       = pool.IsStillInsideSamePuzzle(position, newPosition);

            return(openSpaceAtNextPosition && stillInsidePuzzle?entitiesAtPosition.SingleOrDefault() : null);
        }
Exemple #2
0
        public static Entity GetEntityAt(this Pool pool, TilePos position, Func <Entity, bool> entityMatcher = null)
        {
            var entitiesAtPosition = pool
                                     .GetEntitiesAt(position, entityMatcher)
                                     .ToList();

            if (entitiesAtPosition.Count() > 1)
            {
                throw new MoreThanOneMatchException(entitiesAtPosition);
            }

            return(entitiesAtPosition.SingleOrDefault());
        }
Exemple #3
0
 public void Execute(List <Entity> entities)
 {
     foreach (var box in entities)
     {
         var pushedToPosition      = box.position.Value + box.knocked.FromDirection;
         var entitiesInFront       = _pool.GetEntitiesAt(pushedToPosition).ToList();
         var blockingAtNewPosition = !entitiesInFront.Any() || entitiesInFront.Any(x => x.isBlockingTile || x.isHero);
         if (!blockingAtNewPosition)
         {
             box.ReplacePosition(pushedToPosition);
         }
         else
         {
             box.IsRocked(true);
         }
     }
 }
Exemple #4
0
        public static bool OpenTileAt(this Pool pool, TilePos position)
        {
            var entitiesAtPosition = pool.GetEntitiesAt(position).ToList();

            return(entitiesAtPosition.Any(x => x.gameObject.Type == ObjectType.Tile) && entitiesAtPosition.All(x => !x.isBlockingTile));
        }