public object Visit(Core.Cell n) { if (root == null || wb == null) { return(false); } var sifLocationElement = root.Element(XName.Get("sifLocation")); n.SifLocation = (sifLocationElement != null) ? sifLocationElement.Value : String.Empty; var contentElement = root.Element(XName.Get("content")); n.Content = (contentElement != null) ? contentElement.Value : String.Empty; //get the user cell name if (n.SifLocation != null && n.SifLocation != String.Empty) { n.Location = CellManager.Instance.GetUserCellNameWithSIFName(wb, n.SifLocation); } //future work: update content return(true); }
/// <summary> /// Replace a cell with an other cell, and delete the old, component and gameobject. /// </summary> /// <param name="source">The source gameobject, can be a prefab or an existing gameObject.</param> /// <param name="grid">The grid of the old cell.</param> /// <param name="old">The old cell to replace.</param> /// <returns>The cell component of the new gameobject.</returns> public static Core.Cell ReplaceCell(GameObject source, Grid3D grid, Core.Cell old) { Undo.SetCurrentGroupName("Replace Cell"); int group = Undo.GetCurrentGroup(); GameObject prefab = source; if (IsGameObjectInstancePrefab(source)) { prefab = GetPrefabFromInstance(source); } GameObject gameObject = PrefabUtility.InstantiatePrefab(prefab, grid.transform) as GameObject; Vector3Int index = old.GetIndex(); gameObject.transform.position = old.transform.position; gameObject.name = gameObject.name + "_" + index.x + "_" + index.y + "_" + index.z; Core.Cell cell = gameObject.GetComponent <Core.Cell>(); if (cell == null) { gameObject.AddComponent <Core.Cell>(); } grid.ReplaceCell(index, cell); Undo.RegisterCreatedObjectUndo(cell.gameObject, "Cell replaced"); Undo.DestroyObjectImmediate(old.gameObject); Undo.CollapseUndoOperations(group); /***** my code ******/ cell.tileX = index.x; cell.tileY = index.z; /********************/ return(cell); }
void OnValueChanged(object sender, Core.Cell e) { if (_info.Root.PageSetting.IsValid()) { _info.OnPageSettingChanged(); } }
/// <summary> /// Destroy a cell with his gameobject. Do nothing if not instantiated. /// </summary> /// <param name="cell"></param> public static void DestroyCell(Core.Cell cell) { if (IsGameObjectInstancePrefab(cell.gameObject)) { Undo.DestroyObjectImmediate(cell.gameObject); } }
public static void DebugEmptyCell(Core.Cell cell, GizmoType gizmoType) { if (LayerMask.NameToLayer("EmptyCell") == cell.gameObject.layer) { DebugCell(cell.GetIndex(), cell.GetGridParent(), DebugsColor.empty_cell, -0.01f); } }
public void GivenAliveCell_WhenReproduces_IsStillAlive() { Core.Cell cell = new Core.Cell(CellState.alive); cell.ReproduceCell(); Assert.True(cell.State == CellState.alive); }
public void GivenDeadCell_WhenKilled_IsStillDead() { Core.Cell cell = new Core.Cell(CellState.dead); cell.KillCell(); Assert.True(cell.State == CellState.dead); }
public object Visit(Core.Cell n) { var root = new XElement("cell"); root.Add(new XElement("sifLocation", n.SifLocation)); root.Add(new XElement("content", n.Content)); return(root); }
public Core.Cell ToCell(Grid3D grid) { GameObject prefab = AssetDatabase.LoadAssetAtPath <GameObject>(_pathPrefab); Core.Cell cell = FuncEditor.InstantiateCell(prefab, grid, _index); cell.transform.localPosition = _localposition; cell.transform.localRotation = Quaternion.Euler(_localrotation); cell.transform.localScale = _localscale; return(cell); }
public CellDTO(Core.Cell cell) { GameObject prefab = FuncEditor.GetPrefabFromInstance(cell.gameObject); _pathPrefab = PrefabUtility.GetPrefabAssetPathOfNearestInstanceRoot(prefab); _index = cell.GetIndex(); _localposition = cell.transform.localPosition; _localrotation = cell.transform.localRotation.eulerAngles; _localscale = cell.transform.localScale; }
public override Queue <Vector3Int> Modify(Grid3D grid, Vector3Int index) { Queue <Vector3Int> newIndexes = new Queue <Vector3Int>(); Core.Cell root = grid.TryGetCellByIndex(ref index); Vector3Int upIndex = index + Vector3Int.up; Core.Cell up = grid.TryGetCellByIndex(ref upIndex); if (root == null) { return(null); } List <Core.Cell> neighb = grid.GetNeighboursCell(ref index); foreach (Core.Cell cell in neighb) { if (cell.GetIndex().y == index.y) { newIndexes.Enqueue(cell.GetIndex()); } } Vector3Int downIndex = index + Vector3Int.down; Core.Cell down = grid.TryGetCellByIndex(ref downIndex); int otherLayerCount = up != null ? down != null ? 2 : 1 : 0; int arity = (neighb.Count - otherLayerCount); if (_low_pass_arity < arity && arity <= _high_pass_arity) { return(newIndexes); } if (up != null) { _to_delete.Enqueue(root); } return(newIndexes); }
public object Visit(Core.WorkbookModel n) { if (root == null) return false; //get input cells var inputCellsElement = root.Element(XName.Get("inputCells")); if (inputCellsElement != null) { foreach (var c in inputCellsElement.Elements()) { var inputCell = new Core.Cell(); inputCell.Accept(new XMLToCellDefinitionVisitor(c, n)); n.InputCells.Add(inputCell.ToInputCell()); } } //get intermediate cells var intermediateCellsElement = root.Element(XName.Get("intermediateCells")); if (intermediateCellsElement != null) { foreach (var c in intermediateCellsElement.Elements()) { var intermediateCell = new Core.Cell(); intermediateCell.Accept(new XMLToCellDefinitionVisitor(c, n)); n.IntermediateCells.Add(intermediateCell.ToIntermediateCell()); } } //get result cells var resultCellsElement = root.Element(XName.Get("resultCells")); if (resultCellsElement != null) { foreach (var c in resultCellsElement.Elements()) { var resultCell = new Core.Cell(); resultCell.Accept(new XMLToCellDefinitionVisitor(c, n)); n.OutputCells.Add(resultCell.ToOutputCell()); } } return true; }
/// <summary> /// Instantiate a cell with a prefab as model. /// </summary> /// <param name="prefab">The prefab to instantiate as a cell.</param> /// <param name="grid">The grid the cell will belongs.</param> /// <param name="index"> The index of the cell.</param> /// <returns>The cell component associated to the gameobject.</returns> public static Core.Cell InstantiateCell(GameObject prefab, Grid3D grid, Vector3Int index) { GameObject gameObject = PrefabUtility.InstantiatePrefab(prefab, grid.transform) as GameObject; gameObject.name = index.x + "_" + index.y + "_" + index.z + "_" + gameObject.name; Core.Cell cell = gameObject.GetComponent <Core.Cell>(); if (cell == null) { cell = gameObject.AddComponent <Core.Cell>(); } grid.AddCell(index, cell); cell.ResetTransform(); /***** my code ******/ cell.tileX = index.x; cell.tileY = index.z; /********************/ Undo.RegisterCreatedObjectUndo(cell.gameObject, "Cell created"); return(cell); }
/// <summary> /// Stamp cells is to copy and paste a list of cell to an other location. /// </summary> /// <param name="listCell"> The list of cells to copy.</param> /// <param name="grid"> The grid in which place the copy.</param> /// <param name="displacement"> The displacement relative to the current position of cells.</param> /// <param name="overwrite"> Option if we overwrite an existing cell at destination of copy</param> public static void StampCells(List <Core.Cell> listCell, Grid3D grid, Vector3Int destinationIndex, bool overwrite = true) { Vector3Int displacement = destinationIndex - listCell[0].GetIndex(); foreach (Core.Cell c in listCell) { Vector3Int index = displacement + c.GetIndex(); Core.Cell cdest = grid.TryGetCellByIndex(ref index); GameObject prefabInstance = c.gameObject; GameObject prefab = GetPrefabFromInstance(prefabInstance); if (cdest == null) { InstantiateCell(prefab, grid, index); } else if (overwrite) { ReplaceCell(prefab, grid, cdest); } } }
public object Visit(Core.Cell n) { if (this.root == null) { return(false); } var idElement = root.Element(XName.Get("ID")); n.Id = (idElement != null) ? Convert.ToInt32(idElement.Value) : 1; var contentElement = root.Element(XName.Get("Content")); n.Content = (contentElement != null) ? contentElement.Value : String.Empty; var locationElement = root.Element(XName.Get("Location")); n.Location = (locationElement != null) ? contentElement.Value : String.Empty; return(true); }
/// <summary> /// 记录报表项属性值变化,提供可撤消和重做功能 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void OnItemValueChanged(object sender, Core.Cell e) { History.RecordAction(new HistoryCmdAction(RptCmds.ValueChanged, new ValueChangedArgs(e, sender as RptText))); OnCellValueChanged(sender, null); }
public Set(int size) { this.Size = size; Values = new HashSet <int>(); Cells = new Core.Cell[Size]; }
/// <summary> /// Gizmo for debuging the neighbours of a cell. /// </summary> /// <param name="cell">The cell use to compute neighbours.</param> /// <param name="color">Color of the gizmo.</param> /// <param name="offsetSize"> The scale amount add to the grid size cell.</param> public static void DebugNeigbours(Core.Cell cell, Color color, float offsetSize = 0.01f) { DebugNeigbours(cell.GetIndex(), cell.GetGridParent(), color, offsetSize); }
public object Visit(Core.Cell n) { throw new NotImplementedException(); }
/// <summary> /// 文本项属性值变化 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void OnTextChanged(object sender, Core.Cell e) { Invoke(() => { LoadText((RptText)sender); }); }
public object Visit(Core.WorkbookModel n) { if (root == null) { return(false); } //get input cells var inputCellsElement = root.Element(XName.Get("inputCells")); if (inputCellsElement != null) { foreach (var c in inputCellsElement.Elements()) { var inputCell = new Core.Cell(); inputCell.Accept(new XMLToCellDefinitionVisitor(c, n)); n.InputCells.Add(inputCell.ToInputCell()); } } //get intermediate cells var intermediateCellsElement = root.Element(XName.Get("intermediateCells")); if (intermediateCellsElement != null) { foreach (var c in intermediateCellsElement.Elements()) { var intermediateCell = new Core.Cell(); intermediateCell.Accept(new XMLToCellDefinitionVisitor(c, n)); n.IntermediateCells.Add(intermediateCell.ToIntermediateCell()); } } //get result cells var resultCellsElement = root.Element(XName.Get("resultCells")); if (resultCellsElement != null) { foreach (var c in resultCellsElement.Elements()) { var resultCell = new Core.Cell(); resultCell.Accept(new XMLToCellDefinitionVisitor(c, n)); n.OutputCells.Add(resultCell.ToOutputCell()); } } //get sanity value cells var sanityValueCellsElement = root.Element(XName.Get("sanityValueCells")); if (sanityValueCellsElement != null) { foreach (var c in sanityValueCellsElement.Elements()) { var sanityValueCell = new Core.Cell(); sanityValueCell.Accept(new XMLToCellDefinitionVisitor(c, n)); n.SanityValueCells.Add(sanityValueCell.ToSanityValueCell()); } } //get sanity value cells var sanityConstraintCellsElement = root.Element(XName.Get("sanityConstraintCells")); if (sanityConstraintCellsElement != null) { foreach (var c in sanityConstraintCellsElement.Elements()) { var sanityConstraintCell = new Core.Cell(); sanityConstraintCell.Accept(new XMLToCellDefinitionVisitor(c, n)); n.SanityConstraintCells.Add(sanityConstraintCell.ToSanityConstraintCell()); } } //get sanity Explanation cells var sanityExplanationCellsElement = root.Element(XName.Get("sanityExplanationCells")); if (sanityExplanationCellsElement != null) { foreach (var c in sanityExplanationCellsElement.Elements()) { var sanityExplanationCell = new Core.Cell(); sanityExplanationCell.Accept(new XMLToCellDefinitionVisitor(c, n)); n.SanityExplanationCells.Add(sanityExplanationCell.ToSanityExplanationCell()); } } //get sanity Checking cells var sanityCheckingCellsElement = root.Element(XName.Get("sanityCheckingCells")); if (sanityCheckingCellsElement != null) { foreach (var c in sanityCheckingCellsElement.Elements()) { var sanityCheckingCell = new Core.Cell(); sanityCheckingCell.Accept(new XMLToCellDefinitionVisitor(c, n)); n.SanityCheckingCells.Add(sanityCheckingCell.ToSanityCheckingCell()); } } return(true); }
private void OnEnable() { _cell = (Core.Cell)target; }