void CreateUI(IUIStyle style, Player player) { var powerUpIcons = new Dictionary <IPowerUp, IUITexture>(); var notFoundIcon = new UITexture(null); var g = new Group(style) { // Name in the top-left corner of the screen new Label(style) { Anchor = AnchoredRect.CreateTopLeftAnchored(10, 10) }.DoWith(l => player.BindingFor(p => p.Name).BindTo(text => l.Text = text)), // Hitpoints in the top-right corner of the screen new Label(style) { Anchor = AnchoredRect.CreateTopRightAnchored(10, 10) }.DoWith(l => player .BindingFor(p => p.HitPoints) .Map(value => $"{value:D}") .BindTo(text => l.Text = text)), // Powerups in the top center of the screen new BoxGroup(style) { Anchor = new AnchoredRect(null, 10, null, null, null, null) } // take the power-ups, map them to textures and build image-widgets. // then we'll add those to a list. .DoWith(bg => player.Inventory.ToBinding() .Map(pu => powerUpIcons[pu] ?? notFoundIcon) .Map(img => new Image(style) { Texture = img }) .Map(w => new WidgetAndConstraint <bool>(w)) .BindTo(bg)) }; }