public async void Run(ChessComponent chess, uint cid, int index, byte color) { if (index < 0 || index > chess.chess.Length) { return; } if (chess.chess[index] != 0) { return; } var players = chess.Slibing <PlayersComponent>(); if (players[players.current] != cid) { return; } chess.chess[index] = color; await world.GetBehavior <Sender>().NotifyAsync(players.Players(), FuncDefine.onPlayed, new SetChessMessage() { color = color, index = index }); if (world.GetBehavior <CheckFiveChess>().Run(chess)) { world.GetBehavior <GameOver>().Run(players, players.current); } else { players.current = 1 - players.current; chess.Slibing <TimeCounterComponent>().add = 0; world.GetBehavior <Playing>().Run(players); } }
public bool isFiveH(ChessComponent chess, int x, int y) { if (x + 5 >= chess.size) { return(false); } for (int i = 0; i < 4; i++) { if (chess[x + i, y] != chess[x + i + 1, y]) { return(false); } } return(true); }
public bool isFiveV(ChessComponent chess, int x, int y) { if (y + 5 >= chess.size) { return(false); } for (int i = 0; i < 4; i++) { if (chess[x, y + i] != chess[x, y + i + 1]) { return(false); } } return(true); }
public bool isFiveNDig(ChessComponent chess, int x, int y) { if (x + 5 >= chess.size) { return(false); } if (y + 5 >= chess.size) { return(false); } for (int i = 0; i < 4; i++) { //Console.WriteLine($"Cur::({x + 4 - i},{ y + i})={chess[x + 4 - i, y + i]},Nx::({x + 4 - i - 1},{ y + i + 1})={chess[x + 4 - i - 1, y + i + 1]}"); if (chess[x + 4 - i, y + i] == 0) { return(false); } if (chess[x + 4 - i, y + i] != chess[x + 4 - i - 1, y + i + 1]) { return(false); } } return(true); }
public bool Run(ChessComponent chess) { var toIndex = world.GetBehavior <PosToIndex>(); for (int x = 0; x < chess.size - 5; x++) { for (int y = 0; y < chess.size - 5; y++) { if (isFiveNDig(chess, x, y)) { Console.WriteLine("isFiveNDig"); return(true); } if (chess[x, y] == 0) { continue; } if (isFiveH(chess, x, y)) { Console.WriteLine("isFiveH"); return(true); } if (isFiveV(chess, x, y)) { Console.WriteLine("isFiveV"); return(true); } if (isFiveDig(chess, x, y)) { Console.WriteLine("isFiveDig"); return(true); } } } return(false); }