Example #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));
            }
        }
Example #2
0
        public override MapObj convertToMapObj()
        {
            MapObj temp = new MapObj(ID, type, BombermanOverlord.vecToFlArray(transform.localPosition));

            temp.explodeDuration = explodeTime - Time.time;
            return(temp);
        }
        public override MapObj convertToMapObj()
        {
            MapObj temp = new MapObj(ID, type, BombermanOverlord.vecToFlArray(transform.localPosition), bombsLeft);

            temp.targetPos = BombermanOverlord.vecToFlArray(targetPos);
            temp.color     = color;
            return(temp);
        }
        private void spawnBomb(BoardAction a)
        {
            GameObject temp = Instantiate(bombPrefab, Vector3.zero, Quaternion.identity, mapObjectsParent);

            temp.transform.localPosition = BombermanOverlord.FArrayToVec(a.pos);
            VisualBomb bomb = temp.GetComponent <VisualBomb> ();

            bomb.initBomb(a.targetID, 0, 0, explosionPrefab);
            currentGameObjects.Add(bomb as BombermanVisualObj);
        }
        void Start()
        {
            singleton = this;
            currentMap.Init();

            foreach (PlayerController p in players)
            {
                updater.gameObjects.Add(p as BombermanMapObject);
            }
        }
Example #6
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();
            }
        }
Example #7
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 initBoard(BoardUpdate board)
        {
            foreach (MapObj obj in board.currentMap)
            {
                if (obj.type == BombermanObjType.Player)
                {
                    GameObject tempObj = Instantiate(playerPrefab, Vector3.zero, Quaternion.identity, mapObjectsParent);
                    tempObj.transform.localPosition = BombermanOverlord.FArrayToVec(obj.pos);

                    VisualPlayer tempPlayer = tempObj.GetComponent <VisualPlayer> ();
                    tempPlayer.init(obj.color, playerColors [colorOrder[obj.color]], floatArrayToVec(obj.pos), obj.gameID);
                    players.Add(obj.color, tempPlayer);
                    currentGameObjects.Add(tempPlayer as BombermanVisualObj);
                }
            }
        }
        public void takeDamage()
        {
            if (dead)
            {
                return;
            }

            if (--HP <= 0)
            {
                BombermanOverlord.playerDied(this);
                GameBoard.singleton.gridMap [currentCoord[1]][currentCoord[0]].removePlayer();
                dead = true;
                gameObject.SetActive(false);
                GameBoard.singleton.gridMap [currentCoord [1]][currentCoord [0]].removePlayer();
            }
        }
        public void placeBomb()
        {
            if (GameBoard.validCoord(currentCoord [0], currentCoord [1]) == false)
            {
                return;
            }
            if (bombsLeft == 0)
            {
                return;
            }

            Bomb temp = Instantiate(bombPrefab, GameBoard.getGridPos(currentCoord [0], currentCoord [1]), Quaternion.identity, transform.parent).GetComponent <Bomb> ();

            temp.init(3, 3, currentCoord, this);

            BoardAction dropAction = new BoardAction(ActionType.BombSpawn, temp.ID, BombermanOverlord.vecToFlArray(temp.transform.localPosition));

            BombermanGameStateUpdater.addNewAction(dropAction);
            bombsLeft--;
        }
        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);
        }
 public float[] getFloatPos()
 {
     return(BombermanOverlord.vecToFlArray(transform.position));
 }