void CreateCell(int x, int z, int i) { Vector3 position; position.x = (x + z * 0.5f - z / 2) * (HexMetrics.innerRadius * 2f); position.y = 0f; position.z = z * (HexMetrics.outerRadius * 1.5f); HexCell cell = cells[i] = Instantiate <HexCell>(cellPrefab); cell.transform.SetParent(transform, false); cell.transform.localPosition = position; cell.coordinates = HexCoordinates.FromOffsetCoordinates(x, z); cell.owner = emptyPlayer; cell.units = 3; if (x > 0) { cell.SetNeighbor(HexDirection.W, cells [i - 1]); } if (z > 0) { if ((z & 1) == 0) { cell.SetNeighbor(HexDirection.SE, cells [i - width]); if (x > 0) { cell.SetNeighbor(HexDirection.SW, cells [i - width - 1]); } } else { cell.SetNeighbor(HexDirection.SW, cells [i - width]); if (x < width - 1) { cell.SetNeighbor(HexDirection.SE, cells [i - width + 1]); } } } RectTransform rect = Instantiate <RectTransform>(cellLabelPrefab); rect.SetParent(gridCanvas.transform, false); rect.anchoredPosition = new Vector2(position.x, position.z); CellLabel cellLabel = rect.GetComponent <CellLabel> (); cell.cellLabelRect = cellLabel.unitLabelRect; cell.cellLabelRect = cellLabel.unitLabelRect; cell.upgradeLabel = cellLabel.upgradeLabel; cell.unitText = cellLabel.unitText; cell.goldPerSecondText = cellLabel.goldPerSecondText; cell.progressBar = cellLabel.progressBar; cell.upgradeLabel.GetComponent <UpgradeLabel> ().cell = cell; }
private void PutLabelsOn(List <Vector2Int> positions, string[] labelcontents, string defaultContent = "?") { for (int i = 0; i < positions.Count; i++) { CellLabel newLabel = Instantiate <CellLabel>(labelPrefab); newLabel.SetContent((i < labelcontents.Length ? labelcontents[i] : defaultContent).ToString()); newLabel.SetColor(labelColor2); PutLabelOn(positions[i], newLabel); } }
public void SetStartEndLabels() { CellLabel startLabel = Instantiate <CellLabel>(labelPrefab); startLabel.SetContent("A"); startLabel.SetColor(labelColor1); PutLabelOn(startCell, startLabel); CellLabel endLabel = Instantiate <CellLabel>(labelPrefab); endLabel.SetContent("B"); endLabel.SetColor(labelColor1); PutLabelOn(endCell, endLabel); }
private void PutLabelsOn(List <Vector2Int> positions, char content, bool increment = false) { if (positions == null) { return; } for (int i = 0; i < positions.Count; i++) { CellLabel newLabel = Instantiate <CellLabel>(labelPrefab); newLabel.SetContent(((char)(content + (increment ? i : 0))).ToString()); newLabel.SetColor(labelColor2); PutLabelOn(positions[i], newLabel); } }
private void PutLabelsOn(List <Vector2Int> positions, int startInt) { if (positions == null) { return; } for (int i = 0; i < positions.Count; i++) { CellLabel newLabel = Instantiate <CellLabel>(labelPrefab); newLabel.SetContent(((startInt + i)).ToString()); newLabel.SetColor(labelColor2); PutLabelOn(positions[i], newLabel); } }
private void ClearAllLabels() { foreach (List <GameCell> column in cells) { foreach (GameCell cell in column) { CellLabel label = cell.GetComponentInChildren <CellLabel>(true); if (label != null) { DestroyImmediate(label.gameObject); } } } SetStartEndLabels(); }
void ReleaseDesignerOutlets() { if (AddToBasketBtn != null) { AddToBasketBtn.Dispose(); AddToBasketBtn = null; } if (CellQty != null) { CellQty.Dispose(); CellQty = null; } if (CellLabel != null) { CellLabel.Dispose(); CellLabel = null; } }
private void PutLabelOn(Vector2Int pos, CellLabel label) { GameCell cell = GetCell(pos); if (cell == null) { return; } if (cell.GetComponentInChildren <CellLabel>() == null) { label.transform.parent = cell.transform; label.transform.localPosition = Vector2.zero; } else { cell.GetComponentInChildren <CellLabel>().AddContent(label.Content); Destroy(label.gameObject); } }
// effects: Given an extent's ("extent") table fragment that is // contained inside typeMap, determine the cells that need to be // created and add them to cells // allTypes corresponds to all the different types that the type map // represents -- this parameter has something useful only if extent // is an entity set private void ExtractCellsFromTableFragment( EntitySetBase extent, MappingFragment fragmentMap, Set <EdmType> allTypes, List <Cell> cells) { // create C-query components var cRootExtent = new MemberPath(extent); var cQueryWhereClause = BoolExpression.True; var cSlots = new List <ProjectedSlot>(); if (allTypes.Count > 0) { // Create a type condition for the extent, i.e., "extent in allTypes" cQueryWhereClause = BoolExpression.CreateLiteral(new TypeRestriction(cRootExtent, allTypes), null); } // create S-query components var sRootExtent = new MemberPath(fragmentMap.TableSet); var sQueryWhereClause = BoolExpression.True; var sSlots = new List <ProjectedSlot>(); // Association or entity set // Add the properties and the key properties to a list and // then process them in ExtractProperties ExtractProperties( fragmentMap.AllProperties, cRootExtent, cSlots, ref cQueryWhereClause, sRootExtent, sSlots, ref sQueryWhereClause); // limitation of MSL API: cannot assign constant values to table columns var cQuery = new CellQuery(cSlots, cQueryWhereClause, cRootExtent, CellQuery.SelectDistinct.No /*no distinct flag*/); var sQuery = new CellQuery( sSlots, sQueryWhereClause, sRootExtent, fragmentMap.IsSQueryDistinct ? CellQuery.SelectDistinct.Yes : CellQuery.SelectDistinct.No); var fragmentInfo = fragmentMap; Debug.Assert((fragmentInfo != null), "CSMappingFragment should support Line Info"); var label = new CellLabel(fragmentInfo); var cell = Cell.CreateCS(cQuery, sQuery, label, m_currentCellNumber); m_currentCellNumber++; cells.Add(cell); }
/// <summary> /// Copy Constructor /// </summary> internal CellLabel(CellLabel source) { m_startLineNumber = source.m_startLineNumber; m_startLinePosition = source.m_startLinePosition; m_sourceLocation = source.m_sourceLocation; }
internal CellLabel(CellLabel source) { this.m_startLineNumber = source.m_startLineNumber; this.m_startLinePosition = source.m_startLinePosition; this.m_sourceLocation = source.m_sourceLocation; }