Esempio n. 1
0
        private void cleverPlayMove()
        {
            while (isPlaying)
            {
                Thread.Sleep(100);
                if (hasNewInput == false)
                {
                    continue;
                }

                hasNewInput = false;

                bool dropBomb = false;
                int  moveDir  = -1;


                //Obvious quick fix, we should not have to try catch the DLL....
                try{
                    //moveDir = BombermanBot.MainClass.getCurrentAction (lastInput, ref dropBomb);
                    PlayerCommand outMsg = new PlayerCommand(botColor, moveDir, dropBomb);
                    theClientController.onOutgoingLocalMsgObj(outMsg, (short)BombermanProtocol.MsgType.playerCommands);
                }catch {}
                RealtimeTCPController.requestBoard(BombermanOverlord.convertColorToTeam(botColor));
            }
        }
Esempio n. 2
0
        public override void onPlayerLeft(ConnectedPlayer oldPlayer)
        {
            Debug.LogError("Player left: " + oldPlayer.username);
            int playerGameID           = BombermanOverlord.convertColorToTeam(oldPlayer.color);
            PlayerController playerObj = BombermanGameStateUpdater.getMatchingPlayerObj(playerGameID);

            if (playerObj != null)
            {
                playerObj.takeDamage();
            }
        }
Esempio n. 3
0
        protected override void playMove(string input)
        {
            while (isPlaying)
            {
                Thread.Sleep(200);
                if (hasNewInput == false)
                {
                    continue;
                }

                hasNewInput = false;
                makeDecision();
                RealtimeTCPController.requestBoard(BombermanOverlord.convertColorToTeam(botColor));
            }
        }
        public void handleBoardUpdate(NetworkMessage boardMsg)
        {
            byte[]      bytes = boardMsg.reader.ReadBytesAndSize();
            BoardUpdate msg   = Deserialize <BoardUpdate> (bytes);

            if (msg.updateID < lastUpdateID)
            {
                return;
            }

            if (msg.updateID > lastUpdateID)
            {
                lastUpdateID = msg.updateID;
                localRenderer.renderNewBoard(msg);
            }

            //print ("Update : " + msg.color);

            RealtimeTCPController.gotNewBoard(BombermanOverlord.convertColorToTeam(msg.color), BombermanBoardParser.parseBoard(msg));
        }
        public void handleInitSettings(NetworkMessage initMsg)
        {
            GameInfo msg = Deserialize <GameInfo> (initMsg.reader.ReadBytesAndSize());

            ClientPlayersHandler.initPlayerColor(msg.username, msg.myColor);
            LocalPlayer p = ClientPlayersHandler.getPlayerFromColor(msg.myColor);

            RealtimeTCPController.registerLocalPlayer(BombermanOverlord.convertColorToTeam(p.info.color), p.getTakeInputFunc(), !p.isNPC());

            if (p.isMainPlayer())
            {
                localPlayerColor = p.info.color;
            }
            if (p.Human)
            {
                localHumanColor = p.info.color;
            }

            print(localPlayerColor);

            isListeningForTCP = true;
        }
        protected override void readTCPMsg(ReceivedLocalMessage msg)
        {
            if (isGameOver)
            {
                return;
            }
            if (msg.message.Length == 0)
            {
                RealtimeTCPController.requestBoard(BombermanOverlord.convertColorToTeam(localPlayerColor), true);
                return;
            }

            PlayerCommand outMsg = new PlayerCommand(localPlayerColor, -1);

            parseInputMoveDir(msg.message, ref outMsg);
            parseDropBomb(msg.message, ref outMsg);
            if (outMsg.moveDir >= 0 || outMsg.dropBomb)
            {
                sendServerMsg(outMsg, (short)BombermanProtocol.MsgType.playerCommands);
            }


            RealtimeTCPController.requestBoard(BombermanOverlord.convertColorToTeam(localPlayerColor), true);
        }