public virtual CCell3D[] GetLineNeighbours(CCell3D cell) { var results = new List <CCell3D>(); for (int x = 0; x < this.m_GridCells.GetLength(0); x++) { if (this.m_Grid[x, cell.y, cell.z] <= 0) { results.Add(this.m_GridCells[x, cell.y, cell.z]); } } for (int y = 0; y < this.m_GridCells.GetLength(1); y++) { if (this.m_Grid[cell.x, y, cell.z] <= 0) { results.Add(this.m_GridCells[cell.x, y, cell.z]); } } for (int z = 0; z < this.m_GridCells.GetLength(2); z++) { if (this.m_Grid[cell.x, cell.y, z] <= 0) { results.Add(this.m_GridCells[cell.x, cell.y, z]); } } return(results.ToArray()); }
public virtual void DrawLineCell(CCell3D cell1, CCell3D cell2) { var line = this.CreateLine(); line.positionCount = 2; line.SetPosition(0, cell1.GetPosition()); line.SetPosition(1, cell2.GetPosition()); }
public virtual void SetActiveGrid(bool value) { this.m_ActiveGrid = value; if (value == false) { this.m_Item1 = null; this.m_Item2 = null; } }
public virtual int GetLineNeighboursNonAlloc(CCell3D cell, ref CCell3D[] results) { var x = 0; var y = 0; var z = 0; for (int i = 0; i < results.Length; i++) { results[i] = null; } for (x = 0; x < this.m_GridCells.GetLength(0); x++) { if (this.m_Grid[x, cell.y, cell.z] <= 0) { results[x] = this.m_GridCells[x, cell.y, cell.z]; } } for (y = 0; y < this.m_GridCells.GetLength(1); y++) { if (this.m_Grid[x, cell.y, cell.z] <= 0) { results[x + y] = this.m_GridCells[x, cell.y, cell.z]; } } for (z = 0; z < this.m_GridCells.GetLength(2); z++) { if (this.m_Grid[x, cell.y, cell.z] <= 0) { results[x + y + z] = this.m_GridCells[x, cell.y, cell.z]; } } var resultCount = 0; for (int i = 0; i < results.Length; i++) { for (int j = i + 1; j < results.Length; j++) { var right = results[j]; if (results[i] == null && right != null) { results[i] = right; results[j] = null; break; } } resultCount = results[i] != null ? resultCount + 1 : resultCount; } return(resultCount); }
public bool CheckCell(CCell3D cell1, CCell3D cell2, bool isCheckRoot = false) { if (cell1.y == cell2.y && cell1.z == cell2.z) { return(this.CheckXWith(cell1.x + 1, cell2.x - 1, cell1.y, cell1.z)); } if (cell1.x == cell2.x && cell1.z == cell2.z) { return(this.CheckYWith(cell1.y + 1, cell2.y - 1, cell1.x, cell1.z)); } if (cell1.x == cell2.x && cell1.y == cell2.y) { return(this.CheckZWith(cell1.z + 1, cell2.z - 1, cell1.x, cell1.y)); } return(true); }
public void SubmitCell(CCell3D value) { this.ResetLines(); if (this.m_Item1 == null) { this.m_Item1 = value; } else if (this.m_Item2 == null) { if (this.m_Item1 != value) { this.m_Item2 = value; } else { this.m_Item1 = null; this.m_Item2 = null; } } if (this.m_Item1 != null && this.m_Item2 != null) { if (this.CheckRect( this.m_Item1.x, this.m_Item1.y, this.m_Item1.z, this.m_Item2.x, this.m_Item2.y, this.m_Item2.z )) { this.m_Grid[this.m_Item1.x, this.m_Item1.y, this.m_Item1.z] = 0; this.m_Grid[this.m_Item2.x, this.m_Item2.y, this.m_Item2.z] = 0; this.m_GridCells[this.m_Item1.x, this.m_Item1.y, this.m_Item1.z].SetActive(false); this.m_GridCells[this.m_Item2.x, this.m_Item2.y, this.m_Item2.z].SetActive(false); this.m_LineCounter = this.m_LineTimer; } this.m_Item1 = null; this.m_Item2 = null; if (this.IsCheckCompleteGrid()) { this.OnCompleteGrid(); } } }
public bool CheckPhysicCell(CCell3D cell1, CCell3D cell2, bool isCheckRoot = false) { var origin = cell1.transform.position; var direction = cell2.transform.position - origin; RaycastHit hitInfo; var result = Physics.Raycast( origin, direction, out hitInfo, direction.magnitude, this.m_CellLayerMask ); if (isCheckRoot) { var cellCollider = hitInfo.collider.GetComponent <CCell3D>(); return(result && cellCollider.name == cell2.name); } else { return(!result); } }
public CPoint3D(CPoint3D point, CCell3D cell) { this.point = point; this.cell = cell; }
public CPoint3D() { this.point = null; this.cell = null; }
public CPoint3D(CCell3D cell) { this.point = null; this.cell = cell; }
public virtual int GetNeighboursNonAlloc(CCell3D cell, ref CCell3D[] results) { return(this.GetNeighbours(cell.x, cell.y, cell.z, ref results)); }
public virtual CCell3D[] GetNeighbours(CCell3D cell) { return(this.GetNeighbours(cell.x, cell.y, cell.z)); }