private void UpdateWhisper()
 {
     if (this.m_whisper != null)
     {
         if (this.m_whisper.GetSpeakerId() == BnetPresenceMgr.Get().GetMyGameAccountId())
         {
             this.m_MyDecoration.SetActive(true);
             this.m_TheirDecoration.SetActive(false);
             BnetPlayer receiver = this.m_whisper.GetReceiver();
             object[]   args     = new object[] { receiver.GetBestName() };
             this.m_NameText.Text = GameStrings.Format("GLOBAL_CHAT_BUBBLE_RECEIVER_NAME", args);
         }
         else
         {
             this.m_MyDecoration.SetActive(false);
             this.m_TheirDecoration.SetActive(true);
             BnetPlayer speaker = this.m_whisper.GetSpeaker();
             if (speaker.IsOnline())
             {
                 this.m_NameText.TextColor = GameColors.PLAYER_NAME_ONLINE;
             }
             else
             {
                 this.m_NameText.TextColor = GameColors.PLAYER_NAME_OFFLINE;
             }
             this.m_NameText.Text = speaker.GetBestName();
         }
         this.m_MessageText.Text = ChatUtils.GetMessage(this.m_whisper);
     }
 }
예제 #2
0
    private void OnPlayersChanged(BnetPlayerChangelist changelist, object userData)
    {
        BnetPlayer myPlayer = BnetPresenceMgr.Get().GetMyPlayer();

        if (changelist.FindChange(myPlayer) != null)
        {
            BnetGameAccount hearthstoneGameAccount = myPlayer.GetHearthstoneGameAccount();
            if (((hearthstoneGameAccount != null) && !this.m_myPlayerReady) && (hearthstoneGameAccount.HasGameField(20) && hearthstoneGameAccount.HasGameField(0x13)))
            {
                this.m_myPlayerReady = true;
                this.UpdateMyAvailability();
            }
            if (!this.AmIAvailable() && this.m_challengerPending)
            {
                Network.DeclineFriendChallenge(this.m_partyId);
                this.CleanUpChallengeData(true);
            }
        }
        if (this.m_challengerPending)
        {
            BnetPlayerChange change = changelist.FindChange(this.m_challengerId);
            if (change != null)
            {
                BnetPlayer player = change.GetPlayer();
                if (player.IsDisplayable())
                {
                    this.m_challenger        = player;
                    this.m_challengerPending = false;
                    this.FireChangedEvent(FriendChallengeEvent.I_RECEIVED_CHALLENGE, this.m_challenger);
                }
            }
        }
    }
예제 #3
0
 protected virtual void Awake()
 {
     BnetPresenceMgr.Get().AddPlayersChangedListener(new BnetPresenceMgr.PlayersChangedCallback(this.OnPlayersChanged));
     BnetWhisperMgr.Get().AddWhisperListener(new BnetWhisperMgr.WhisperCallback(this.OnWhisper));
     ChatMgr.Get().AddPlayerChatInfoChangedListener(new ChatMgr.PlayerChatInfoChangedCallback(this.OnPlayerChatInfoChanged));
     RecruitListMgr.Get().AddRecruitsChangedListener(new RecruitListMgr.RecruitsChangedCallback(this.OnRecruitsChanged));
     this.m_RecruitUI = UnityEngine.Object.Instantiate <FriendListRecruitUI>(this.m_Prefabs.recruitUI);
     this.m_RecruitUI.transform.parent = base.gameObject.transform;
     this.m_RecruitUI.gameObject.SetActive(false);
     if (this.m_rankMedalSpawner == null)
     {
         this.m_rankMedal = UnityEngine.Object.Instantiate <TournamentMedal>(this.m_rankMedalPrefab);
         this.m_rankMedal.transform.parent        = base.transform;
         this.m_rankMedal.transform.localScale    = new Vector3(20f, 1f, 20f);
         this.m_rankMedal.transform.localRotation = Quaternion.Euler(new Vector3(-90f, 0f, 0f));
     }
     else
     {
         this.m_rankMedal = this.m_rankMedalSpawner.Spawn <TournamentMedal>();
     }
     this.m_rankMedal.RemoveEventListener(UIEventType.ROLLOVER, new UIEvent.Handler(this.m_rankMedal.MedalOver));
     this.m_rankMedal.AddEventListener(UIEventType.ROLLOVER, new UIEvent.Handler(this.RankMedalOver));
     if (UniversalInputManager.UsePhoneUI != null)
     {
         this.m_rankMedal.GetComponent <Collider>().enabled = false;
     }
     this.m_rankMedal.gameObject.SetActive(false);
     SceneUtils.SetLayer(this.m_rankMedal, GameLayer.BattleNetFriendList);
 }
 private void AddPendingFriend(BnetPlayer friend)
 {
     if (this.m_pendingChangelist.Add(friend) && (this.m_pendingChangelist.GetCount() == 1))
     {
         BnetPresenceMgr.Get().AddPlayersChangedListener(new BnetPresenceMgr.PlayersChangedCallback(this.OnPendingPlayersChanged));
     }
 }
