Ejemplo n.º 1
0
        public bool Move()
        {
            var newPositions = new Position[body.Count];

            for (int i = 1; i < newPositions.Length; i++)
            {
                newPositions[i] = body[i - 1].Position;
            }

            newPositions[0] = body[0].Position.GetRelativePosition(MovementDirection, 1);

            for (int i = 0; i < body.Count; i++)
            {
                try
                {
                    if (!board.MoveEntity(body[i], newPositions[i]))
                    {
                        foreach (var entity in body)
                        {
                            board.EditEntities(entity, EditOperation.Delete);
                        }

                        return(false);
                    }
                }
                catch (IndexOutOfRangeException ex) { return(true); }
            }

            return(true);
        }