// Use this for initialization void Start() { togglePressed(); setMoveSpeed(); TCPLocalConnection.startServer(4000); SinglePlayerGameMaster.init(takeInput, () => {}); }
public void requestMove(NetworkMessage boardMsg) { byte[] bytes = boardMsg.reader.ReadBytesAndSize(); string msg = Game.ClientController.Deserialize <Game.CommProtocol.StringMessage> (bytes).msg; TCPLocalConnection.sendMessage(msg); }
public void handleGameInfo(NetworkMessage msg) { byte[] bytes = msg.reader.ReadBytesAndSize(); GameInfo infoMsg = Game.ClientController.Deserialize <GameInfo> (bytes);; if (infoMsg.gameOver) { string gameOverString = TCP_API.APIStandardConstants.Fields.gameOver; TCPLocalConnection.sendMessage(gameOverString); isGameOver = true; UnetRoomConnector.shutdownCurrentConnection(); string gameOverMsg; if (infoMsg.winnerColor == Game.PlayerColor.None) { gameOverMsg = "It's a draw!"; } else { gameOverMsg = infoMsg.winnerColor + " won"; } CurrentGame.gameOver(gameOverMsg); } }
public void handleGameStatus(NetworkMessage gameStatusMsg) { byte[] bytes = gameStatusMsg.reader.ReadBytesAndSize(); GameInfo msg = ClientController.Deserialize <GameInfo> (bytes); if (msg.gameOver) { string gameOverString = TCP_API.APIStandardConstants.Fields.gameOver; TCPLocalConnection.sendMessage(gameOverString); gameOver(); waitingForInput = false; string gameOverMsg; if (msg.winnerColor == PlayerColor.None) { gameOverMsg = "It's a draw!"; } else { gameOverMsg = msg.winnerColor + " won"; } CurrentGame.gameOver(gameOverMsg); } }
private void simulateFree(List <MemorySegment> allocList) { int freePos = allocList [Random.Range(0, allocList.Count - 1)].pos; TCPLocalConnection.sendMessage("Free " + freePos); print("Free " + freePos); }
public void restartGame() { foreach (GameObject g in discs) { Destroy(g); } discs.Clear(); foreach (TowerPole tp in poles) { tp.amountOfDiscs = 0; } board.Clear(); board.Add(new List <int> ()); board.Add(new List <int> ()); board.Add(new List <int> ()); for (int i = 0; i < (int)amountSlider.value; i++) { discs.Add(Instantiate(discPrefab, poles [0].addDisc(), Quaternion.identity)); discs [discs.Count - 1].GetComponent <TowerDisc> ().init(materials [i], i); board [0].Add(i); } moveCounter = 0; wonGame = false; TCPLocalConnection.sendMessage(formatBoard()); }
public static void init(GameConnectorUI connector) { gameConnector = connector; TCPLocalConnection.subscribeToTCPStatus(TCPStatusChanged); ClientUIOverlord.onUIStateChanged += UIStateChanged; Msf.Server.SetHandler((short)ServerCommProtocl.GameRoomInvite, handleStartGame); }
private void simulateMalloc(List <MemorySegment> freeList) { int allocationSize = calcAllocSize(); TCPLocalConnection.sendMessage("Malloc " + allocationSize); print("Malloc " + allocationSize); }
public void handleGameInfoMsg(NetworkMessage initMsg) { GameInfo msg = Deserialize <GameInfo> (initMsg.reader.ReadBytesAndSize()); if (msg.gameOver) { isGameOver = true; canSendServerMsg = false; isListeningForTCP = false; UnetRoomConnector.shutdownCurrentConnection(); string gameOverString = TCP_API.APIStandardConstants.Fields.gameOver; string gameOverMsg; //Debug.LogError ("Winner: " + msg.winnerColor); if (msg.winnerColor == Game.PlayerColor.None) { gameOverMsg = "It's a draw!"; TCPLocalConnection.sendMessage(gameOverString + ": 0"); } else { gameOverMsg = msg.winnerColor + " won"; TCPLocalConnection.sendMessage(gameOverString + ": " + (msg.winnerColor == PlayerColor.Blue ? "1" : "-1")); } CurrentGame.gameOver(gameOverMsg); } }
public void handleGameState(NetworkMessage gameStateMsg) { byte[] bytes = gameStateMsg.reader.ReadBytesAndSize(); GameState stateMsg = Game.ClientController.Deserialize <GameState> (bytes); localRenderer.updatePlayerPosition(stateMsg.currentPos, stateMsg.currentTarget, stateMsg.time); TCPLocalConnection.sendMessage(stateMsg.currentPos.ToString()); }
void Start() { if (TCPLocalConnection.isReady == false) { TCPLocalConnection.init(); } // Destroy (gameObject); }
public void freeButtonPressed() { MemorySegment selectedSeg = segmentClicker.getSelectedSegment(); if (selectedSeg != null) { TCPLocalConnection.sendMessage("Free " + selectedSeg.pos); } }
public void gameOver() { moveQ.Clear(); playing = false; string gameOverString = TCP_API.APIStandardConstants.Fields.gameOver; TCPLocalConnection.sendMessage(gameOverString + ": " + logic.getCurrentScore()); //restartGame (); }
void Start() { ClientUIOverlord.onUIStateChanged += (ClientUIStates newState) => { if (newState != ClientUIStates.PreGame) { resetPanel(); } }; TCPLocalConnection.subscribeToTCPStatus(locAlbotStatusChanged); }
public static void startSinglePlayerLobby(PreGameBaseLobby theLobby, MapSelection theGame) { lobby = theLobby; gameMap = theGame; singleton.realSinglePlayerLobby.setScene(gameMap.Scene); ClientUIOverlord.onUIStateChanged += UIStateChanged; TCPLocalConnection.subscribeToTCPStatus(tcpStatusChanged); playingSinglePlayerGame = true; }
void Start() { TCPLocalConnection.subscribeToTCPStatus(TCPStatusChanged); TCPMessageQueue.readMsgInstant = takeInput; TCPLocalConnection.startServer(4000); //SinglePlayerGameMaster.init (takeInput, restartGame); logic.init(gameOver, roundFinished, updateScoreText); slideSpeed = moveSpeedSlider.value; //restartGame (); }
private void sendStartMsg(SortingVisualNumber[] numbers) { string s = ""; foreach (SortingVisualNumber n in numbers) { s += n.value + " "; } TCPLocalConnection.sendMessage(s); }
void Awake() { if (hasInit) { return; } hasInit = true; singleton = this; TCPLocalConnection.subscribeToTCPStatus(TCPStatusChanged); }
void Start() { if (ClientUI.ClientUIOverlord.hasLoaded) { return; } instance = this; //TCPLocalConnection.TCPStatusChanged += listenForTCPUpdate; TCPLocalConnection.subscribeToTCPStatus(UpdateStatusView); UpdateStatusView(ConnectionStatus.Disconnected); }
public void startButtonPressed() { int arraySize = int.Parse(arraySizeField.text); numbers = controller.startNewSession(arraySize, 0, 99); theAnimator.init(numbers); TCPLocalConnection.stopServer(); TCPLocalConnection.startServer(4000); gameStarted = true; }
private void instantReadTCPMsg(ReceivedLocalMessage msg) { if (msg.message == "JUMP") { localPlayer.activateJump(); } MainThread.fireEventAtMainThread(() => { print("Sending msg"); TCPLocalConnection.sendMessage(formatBoard()); }); }
private void waitForConnection() { isWaitingForConnection = true; TCPLocalConnection.fireTCPStatusChange(ConnectionStatus.Connecting); client = server.AcceptTcpClient(); stream = client.GetStream(); clientConnected = true; TCPLocalConnection.clientConnected(client); isWaitingForConnection = false; TCPLocalConnection.fireTCPStatusChange(ConnectionStatus.Connected); }
public static void startNewSession(GameType type, Action startFunc, int port = 4000) { TCPLocalConnection.init(); currentGameType = type; onStartFunc = startFunc; if (type == GameType.Connect4) { router = new Connect4.Connect4APIRouter(); } TCPLocalConnection.startServer(port); TCPLocalConnection.subscribeToTCPStatus(onBotConnected); }
private void playMove() { if (moveQ.Count == 0) { TCPLocalConnection.sendMessage(logic.formatBoard()); } else { int tempMove = moveQ [0]; moveQ.RemoveAt(0); logic.playMove(tempMove); } }
void Start() { if (hasInit) { return; } hasInit = true; TCPLocalConnection.subscribeToTCPStatus(locAlbotStatusChanged); ClientUIOverlord.onUIStateChanged += (ClientUIStates newState) => { if (newState != ClientUIStates.PreGame) { gameObject.SetActive(false); } }; }
private void requestBoard() { if (initBoard) { console.text = "Invalid start board"; } else { console.text = "Waiting for board"; } TCPLocalConnection.sendMessage("InitBoard"); initBoard = true; }
public void startServerClicked(bool forceOpen = false) { if (canOpenPort == false && forceOpen == false) { return; } LocalConnectionStatus status = TCPLocalConnection.startServer(int.Parse(portNumber.text)); errorOpeningPort = status != LocalConnectionStatus.connecting; if (status != LocalConnectionStatus.connecting) { displayPortError(status); } }
public void handleGameStatus(NetworkMessage gameStatusMsg) { byte[] bytes = gameStatusMsg.reader.ReadBytesAndSize(); GameInfo msg = Deserialize <GameInfo> (bytes); if (msg.gameOver && isGameOver == false) { BoardState finalState = getFinalState(msg.winnerColor); TCPLocalConnection.sendMessage(Connect4JsonParser.formatBoardMsgFromServer(lastRawBoard, msg.myColor, finalState)); localRenderer.onGameOver(msg.winnerColor == PlayerColor.Yellow ? Piece.Yellow : Piece.Red); gameOver(); CurrentGame.gameOver(getGameOverText(msg.winnerColor)); } }
private static void onBotConnected(ConnectionStatus status) { if (status == ConnectionStatus.Disconnected) { TCPLocalConnection.restartServer(); return; } if (status != ConnectionStatus.Connected) { return; } onStartFunc(); TCPLocalConnection.sendMessage(currentGameType + " API session started."); }
public void takeInput(string msg) { if (isMainPlayer()) { TCPLocalConnection.sendMessage(msg); } else if (NPC) { bot.onReceiveInput(msg); } else if (Human) { onHumanTakeInput(); } //Do nothing if us human }