Ejemplo n.º 1
0
        /* --- Static Methods (Interface) --- */
        public static void Load()
        {
            // connect to the bot server
            if (HSMPClient.Get() == null)
            {
                HSMPClient.Connect("foobar");
            }

            if (NetCache.Get() == null || BnetPresenceMgr.Get() == null || BnetPresenceMgr.Get().GetMyPlayer() == null)
            {
                HSMPClient.Get().Send(new MsgStatus(MsgStatus.State.HANDSHAKE_FAILED, MsgStatus.User.CLIENT, "Hearthstone is initializing, please wait..."));
                return;
            }

            if (s_loaded == false)
            {
                // create root game object
                UnityEngine.GameObject root = new UnityEngine.GameObject("HookRoot");
                root.transform.parent = BaseUI.Get().transform;

                // initialize subcomponents
                AttachScripts(root);
                InstallNetworkSniffers(root);
                RegisterMessageListeners(root);

                s_loaded = true;
            }

            HSMPClient.Get().Send(new MsgStatus(MsgStatus.State.CONNECTED, MsgStatus.User.CLIENT, "Success"));
        }
Ejemplo n.º 2
0
        private static void RegisterMessageListeners(UnityEngine.GameObject root)
        {
            HSMPClient c = HSMPClient.Get();

            Meta.ResponseInstaller.Register(c);
            Game.ResponseInstaller.Register(c);
            Account.ResponseInstaller.Register(c);
        }
Ejemplo n.º 3
0
        /* --- Static Methods (Interface) --- */
        public static bool Connect(string name)
        {
            if (s_instance != null)
            {
                s_instance.SendDebugMessage("ERROR: tried to connect with an already open HSMPClient...");
                return(false);
            }
            ClientMessageStream s = ClientMessageStream.Create(name);

            if (s == null)
            {
                return(false);
            }
            s_instance = new HSMPClient(s);
            return(true);
        }
Ejemplo n.º 4
0
        private bool OnTaskPlayTournament(TaskParamPlayTournament p)
        {
            PegasusShared.GameType type = p.Ranked ?
                                          PegasusShared.GameType.GT_RANKED :
                                          PegasusShared.GameType.GT_UNRANKED;

            long deckID = GetDeckID(p.DeckIndex);

            if (deckID == 0)
            {
                HSMPClient.Get().SendDebugMessage("invalid deck ID :(");
                return(false);
            }

            GameMgr.Get().FindGame(type, 2, deckID, 0);
            return(true);
        }
Ejemplo n.º 5
0
 public void Awake()
 {
     HSMPClient.Get().RegisterListener(MsgTaskSet.ID, OnMsgTaskSet);
     HSMPClient.Get().RegisterListener(MsgTaskGetState.ID, OnMsgTaskGetState);
 }
Ejemplo n.º 6
0
 private void OnPacketNAckOption()
 {
     HSMPClient.Get().SendDebugMessage("NAck Option...");
 }
Ejemplo n.º 7
0
 public void Awake()
 {
     HSMPClient.Get().RegisterListener(MsgChooseOption.ID, OnMsgChooseOption);
     Network.Get().RegisterNetHandler(PegasusGame.NAckOption.PacketID.ID, OnPacketNAckOption);
 }
Ejemplo n.º 8
0
 /* --- Instance Methods (Interface) --- */
 public void Awake()
 {
     m_serverState = MsgStatus.State.DISCONNECTED;
     HSMPClient.Get().RegisterListener(MsgStatus.ID, OnMsgStatus);
 }
Ejemplo n.º 9
0
 public void OnDestroy()
 {
     HSMPClient.Get().Send(new MsgStatus(MsgStatus.State.DISCONNECTED, MsgStatus.User.CLIENT, "NORMAL"));
     HSMPClient.Get().GetStream().Close();
 }
Ejemplo n.º 10
0
 public void LateUpdate()
 {
     HSMPClient.Get().GetStream().CheckForMessages(MessageHandler.Alloc);
     HSMPClient.Get().GetStream().Distribute();
 }