private void Movie(Vector2Int vector) { foreach (var item in chessboardDic) { if (item.Value != null) { item.Value.isMerge = false; } } for (int i = 0; i < chessboardlength; i++) { List <Vector2Int> chessList = GetChessList(vector, i); Debug.Log("获取棋盘一列数据"); Debug.Log(chessList.GetString()); Movie(chessList); Debug.Log("一列数据移动后"); Debug.Log(chessboardDic.GetString()); } Movie(); VPTimer.In(0.4f, () => { gameState = Game2048GameState.Build; SwitchState(); }); //Debug.Log(chessboardDic.GetString()); }
private void SwitchState() { Debug.Log("当前游戏状态:" + gameState.ToString()); switch (gameState) { case Game2048GameState.Begin: Init(); gameState = Game2048GameState.Build; SwitchState(); break; case Game2048GameState.Build: Spawn(); VPTimer.In(0.5f, () => { SwitchState(); }); break; case Game2048GameState.Movie: break; case Game2048GameState.IsGameOver: break; default: break; } }
public Game2048ChessboardData(int[,] chessboard, Game2048GameState gameState) { chessboardDic = new Dictionary <Vector2Int, Game2048ChessData>(); for (int i = 0; i < chessboard.GetLength(0); i++) { for (int j = 0; j < chessboard.GetLength(1); j++) { Game2048ChessData chessData = null; if (chessboard[j, i] != 0) { chessData = new Game2048ChessData(chessboard[j, i]); } chessboardDic.Add(new Vector2Int(i, j), chessData); } } this.gameState = gameState; }
private void SwitchState(Game2048GameState gameState) { this.gameState = gameState; switch (this.gameState) { case Game2048GameState.Begin: OnBegin(); break; case Game2048GameState.Build: OnBuild(); break; case Game2048GameState.IsGameOver: OnIsGameOver(); break; case Game2048GameState.Movie: break; default: break; } }
private void NewGame() { gameState = Game2048GameState.Begin; SwitchState(); }