/// <summary> /// Creates a new cell in this holder of type celltype. /// If type is blocked then it's gonna disable cell by default and the returned cell will be null /// </summary> /// <param name="cellType"></param> /// <param name="animate">Whether to animate the cell or not</param> /// <returns>Return null if the cell could not be created</returns> public Cell NewCell(Cell.CellOcc cellType, bool animate = true) { if (!cell) { // We have a blocking cell, for example a hole filler if (cellType == Cell.CellOcc.BLOCKED) { Disable(); currentTemplate = new CellTemplate(); currentTemplate.cellOcc = cellType; return(null); } cellGameObject = CellPooling.GetCell(); SpriteRenderer sprR = cellGameObject.GetComponent <SpriteRenderer>(); sprR.sortingLayerName = "Signs" + cellType.ToString(); // Set sorting layer for dynamic batching sprR.color = SignResourceStorage.Instance.GetColorRelatedTo(cellType); if (Grid.cellParent != null) { cellGameObject.transform.parent = Grid.cellParent.transform; } // current cell template currentTemplate = new CellTemplate(); currentTemplate.cellOcc = cellType; // Set cell type both for animation and data storage purposes cell = cellGameObject.GetComponent <Cell>(); cell.cellType = cellType; // Animation if (animate) { cell.TriggerDraw(); } else { cell.TriggerIdle(); } // Subtract .five because the center is the pivot (because we want to rotate it to give it better look) cellGameObject.transform.position = GetRandomPosBasedOnWorldPos(); cellGameObject.transform.eulerAngles = GetRandomAngles(); } else { return(null); } return(cell); }
/// <summary> /// Returns it ready for bluetooth use /// </summary> public override string ToString() { string s = points.GetLength(0).ToString() + "#" + winLinePoints[0, 0].ToString() + "#" + winLinePoints[0, 1].ToString() + "#" + winLinePoints[1, 0].ToString() + "#" + winLinePoints[1, 1].ToString() + "#"; for (int i = 0; i < points.GetLength(0); i++) { s += points[i, 0].ToString() + "#" + points[i, 1].ToString() + "#"; } s += winType.ToString(); return(s); }
public override void AddBorderToGame(int[,] points, float[,] winLinePoints, Cell.CellOcc winType) { base.AddBorderToGame(points, winLinePoints, winType); string send = string.Join("", new string[] { GPMessageStrings.ADD_BORDER, "#", points.GetLength(0).ToString(), "#", winLinePoints[0, 0].ToString(), "#", winLinePoints[0, 1].ToString(), "#", winLinePoints[1, 0].ToString(), "#", winLinePoints[1, 1].ToString(), "#" }); StringBuilder sb = new StringBuilder(send); for (int i = 0; i < points.GetLength(0); i++) { for (int k = 0; k < points.GetLength(1); k++) { sb.Append(points[i, k]); sb.Append("#"); } } // No need of # because one is added at the end of the loops sb.Append(winType.ToString()); // Send client the border PlayGamesPlatform.Instance.RealTime.SendMessageToAll(true, Encoding.Unicode.GetBytes(sb.ToString())); }