// Connect this board space with another, creating a line between them public void Connect(BoardSpace space) { Vector3 lineStart = GetScreenPosition(); Vector3 lineEnd = space.GetScreenPosition(); ConnectionLine line = connectionLines.GetUnusedLine(); line.SetPoints(lineStart, lineEnd); connectedSpaces.Add(space); }
// Line from the last connected space to the touch position void UpdateLine(Vector3 touchPos) { if (!currentDotLink.IsEmpty()) { BoardSpace lastConnected = currentDotLink.lastConnected; Vector3 lineStart = lastConnected.GetScreenPosition(); touchLine.SetType(lastConnected.GetCurrentDot().GetDotType()); touchLine.SetPoints(lineStart, touchPos); } }
// Search the possbile spaces for one close enough to the touch BoardSpace FindSpace(Vector3 touchPos, List <BoardSpace> possibleSpaces) { for (int i = 0; i < possibleSpaces.Count; i++) { BoardSpace curSpace = possibleSpaces[i]; float touchDist = Vector3.Distance(touchPos, curSpace.GetScreenPosition()); if (touchDist < board.DotTouchDistance) { return(curSpace); } } return(null); }
// Find valid space, searching all board spaces for one close enough to the touch BoardSpace FindFirstSpace(Vector3 touchPos) { List <List <BoardSpace> > boardArray = board.BoardArray; for (int i = 0; i < boardArray.Count; i++) { for (int k = 0; k < boardArray[i].Count; k++) { BoardSpace curSpace = boardArray[i][k]; float touchDist = Vector3.Distance(touchPos, curSpace.GetScreenPosition()); if (touchDist < board.DotTouchDistance) { return(curSpace); } } } return(null); }