public void PrintState(RowConfig shipRowConfig, int shipStep) { foreach (RowConfig rowConfig in rowConfigs) { StringBuilder sb = new StringBuilder(); List <Step> steps = rows[rowConfig]; for (int stepId = 0; stepId < steps.Count; stepId++) { Step step = steps[stepId]; if (shipRowConfig == rowConfig && shipStep == stepId) { sb.Append("X"); } else if (step.hazard != null) { sb.Append(step.hazard.letter); } else { sb.Append("O"); } } Debug.Log(sb.ToString()); } }
/// <summary> /// Renders a Bootstrap form row. /// </summary> /// <param name="htmlHelper">Html helper instance.</param> /// <param name="configAction">Action that implements form row configuration.</param> public static IHtmlContent MvcCoreBootstrapFormRow(this IHtmlHelper htmlHelper, Action <MvcCoreBootstrapFormRowBuilder> configAction) { RowConfig config = new RowConfig(); MvcCoreBootstrapFormRowBuilder builder = new MvcCoreBootstrapFormRowBuilder(config); configAction(builder); return(new RowRenderer(config).Render()); }
public RowConfig GetRowRightNeighbor(RowConfig row) { int rowIdx = GetRowIndex(row); if (rowIdx < rowConfigs.Count - 1) { return(rowConfigs[rowIdx + 1]); } return(null); }
public RowConfig GetRowLeftNeighbor(RowConfig row) { int rowIdx = GetRowIndex(row); if (rowIdx > 0) { return(rowConfigs[rowIdx - 1]); } return(null); }
public int GetDistanceBeteenRows(RowConfig rowA, RowConfig rowB) { int distance = -1; int rowAIdx = GetRowIndex(rowA); int rowBIdx = GetRowIndex(rowB); if (rowAIdx >= 0 && rowBIdx >= 0) { distance = Mathf.Abs(rowAIdx - rowBIdx); } return(distance); }
public int GetRowIndex(RowConfig row) { int index = -1; for (int i = 0; i < rowConfigs.Count; i++) { if (rowConfigs[i] == row) { return(i); } } return(index); }
public SubManager.MoveDirection GetHeading(RowConfig from, RowConfig to) { if (from == to) { return(SubManager.MoveDirection.STRAIGHT); } if (GetRowIndex(from) > GetRowIndex(to)) { return(SubManager.MoveDirection.LEFT); } else { return(SubManager.MoveDirection.RIGHT); } }
public Step GetStep(RowConfig rowConfig, int stepId) { Step step = null; if (rows.ContainsKey(rowConfig)) { List <Step> row = rows[rowConfig]; if (stepId < row.Count) { step = row[stepId]; } } return(step); }
public void ChangeHeading(MoveDirection direction) { RowConfig checkRow = null; if (direction == MoveDirection.LEFT) { checkRow = stage.GetRowLeftNeighbor(position.nextRow); } else if (direction == MoveDirection.RIGHT) { checkRow = stage.GetRowRightNeighbor(position.nextRow); } if (checkRow != null) { // If the distance between our current row, and the next potential row // is less than or equal to our maximum movement, go ahead and move if (stage.GetDistanceBeteenRows(position.row, checkRow) <= stats.maxRowMovement) { position.nextRow = checkRow; SetHeading(); } } }
internal MvcCoreBootstrapFormRowBuilder(RowConfig config) { _config = config; }
public void Rows(bool values, bool rowClick, bool globalRowClick) { TableEntity entity = new TableEntity { Property = "Value1", Property2 = values ? "Value2" : null, Property3 = 123, }; RowConfig <TableEntity> row = new RowConfig <TableEntity>(entity) { State = values ? ContextualState.Danger : ContextualState.Default, NavigationUrl = values ? "NavUrl" : null, RowClick = rowClick ? "RowClick" : null, }; if (values) { row.CssClasses.Add("C1"); row.CssClasses.Add("C2"); row.CellConfigs.Add("Property", new CellConfig { State = ContextualState.Warning }); row.CellConfigs.ElementAt(0).Value.CssClasses.Add("Css1"); row.CellConfigs.ElementAt(0).Value.CssClasses.Add("Css2"); } _tableConfig.RowClick.Returns(globalRowClick ? "GlobalRowClick" : null); _tableConfig.Rows.Returns(new[] { new RowConfig <TableEntity>(new TableEntity()), row, new RowConfig <TableEntity>(new TableEntity()), }); this.ActAndValidate(); TableNode body = this.Node("tbody"); body.Should().NotBeNull(); body.InnerContent.Should().HaveCount(3); body.InnerContent.Select(ic => ic.Element.TagName).Should().OnlyContain(tn => tn == "tr"); for (int i = 0; i < body.InnerContent.Count; i++) { TableNode rowNode = body.InnerContent.ElementAt(i); List <string> cssClasses = new List <string>(_tableConfig.Rows.ElementAt(i).CssClasses); bool rowValues = i == 1 && values; if (rowValues) { cssClasses.Add("danger"); } this.VerifyCssClasses(rowNode.Element, cssClasses); this.VerifyAttribute(rowNode.Element, "style", rowValues || (i == 1 && rowClick) || globalRowClick ? "cursor: pointer" : null); if (rowValues) { this.VerifyAttribute(rowNode.Element, "onclick", "window.location.href = 'NavUrl'"); } else if (i == 1 && rowClick) { this.VerifyAttribute(rowNode.Element, "onclick", "RowClick"); } else if (globalRowClick) { this.VerifyAttribute(rowNode.Element, "onclick", "GlobalRowClick(this)"); } else { this.VerifyAttribute(rowNode.Element, "onclick"); } rowNode.InnerContent.Should().HaveCount(3); rowNode.InnerContent.Select(ic => ic.Element.TagName).Should().OnlyContain(tn => tn == "td"); if (i == 1) { this.VerifyInnerHtml(rowNode.InnerContent.ElementAt(0).Element, entity.Property); this.VerifyInnerHtml(rowNode.InnerContent.ElementAt(1).Element, values ? entity.Property2 : string.Empty); this.VerifyInnerHtml(rowNode.InnerContent.ElementAt(2).Element, entity.Property3.ToString()); this.VerifyCssClasses(rowNode.InnerContent.ElementAt(0).Element, values ? new[] { "warning", "Css1", "Css2" } : Enumerable.Empty <string>()); this.VerifyCssClasses(rowNode.InnerContent.ElementAt(1).Element, Enumerable.Empty <string>()); this.VerifyCssClasses(rowNode.InnerContent.ElementAt(2).Element, Enumerable.Empty <string>()); } } }
public RowRenderer(RowConfig config) { _config = config; }
internal RowBuilder(T entity, IBuilderFactory builderFactory) { _builderFactory = builderFactory; Config = new RowConfig <T>(entity); }
internal Row(RowConfig config) { _config = config; }
internal MvcCoreBootstrapTableRowBuilder(T entity, IBuilderFactory builderFactory) { _builderFactory = builderFactory; Config = new RowConfig(entity); }