Exemplo n.º 1
0
        public void MessageSentFromView(Messages.LobbyViewMessage code, List <object> args, object sender)
        {
            switch (code)
            {
            case Messages.LobbyViewMessage.connect:    //Address and port are in array
                cm.parseRequest(Messages.GameMessages.connect, args, this);
                break;

            case Messages.LobbyViewMessage.viewClosed:
                notifyObservers("Connect To Server Form Closed");
                break;

            default:
                break;
            }
        }
        //MainMenuController implementation
        /// <summary>
        /// Parses messages from MainMenuView, calls appropriate function as response
        /// </summary>
        /// <param name="code">message</param>
        /// <param name="args">view bag from view, in case parameters needed to be passed to response function</param>
        public void MessageSentFromView(MainMenuMessages code, List <object> args)
        {
            NamedParameter par;

            switch (code)
            {
            case MainMenuMessages.ConnectToServer:
                connectToServer();
                //updatePlayerName();
                break;

            case MainMenuMessages.CreateCharacter:
                createCharacter();
                break;

            case MainMenuMessages.CharacterLoaded:
                sendCharacterToServer();
                break;

            case MainMenuMessages.CreateMatch:
                createMatch(args);
                break;

            case MainMenuMessages.CreateGoal:
                createGoal();
                break;

            case MainMenuMessages.JoinMatch:
                joinMatch(args);
                break;

            case MainMenuMessages.LeaveGame:
                connectionManager.parseRequest(Messages.GameMessages.LeaveMatch, args, this);
                break;

            case MainMenuMessages.RefreshMatches:
                connectionManager.parseRequest(Messages.GameMessages.UpdateMatches, args, this);
                break;

            case MainMenuMessages.LoadPlayer1:
                par = DataTypes.createList(args, DataType.xmlDocument)[0];
                if (args != null)
                {
                    loadCharacterFromXml((XmlDocument)par.data, 0);
                }
                break;

            case MainMenuMessages.LoadPlayer2:
                par = DataTypes.createList(args, DataType.xmlDocument)[0];
                if (args != null)
                {
                    loadCharacterFromXml((XmlDocument)par.data, 1);
                }
                break;

            case MainMenuMessages.SelectedMatchChanged:
                par = DataTypes.createList(args, DataType.name)[0];
                setSelectedMatch(par.data.ToString());
                updateSelectedMatch();
                break;

            case MainMenuMessages.PlayerReady:
                setPlayerReady();
                break;

            case MainMenuMessages.PlayDispute:
                playDispute();
                break;

            case MainMenuMessages.FormClosed:
                this.formClosed("Closed");
                break;

            case MainMenuMessages.Update:
                connectionManager.parseRequest(Messages.GameMessages.SendActiveMatches, args, this);
                break;

            default:
                break;
            }
        }