예제 #5
0
    public void UpdateMyAvailability()
    {
        bool val = !this.HasAvailabilityBlocker();

        BnetPresenceMgr.Get().SetGameField(1, val);
        BnetNearbyPlayerMgr.Get().SetAvailability(val);
    }
 public void UpdateIcon()
 {
     if (this.m_player == null)
     {
         base.gameObject.SetActive(false);
     }
     else
     {
         List <BnetWhisper> whispersWithPlayer = BnetWhisperMgr.Get().GetWhispersWithPlayer(this.m_player);
         if (whispersWithPlayer == null)
         {
             base.gameObject.SetActive(false);
         }
         else if (whispersWithPlayer[whispersWithPlayer.Count - 1].IsSpeaker(BnetPresenceMgr.Get().GetMyPlayer()))
         {
             base.gameObject.SetActive(false);
         }
         else
         {
             PlayerChatInfo playerChatInfo = ChatMgr.Get().GetPlayerChatInfo(this.m_player);
             if ((playerChatInfo != null) && (Enumerable.LastOrDefault <BnetWhisper>(whispersWithPlayer, (Func <BnetWhisper, bool>)(whisper => whisper.IsSpeaker(this.m_player))) == playerChatInfo.GetLastSeenWhisper()))
             {
                 base.gameObject.SetActive(false);
             }
             else
             {
                 base.gameObject.SetActive(true);
             }
         }
     }
 }
 public string GetBestName()
 {
     if (this == BnetPresenceMgr.Get().GetMyPlayer())
     {
         if (this.m_hsGameAccount == null)
         {
             return(null);
         }
         return((this.m_hsGameAccount.GetBattleTag() != null) ? this.m_hsGameAccount.GetBattleTag().GetName() : null);
     }
     if (this.m_account != null)
     {
         string fullName = this.m_account.GetFullName();
         if (fullName != null)
         {
             return(fullName);
         }
         if (this.m_account.GetBattleTag() != null)
         {
             return(this.m_account.GetBattleTag().GetName());
         }
     }
     foreach (KeyValuePair <BnetGameAccountId, BnetGameAccount> pair in this.m_gameAccounts)
     {
         if (pair.Value.GetBattleTag() != null)
         {
             return(pair.Value.GetBattleTag().GetName());
         }
     }
     return(null);
 }
