private MovieState Movie(Game2048Chess chess, Vector2Int current, Vector2Int target) { if (chessboardDic[target] == null) { chessboardDic[current] = null; chessboardDic[target] = chess; return(MovieState.Movie); } if (chessboardDic[target].value != chess.value) { chessboardDic[current] = chess; return(MovieState.Stop); } if (chessboardDic[target].isMerge) { chessboardDic[current] = chess; return(MovieState.Stop); } if (chessboardDic[target].value == chess.value) { pool.Recycle(chessboardDic[target].gameObject);//回收 chess.isMerge = true; chess.value = (Game2048ChessType)((int)chess.value * 2); chessboardDic[current] = null; chessboardDic[target] = chess; return(MovieState.Merge); } return(MovieState.Empty); }
public void Spawn(Vector2Int location, Game2048ChessType chessType) { if (chessboardDic.ContainsKey(location) == false) { Debug.LogError("生成位置错误location : " + location.ToString()); return; } if (chessboardDic[location] != null) { Debug.LogError("生成位置错误 该位置有棋子location : " + location.ToString()); return; } Debug.Log("生成位置:" + location.ToString()); Debug.Log("生成值:" + ((int)chessType).ToString()); Game2048Chess chess = pool.Get <Game2048Chess>(); chess.Init(Game2048ChessType.Number_2); chessboardDic[location] = chess; RefreshPosition(); Debug.Log("棋盘状态"); Debug.Log(chessboardDic.GetString()); }
private void Movie(List <Vector2Int> chessList) { for (int i = 1; i < chessList.Count; i++) { if (chessboardDic[chessList[i]] == null) { continue; } Game2048Chess current = chessboardDic[chessList[i]]; chessboardDic[chessList[i]] = null; Movie(chessList, i, current); } }
private void Movie(List <Vector2Int> chessList, int index, Game2048Chess chess) { for (int i = index - 1; i >= 0; i--) { Vector2Int current = chessList[i + 1]; Vector2Int target = chessList[i]; MovieState movieState = Movie(chess, current, target); if (movieState != MovieState.Movie) { break; } } }