// 이미 매치된 타일에 대한 처리 과정 private void mergeMachedInfo(MatchInfo findinfo, Tile tile) { // 해당 매치를 찾아, 이전 데이터와 합치기 var matchedInfo = findMatchInfo(tile.row, tile.col); if (matchedInfo == null) { return; } Debug.LogFormat("교차점[{0},{1}] 발견", tile.row, tile.col); if (matchedInfo.isLinearMatch) // 교차되면서 매치를 하나로 합치기 { findinfo.direction |= matchedInfo.direction; findinfo.AddTilePosition(matchedInfo); matchInfos.Remove(matchedInfo); findinfo.creationPos = tile.GetLocation(); } // 타일 위치의 중복을 허용하면서 현재는 이에 대한 검증이 안되어 있음. else if (matchedInfo.matchType == MatchType.Butterfly) { Debug.LogFormat("나비 발견."); if (findinfo.isCreationTile && findinfo.matchType != MatchType.Butterfly) { resetMatchedInfo(matchedInfo); findinfo.AddTilePosition(tile.GetLocation()); matchInfos.Remove(matchedInfo); } } else { findinfo.AddTilePosition(tile.GetLocation()); } }
public bool SwapTile(Tile src, Tile dst) { var srcPos = src.GetLocation(); var dstPos = dst.GetLocation(); // 둘이 바뀌었다고 가정하고 두 인접 타일에 대해 확인을 해야한다. tiles[srcPos.row, srcPos.col] = dst; tiles[dstPos.row, dstPos.col] = src; bool isMatch = (IsSwapable(srcPos.row, srcPos.col) || IsSwapable(dstPos.row, dstPos.col)); // 위 함수 대신 매치 정보를 포함하는 src.MoveSwap(dst, !isMatch); if (isMatch) { // 애니메이션 처리 전에 검사 src.SwapLocation(dst); // 순서 테스트. int cntMatch = _matchingChecker.FindMatches(new Point2D[] { srcPos, dstPos }); // src.SwapLocation(dst); // // 필요한 경우 시그널 생성 Debug.LogFormat($"매치! ({cntMatch})"); return(true); } else { tiles[srcPos.row, srcPos.col] = src; tiles[dstPos.row, dstPos.col] = dst; //Debug.LogFormat("교환하지 않음. yoyo 발생"); return(false); } }
public void SwapLocation(Tile tile) { var tmpLocation = tile.GetLocation(); Debug.LogFormat($"[{location.row},{location.col}]과 [{tmpLocation.row},{tmpLocation.col}] 교환"); // 로케이션 교환 tile.SetLocation(location); location = tmpLocation; }
public Tile GetAdjacentTile(Tile tile, TileMovement move) { var location = tile.GetLocation(); Tile adjTile = null; if (move == TileMovement.Up && location.row > 0) { adjTile = tiles[location.row - 1, location.col]; } else if (move == TileMovement.Down && location.row < GetLastIndexRow()) { adjTile = tiles[location.row + 1, location.col]; } else if (move == TileMovement.Left && location.col > 0) { adjTile = tiles[location.row, location.col - 1]; } else if (move == TileMovement.Right && location.col < GetLastIndexCol()) { adjTile = tiles[location.row, location.col + 1]; } return(adjTile); }
void OnMouseDown() { pos = Input.mousePosition; Debug.Log($"OnMouseDown [{refTile.GetLocation().row}, {refTile.GetLocation().col}] {gameObject.name}, {gameObject.GetHashCode()}"); }