コード例 #1
0
		private void setPlayerCrash(bool p1, bool p2){
			List<int[]> newCrash = new List<int[]> ();
			PlayerColor winColor;
            GameOverState winState;

			if (p1 && p2) {
                winState = GameOverState.draw;
				winColor = PlayerColor.None;
				newCrash.Add (new int[]{(int)crashPos[0].x, (int)crashPos[0].y});
				newCrash.Add (new int[]{(int)crashPos[1].x, (int)crashPos[1].y});

            } else {
                winState = GameOverState.playerWon;
                int crashPlayerIndex = p1 ? 0 : 1;
				winColor = master.getIndexColor (p1 ? 1 : 0);
				newCrash.Add (new int[]{(int)crashPos[crashPlayerIndex].x, (int)crashPos[crashPlayerIndex].y});
			}

			int[][] crashes = new int[newCrash.Count] [];
			for (int i = 0; i < newCrash.Count; i++)
				crashes [i] = newCrash [i];

			master.submitToGameLog (SnakeGameLogProtocol.generateCrash(p1, p2, crashPos));
            master.onGameOver(winState, winColor, crashes);
		}
コード例 #2
0
        protected override void displayNewUpdate(GameLogState update)
        {
            if (gameOver)
            {
                return;
            }

            BoardUpdate state = SnakeGameLogProtocol.parseGameState(update.log[0]);

            if (state.gameOver)
            {
                handleAdminGameOver(state);
            }
            else
            {
                handleBoardUpdate(state);
            }
        }
コード例 #3
0
		private void submitToGameLog(){master.submitToGameLog(SnakeGameLogProtocol.generateState(playerPos, dir));}