예제 #8
0
 private void Initialize()
 {
     BnetFriendMgr.Get().AddChangeListener(new BnetFriendMgr.ChangeCallback(this.OnFriendsChanged));
     Network.Get().AddBnetErrorListener(BnetFeature.Friends, new Network.BnetErrorCallback(this.OnBnetError));
     BnetPresenceMgr.Get().AddPlayersChangedListener(new BnetPresenceMgr.PlayersChangedCallback(this.OnPlayersChanged));
     SceneMgr.Get().RegisterSceneLoadedEvent(new SceneMgr.SceneLoadedCallback(this.OnSceneLoaded));
 }
 public static BnetPresenceMgr Get()
 {
     if (s_instance == null)
     {
         s_instance = new BnetPresenceMgr();
         if (< > f__am$cache8 == null)
         {
예제 #10
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"));
        }
예제 #11
0
 public static bool CanReceiveWhisperFrom(BnetGameAccountId id)
 {
     if (BnetPresenceMgr.Get().GetMyPlayer().IsBusy())
     {
         return(false);
     }
     return(BnetFriendMgr.Get().IsFriend(id));
 }
 private void Clear()
 {
     this.m_friends.Clear();
     this.m_receivedInvites.Clear();
     this.m_sentInvites.Clear();
     this.m_pendingChangelist.Clear();
     BnetPresenceMgr.Get().RemovePlayersChangedListener(new BnetPresenceMgr.PlayersChangedCallback(this.OnPendingPlayersChanged));
 }
예제 #13
0
 private void OnBnetPlayersChanged(BnetPlayerChangelist changelist, object userData)
 {
     if ((changelist.FindChange(this.m_gameAccountId) != null) && this.IsDisplayable())
     {
         BnetPresenceMgr.Get().RemovePlayersChangedListener(new BnetPresenceMgr.PlayersChangedCallback(this.OnBnetPlayersChanged));
         this.UpdateDisplayInfo();
     }
 }
예제 #14
0
 protected override void Awake()
 {
     s_instance = this;
     base.Awake();
     this.UpdateOnlineCount();
     BnetFriendMgr.Get().AddChangeListener(new BnetFriendMgr.ChangeCallback(this.OnFriendsChanged));
     BnetPresenceMgr.Get().AddPlayersChangedListener(new BnetPresenceMgr.PlayersChangedCallback(this.OnPlayersChanged));
     this.ShowPendingInvitesIcon(false);
 }
예제 #15
0
 private void OnDestroy()
 {
     BnetWhisperMgr.Get().RemoveWhisperListener(new BnetWhisperMgr.WhisperCallback(this.OnWhisper));
     BnetPresenceMgr.Get().RemovePlayersChangedListener(new BnetPresenceMgr.PlayersChangedCallback(this.OnPlayersChanged));
     if (UniversalInputManager.Get() != null)
     {
         UniversalInputManager.Get().CancelTextInput(base.gameObject, false);
     }
 }
 private void OnDestroy()
 {
     BnetPresenceMgr.Get().RemovePlayersChangedListener(new BnetPresenceMgr.PlayersChangedCallback(this.OnPlayersChanged));
     BnetWhisperMgr.Get().RemoveWhisperListener(new BnetWhisperMgr.WhisperCallback(this.OnWhisper));
     if (this.notifications != null)
     {
         this.notifications.Notified -= new MobileChatNotification.NotifiedEvent(this.OnNotified);
     }
 }
 private void Awake()
 {
     this.CreateMessagesCamera();
     if (this.notifications != null)
     {
         this.notifications.Notified += new MobileChatNotification.NotifiedEvent(this.OnNotified);
     }
     BnetWhisperMgr.Get().AddWhisperListener(new BnetWhisperMgr.WhisperCallback(this.OnWhisper));
     BnetPresenceMgr.Get().AddPlayersChangedListener(new BnetPresenceMgr.PlayersChangedCallback(this.OnPlayersChanged));
 }
    private void FirePendingFriendsChangedEvent()
    {
        BnetFriendChangelist changelist = this.m_pendingChangelist.CreateChangelist();

        if (this.m_pendingChangelist.GetCount() == 0)
        {
            BnetPresenceMgr.Get().RemovePlayersChangedListener(new BnetPresenceMgr.PlayersChangedCallback(this.OnPendingPlayersChanged));
        }
        this.FireChangeEvent(changelist);
    }
 private void Awake()
 {
     this.playerIcon = this.playerIconRef.Spawn <PlayerIcon>();
     this.UpdateBackgroundCollider();
     this.inputTextField.maxCharacters = 0x200;
     this.inputTextField.Submitted    += new Action <string>(this.OnInputComplete);
     this.inputTextField.Canceled     += new System.Action(this.OnInputCanceled);
     this.closeButton.AddEventListener(UIEventType.RELEASE, new UIEvent.Handler(this.OnCloseButtonReleased));
     BnetPresenceMgr.Get().AddPlayersChangedListener(new BnetPresenceMgr.PlayersChangedCallback(this.OnPlayersChanged));
 }
예제 #20
0
 protected virtual void OnDestroy()
 {
     BnetPresenceMgr.Get().RemovePlayersChangedListener(new BnetPresenceMgr.PlayersChangedCallback(this.OnPlayersChanged));
     BnetWhisperMgr.Get().RemoveWhisperListener(new BnetWhisperMgr.WhisperCallback(this.OnWhisper));
     RecruitListMgr.Get().RemoveRecruitsChangedListener(new RecruitListMgr.RecruitsChangedCallback(this.OnRecruitsChanged));
     if (ChatMgr.Get() != null)
     {
         ChatMgr.Get().RemovePlayerChatInfoChangedListener(new ChatMgr.PlayerChatInfoChangedCallback(this.OnPlayerChatInfoChanged));
     }
 }
예제 #21
0
 private void UpdateLocal()
 {
     if (this.IsBnetPlayer())
     {
         BnetGameAccountId myGameAccountId = BnetPresenceMgr.Get().GetMyGameAccountId();
         this.m_local = myGameAccountId == this.m_gameAccountId;
     }
     else
     {
         this.m_local = this.m_gameAccountId.GetLo() == 1L;
     }
 }
예제 #22
0
 private void UpdateRank()
 {
     if (this.ShouldUseBogusRank())
     {
         this.m_medalInfo = new MedalInfoTranslator();
     }
     else
     {
         BnetPlayer player = BnetPresenceMgr.Get().GetPlayer(this.m_gameAccountId);
         this.m_medalInfo = RankMgr.Get().GetRankPresenceField(player);
     }
 }
예제 #23
0
 private void OnAckRewards()
 {
     object[] objArray1 = new object[] { this.m_wins, ",", this.m_losses, ",1" };
     BnetPresenceMgr.Get().SetGameField(3, string.Concat(objArray1));
     if (!Options.Get().GetBool(Option.HAS_ACKED_ARENA_REWARDS, false))
     {
         NotificationManager.Get().CreateInnkeeperQuote(new Vector3(155.3f, NotificationManager.DEPTH, 34.5f), GameStrings.Get("VO_INNKEEPER_ARENA_1ST_REWARD"), "VO_INNKEEPER_ARENA_1ST_REWARD", 0f, null);
         Options.Get().SetBool(Option.HAS_ACKED_ARENA_REWARDS, true);
     }
     Network.GetRewardsAckDraftID();
     this.ClearDeckInfo();
 }
예제 #24
0
 private void UpdateDisplayInfo()
 {
     this.UpdateName();
     this.UpdateRank();
     if (this.IsBnetPlayer() && !this.IsLocalUser())
     {
         BnetPlayer player = BnetPresenceMgr.Get().GetPlayer(this.m_gameAccountId);
         if (BnetFriendMgr.Get().IsFriend(player))
         {
             ChatMgr.Get().AddRecentWhisperPlayerToBottom(player);
         }
     }
 }
 private void RemovePendingFriend(BnetPlayer friend)
 {
     if (this.m_pendingChangelist.Remove(friend))
     {
         if (this.m_pendingChangelist.GetCount() == 0)
         {
             BnetPresenceMgr.Get().RemovePlayersChangedListener(new BnetPresenceMgr.PlayersChangedCallback(this.OnPendingPlayersChanged));
         }
         else
         {
             this.ProcessPendingFriends();
         }
     }
 }
예제 #26
0
    public static BnetPlayer GetPlayer(BnetGameAccountId id)
    {
        if (id == null)
        {
            return(null);
        }
        BnetPlayer player = BnetNearbyPlayerMgr.Get().FindNearbyStranger(id);

        if (player == null)
        {
            player = BnetPresenceMgr.Get().GetPlayer(id);
        }
        return(player);
    }
    public bool SetRankPresenceField(NetCache.NetCacheMedalInfo medalInfo)
    {
        TranslatedMedalInfo currentMedal = new MedalInfoTranslator(medalInfo).GetCurrentMedal();
        List <byte>         list         = new List <byte>();
        byte item        = Convert.ToByte(currentMedal.rank);
        int  legendIndex = currentMedal.legendIndex;

        list.Add(item);
        byte[] bytes = BitConverter.GetBytes(legendIndex);
        list.Add(bytes[0]);
        list.Add(bytes[1]);
        byte[] val = list.ToArray();
        return(BnetPresenceMgr.Get().SetGameField(0x12, val));
    }
예제 #28
0
    public bool CanChallenge(BnetPlayer player)
    {
        if (player == null)
        {
            return(false);
        }
        BnetPlayer myPlayer = BnetPresenceMgr.Get().GetMyPlayer();

        if (player == myPlayer)
        {
            return(false);
        }
        if (!this.AmIAvailable())
        {
            return(false);
        }
        if ((TavernBrawlManager.Get().ShouldNewFriendlyChallengeBeTavernBrawl() && TavernBrawlManager.Get().CurrentMission().canCreateDeck) && !TavernBrawlManager.Get().HasValidDeck())
        {
            return(false);
        }
        BnetGameAccount hearthstoneGameAccount = player.GetHearthstoneGameAccount();

        if (hearthstoneGameAccount == null)
        {
            return(false);
        }
        if (!hearthstoneGameAccount.IsOnline())
        {
            return(false);
        }
        if (!hearthstoneGameAccount.CanBeInvitedToGame())
        {
            return(false);
        }
        if (ApplicationMgr.IsPublic())
        {
            BnetGameAccount account2 = myPlayer.GetHearthstoneGameAccount();
            if (string.Compare(hearthstoneGameAccount.GetClientVersion(), account2.GetClientVersion()) != 0)
            {
                return(false);
            }
            if (string.Compare(hearthstoneGameAccount.GetClientEnv(), account2.GetClientEnv()) != 0)
            {
                return(false);
            }
        }
        return(true);
    }
예제 #29
0
    private void OnBegin()
    {
        BnetPresenceMgr.Get().SetGameField(3, "0,0,0");
        Network.BeginDraft newDraftDeckID = Network.GetNewDraftDeckID();
        CollectionDeck     deck           = new CollectionDeck {
            ID   = newDraftDeckID.DeckID,
            Type = DeckType.DRAFT_DECK
        };

        this.m_draftDeck   = deck;
        this.m_currentSlot = 0;
        this.m_validSlot   = 0;
        Log.Arena.Print(string.Format("DraftManager.OnBegin - Got new draft deck with ID: {0}", this.m_draftDeck.ID), new object[0]);
        this.InformDraftDisplayOfChoices(newDraftDeckID.Heroes);
        this.FireDraftDeckSetEvent();
    }
 private void Awake()
 {
     s_instance   = this;
     this.m_toast = UnityEngine.Object.Instantiate <SocialToast>(this.m_socialToastPrefab);
     RenderUtils.SetAlpha(this.m_toast.gameObject, 0f);
     this.m_toast.gameObject.SetActive(false);
     this.m_toast.transform.parent        = BnetBar.Get().m_socialToastBone.transform;
     this.m_toast.transform.localRotation = Quaternion.Euler(new Vector3(90f, 180f, 0f));
     this.m_toast.transform.localScale    = (Vector3)this.TOAST_SCALE;
     this.m_toast.transform.position      = BnetBar.Get().m_socialToastBone.transform.position;
     BnetPresenceMgr.Get().AddPlayersChangedListener(new BnetPresenceMgr.PlayersChangedCallback(this.OnPlayersChanged));
     BnetPresenceMgr.Get().OnGameAccountPresenceChange += new Action <BattleNet.PresenceUpdate[]>(this.OnPresenceChanged);
     BnetFriendMgr.Get().AddChangeListener(new BnetFriendMgr.ChangeCallback(this.OnFriendsChanged));
     Network.Get().SetShutdownHandler(new Network.ShutdownHandler(this.ShutdownHandler));
     SoundManager.Get().Load("UI_BnetToast");
 }