示例#1
0
        //! Dispatch a custom Esc Event message to the specified peer
        public int DispatchEventToClient(EscEvent evt, Peer endpoint)
        {
            WriteToLog(" sending message: " + evt.ToString() + " to " + endpoint.Username());

            if (evt.ToString().Length > 256)
            {
                Debug.LogWarning("ServerConnection : DispatchEventToClient EscEvent length exceeds limit!");
            }
            //		LoadSave.savedData.Add (Time.time.ToString () + " : OUT :" + evt.ToString () + "\n");
            return(GameInterface.dispatchEvent(endpoint.Username(), evt.ToString()));
        }
示例#2
0
        /**
         * Dispatches the currently stored list of games from the locally generated list
         */
        public void UpdateDocentGamesList()
        {
            EscEvent evt = new EscEvent("games", gamesList);
            string   initPayloadString = evt.ToString();

            GameInterface.dispatchEvent("docent", initPayloadString);
        }
示例#3
0
        /**
         * Dispatches a EscEvent to a controller client with initial payload attributes provided by the Game class.
         *
         * @param client the client to be initialized
         * @param initPayload the initialization key/value pairs to be dispatched
         */
        public void InitializeController(Client client, Dictionary <string, string> initPayload)
        {
            string   msgInit           = API_KEYWORD_INIT.Substring(0, API_KEYWORD_INIT.Length - 1);
            EscEvent evt               = new EscEvent(msgInit, initPayload);
            string   initPayloadString = evt.ToString();

            WriteToLog(" sending message: " + initPayloadString + " to " + client.Username());
//						LoadSave.savedData.Add (Time.time.ToString () + " : OUT :" + client.Username () + " " + initPayloadString + "\n");
            GameInterface.dispatchEvent(client.Username(), initPayloadString);
        }
示例#4
0
        /**
         * Invoked by the ESC Launcher application when a Quit action is triggered or when a new game is loaded.
         * Dispatches an event to the plugin which then propagates it to all connected client controllers.
         */
        public void DocentQuitGame(string gameId)
        {
            Dictionary <string, string> dict = new Dictionary <string, string>();

            dict.Add("game", gameId);
            EscEvent evt = new EscEvent("quit", dict);

            GameInterface.dispatchEvent("game-engine", evt.ToString());

            if (null != OnDocentGameEnd)
            {
                OnDocentGameEnd(gameId);
            }
        }
示例#5
0
        //! Dispatches an EscEvent to the game engine to stop game
        public void DocentStopGame(string gameId)
        {
            Dictionary <string, string> dict = new Dictionary <string, string>();

            dict.Add("game", gameId);
            EscEvent evt = new EscEvent("stop", dict);

            GameInterface.dispatchEvent("game-engine", evt.ToString());
            GameInterface.writeLog("stop game");
            if (null != OnDocentGameStop)
            {
                OnDocentGameStop(gameId);
            }
        }
示例#6
0
        /**
         * Dispatches a list of parameters to the docent remote control to initialize it
         *
         * @param gameId the unique game name identifier
         * @param mode1 the first mode toggle integer
         * @param mode2 the second mode toggle integer
         * @param mode3 the third mode toggle integer
         * @param param1 the first custom string paramter
         * @param param2 the second custom string paramter
         * @param param3 the third custom string paramter
         *
         * !DEPRECATED!
         */
        public void DocentApplyAdvancedSettings(string gameId, int mode1, int mode2, int mode3, string param1, string param2, string param3)
        {
            Dictionary <string, string> dict = new Dictionary <string, string>();

            dict.Add("game", gameId);
            if (-1 != mode1)
            {
                dict.Add("mode1", mode1.ToString());
            }

            if (-1 != mode2)
            {
                dict.Add("mode2", mode2.ToString());
            }

            if (-1 != mode3)
            {
                dict.Add("mode3", mode3.ToString());
            }

            if ("" != param1)
            {
                dict.Add("param1", param1.ToString());
            }

            if ("" != param1)
            {
                dict.Add("param2", param1.ToString());
            }

            if ("" != param1)
            {
                dict.Add("param3", param1.ToString());
            }

            EscEvent evt = new EscEvent("start", dict);

            GameInterface.dispatchEvent("game-engine", evt.ToString());

            if (null != OnDocentApplyAdvancedSettings)
            {
                OnDocentApplyAdvancedSettings(gameId);
            }
        }
示例#7
0
        /**
         * Dispatches an EscEvent to the game engine to start the game
         *
         * @param gameId the unique game name identifier
         * @param round the round setting to dispatch
         * @param difficulty the difficulty setting to dispatch
         */
        public void DocentStartGame(string gameId, int round, int difficulty)
        {
            Dictionary <string, string> dict = new Dictionary <string, string>();

            dict.Add("game", gameId);
            if (-1 != round)
            {
                dict.Add("round", round.ToString());
            }
            if (-1 != difficulty)
            {
                dict.Add("difficulty", difficulty.ToString());
            }
            EscEvent evt = new EscEvent("start", dict);

            GameInterface.dispatchEvent("game-engine", evt.ToString());

            if (null != OnDocentGameStart)
            {
                OnDocentGameStart(gameId);
            }
        }
 /**
  * Dispatch a custom EscEvent to the game launcher
  *
  * @param evt an event to dispatch
  * @return zero on success, failure otherwise
  */
 public int DispatchEventToGameLauncher(EscEvent evt)
 {
     return(ControllerInterface.dispatchEvent(GAME_LAUNCHER, evt.ToString()));
 }
 /**
  * Dispatch a custom EscEvent message to the specified network peer
  *
  * @param evt an event to dispatch
  * @param endpoint the network peer that will receive the event
  * @return zero on success, failure otherwise
  */
 public int DispatchEventToClient(EscEvent evt, Peer endpoint)
 {
     return(ControllerInterface.dispatchEvent(endpoint.Username(), evt.ToString()));
 }