コード例 #1
0
        public void InitializeTest()
        {
            List <String> playersList = new List <string>();

            playersList.Add("victor");
            playersList.Add("Alan");
            playersList.Add("Pepe");

            connectionChatService.Add("victor", null);
            connectionChatService.Add("Alan", null);
            connectionChatService.Add("Pepe", null);

            logginsConnections.Add("Alan", null);

            listGamesOnline.Add(1, playersList);
            listGamesOnline.Add(2, playersList);

            InformationPlayer info1 = new InformationPlayer();

            info1.userLisman  = "Alan";
            info1.isLive      = true;
            info1.lifesLisman = 0;
            info1.scoreLisman = 0;
            InformationPlayer info2 = new InformationPlayer();

            info2.userLisman  = "Victor";
            info2.isLive      = true;
            info2.lifesLisman = 2;
            info2.scoreLisman = 0;
            InformationPlayer info3 = new InformationPlayer();

            info3.userLisman  = "Pablo";
            info3.isLive      = true;
            info3.lifesLisman = 2;
            info3.scoreLisman = 0;
            InformationPlayer info4 = new InformationPlayer();

            info4.userLisman  = "Gume";
            info4.isLive      = true;
            info4.lifesLisman = 3;
            info4.scoreLisman = 0;

            ReadMapGame();

            Game game = new Game();

            game.gameMap     = GAMEMAP;
            game.lismanUsers = new Dictionary <int, InformationPlayer>();
            game.lismanUsers.Add(3, info1);
            game.lismanUsers.Add(4, info2);
            game.lismanUsers.Add(5, info3);
            game.lismanUsers.Add(6, info4);

            multiplayerGameInformation.Add(1, game);

            Game game2 = new Game();

            game2.lismanUsers = new Dictionary <int, InformationPlayer>();
            multiplayerGameInformation.Add(2, game2);
        }
コード例 #2
0
        /// <summary>
        /// Método que asigna el color que utilizara cada jugador en la partida
        /// </summary>
        /// <param name="idgame">identificador del juego al que pertenece</param>
        /// <param name="user">nombre de usuario del jugador</param>
        /// <returns></returns>
        public bool AssignColorPlayer(int idgame, String user)
        {
            InformationPlayer infoPlayer = new InformationPlayer();
            int  index         = listGamesOnline[idgame].FindIndex(u => u == user);
            bool result        = false;
            int  colorAssigned = 0;

            switch (index)
            {
            case 0:
                colorAssigned = LISMANYELLOW;
                infoPlayer.initialDirecction = "RIGHT";
                break;

            case 1:
                colorAssigned = LISMANRED;
                infoPlayer.initialDirecction = "LEFT";
                break;

            case 2:
                colorAssigned = LISMANBLUE;
                infoPlayer.initialDirecction = "RIGHT";
                break;

            case 3:
                colorAssigned = LISMANGREEN;
                infoPlayer.initialDirecction = "LEFT";
                break;
            }
            infoPlayer.userLisman  = user;
            infoPlayer.lifesLisman = 3;
            infoPlayer.hasPower    = false;
            infoPlayer.isLive      = true;
            infoPlayer.scoreLisman = 0;
            multiplayerGameInformation[idgame].lismanUsers.Add(colorAssigned, infoPlayer);

            if (colorAssigned != 0)
            {
                result = true;
            }

            return(result);
        }