Exemplo n.º 1
0
        /*
         *  Methods
         */

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="server">Reference to the game server</param>
        /// <param name="UserName">The logged in user's name</param>
        /// <param name="gameMode">The current game mode</param>
        /// <param name="isGm">Is this player the Game Master</param>
        public Main_GUI_Driver(IServer_WCF_Interface server, String UserName, String gameMode, Boolean isGm)
        {
            // Make sure all the shit meshes well
            is_gm         = isGm;
            userName      = UserName;
            this.server   = server;
            this.gameMode = gameMode;

            Construct_Main_GUI();
            Construct_Game_Field();
            Construct_Character_Driver();
            Construct_Bottom_Section();
            Construct_Portrait_Pane();
            Link_Control_Drivers();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Attempts to create a connection to the server.  If successful, it destroys the login_screen, and spawns the mainGUI.
        /// </summary>
        /// <param name="userName"></param>
        /// <param name="IP"></param>
        /// <param name="isGM"></param>
        /// <param name="gameMode"></param>
        /// <param name="error_reporting">Method of reporting an error (the GUI's error message label's text in this case)</param>
        public void Perform_Login(String userName, String IP, Boolean isGM, String gameMode, takes_string error_reporting)
        {
            var myBinding  = new NetTcpBinding();
            var myEndpoint = new EndpointAddress("net.tcp://" + IP + "/Design_Time_Addresses/ServiceLibrary/Comm/");
            var myChannel  = new DuplexChannelFactory <IServer_WCF_Interface>(new WCF_Client(), myBinding, myEndpoint); // todo: decouple frame from WCF

            try
            {
                server = myChannel.CreateChannel();

                client_id = server.performConnection(userName, isGM, ref gameMode);
            }
            catch (Exception e)
            {
                error_reporting("Exception occured: " + e.Message);
                return;
            }

            if (client_id == -1)
            {
                error_reporting("No GM is present, cannot connect.");
                return;
            }

            Main_GUI_Driver main_driver = new Main_GUI_Driver(server, userName, gameMode, isGM);

            //Main_GUI mainGUI = new Main_GUI(server, userName, isGM);

            // Replace login window with the main gui
            frame.contentPane.Controls.Remove(current_form);
            frame.contentPane.Controls.Add(main_driver.getGUI());

            current_form.Dispose();
            current_form = null;

            current_form = main_driver.getGUI();

            server.getCurrentlyConnectedPlayers(client_id);

            main_driver.getGUI().Show();
        }