예제 #1
0
    private void Start()
    {
        GEventManager.StartListening(GEventManager.ON_PLAYER_TAKE_DAMAGE, updateDisplay);
        GEventManager.StartListening(GEventManager.ON_PLAYER_HEAL_DAMAGE, updateDisplay);

        updateDisplay();
    }
예제 #2
0
        override public void ExitSubState()
        {
            GEventManager.StopListening("NEW_GLOBAL_CHAT", onNewGlobalChat);
            GEventManager.StopListening("NEW_LOBBY_CHAT", onNewLobbyChat);

            BombersNetworkManager.Instance.LeaveLobby();

            base.ExitSubState();
        }
예제 #3
0
        protected override void Start()
        {
            Cursor.visible    = true;
            Cursor.lockState  = CursorLockMode.None;
            m_friendsListItem = new List <FriendsListItem>();
            GEventManager.StartListening(GFriendsManager.ON_FRIENDS_LIST_UPDATED, OnRefreshFriendsList);
            GEventManager.StartListening(GEventManager.ON_INVITED_FRIEND, OnInvitedFriend);
            GEventManager.StartListening(GEventManager.ON_REFUSED_INVITE_FRIEND, OnRefusedInviteFriend);
            GEventManager.StartListening(GEventManager.ON_RTT_ENABLED, OnEnableRTTSuccess);
            GEventManager.StartListening(GEventManager.ON_PLAYER_DATA_UPDATED, OnUpdateStats);

            m_statsPanelContentLeft  = GameObject.Find("StatsPanel").transform.FindDeepChild("ContentLeft").gameObject;
            m_statsPanelContentRight = GameObject.Find("StatsPanel").transform.FindDeepChild("ContentRight").gameObject;
            m_joinFriendsPanel       = GameObject.Find("JoinFriendsPanel");
            m_statText  = GameObject.Find("StatText");
            m_statValue = GameObject.Find("StatValue");

            ChatInputField.onEndEdit.AddListener(delegate { OnEndEditHelper(); });

            BombersNetworkManager.Instance.ConnectRTT();

            GameObject playerName = GameObject.Find("PlayerName");

            m_inputField = playerName.GetComponent <InputField>();
            m_inputField.characterLimit = MAX_CHARACTERS_NAME;
            m_inputField.text           = GPlayerMgr.Instance.PlayerData.PlayerName;
            m_inputField.interactable   = false;
            PlayerRankIcon.UpdateIcon(GPlayerMgr.Instance.PlayerData.PlayerRank);
            BrainCloudStats.Instance.ReadStatistics();

            BaseNetworkBehavior.MSG_ENCODED   = GConfigManager.GetIntValue("MSGENCODING");
            BaseNetworkBehavior.SEND_INTERVAL = GConfigManager.GetFloatValue("SEND_INTERVAL");
            _stateInfo = new StateInfo(STATE_NAME, this);
            base.Start();

            // should we push the connect screen
            if (!GCore.Wrapper.Client.Initialized)
            {
                GStateManager.Instance.PushSubState(ConnectingSubState.STATE_NAME);
            }

#if STEAMWORKS_ENABLED
            QuitButton.SetActive(true);
            StoreButtonTop.SetActive(false);
            StoreButtonBottom.SetActive(true);
#else
            QuitButton.SetActive(false);
            StoreButtonTop.SetActive(true);
            StoreButtonBottom.SetActive(false);
#endif

#if UNITY_WEBGL
            LeftButtonGroup.SetActive(false);
#endif

            GPlayerMgr.Instance.GetXpData();
        }
예제 #4
0
        protected override void Start()
        {
            m_initialized = false;

            m_teamGreenListItem = new List <FriendsListItem>();
            m_teamRedListItem   = new List <FriendsListItem>();
            m_teamGreenItems    = new List <PlayerData>();
            m_teamRedItems      = new List <PlayerData>();

            m_currentMemberCount = 0;
            m_gameName           = transform.FindDeepChild("GameName").transform.Find("Text").GetComponent <Text>();
            m_waitingForPlayers  = transform.FindDeepChild("Waiting...").GetComponent <Text>();
            m_gameQuitButton     = transform.FindDeepChild("ButtonQuitGame").gameObject;
            m_gameStartButton    = transform.FindDeepChild("ButtonStartGame").gameObject;
            m_chatGroupLobby     = transform.FindDeepChild("ChatGroupLocal").gameObject;
            m_chatGroupGlobal    = transform.FindDeepChild("ChatGroupGlobal").gameObject;

            m_optionsAndGameGroup = transform.FindDeepChild("OptionsAndGameGroup").gameObject;
            m_gameButtons         = transform.FindDeepChild("GameButtons").gameObject;
            m_panelLeft           = transform.FindDeepChild("PanelLeft").GetComponent <Canvas>();

            m_titleField             = transform.FindDeepChild("Title Field").gameObject;
            m_editButton             = m_titleField.transform.Find("EditButton").gameObject;
            m_lobbyGameOptionsHost   = m_optionsAndGameGroup.transform.Find("lobbyGameOptionsHost").gameObject;
            m_lobbyGameOptionsTester = m_optionsAndGameGroup.transform.Find("lobbyGameOptionsTester").gameObject;
            m_protocolDropdown       = m_lobbyGameOptionsTester.transform.Find("dropdownButton1").GetComponent <Dropdown>();
            m_compressionDropdown    = m_lobbyGameOptionsTester.transform.Find("dropdownButton2").GetComponent <Dropdown>();

            SetupLobbyDisplaySettings();
            SetupTesterSettings();

            m_changeTeamButton = transform.FindDeepChild("ButtonChangeTeam").gameObject;

            GameObject tabGlobal = transform.FindDeepChild("TabGlobal").gameObject;
            GameObject tabLocal  = transform.FindDeepChild("TabLocal").gameObject;

            m_lobbyChatNotification  = tabLocal.transform.FindDeepChild("notificationBadge").gameObject;
            m_globalChatNotification = tabGlobal.transform.FindDeepChild("notificationBadge").gameObject;

            LocalChatInputField.onEndEdit.AddListener(delegate { OnEndEditHelperLocal(); });
            GlobalChatInputField.onEndEdit.AddListener(delegate { OnEndEditHelperGlobal(); });

            GEventManager.StartListening("NEW_GLOBAL_CHAT", onNewGlobalChat);
            GEventManager.StartListening("NEW_LOBBY_CHAT", onNewLobbyChat);

            GPlayerMgr.Instance.UpdateActivity(GPlayerMgr.LOCATION_LOBBY, GPlayerMgr.STATUS_IDLE, BombersNetworkManager.LobbyInfo.LobbyId, BombersNetworkManager.LobbyInfo.LobbyType);
            m_initialized = true;

            _stateInfo = new StateInfo(STATE_NAME, this);
            base.Start();

            populateGlobalChatWithExistingMessages();

            // start with lobby chat
            DisplayGlobalChat(false);
        }
        protected override void Start()
        {
            _stateInfo = new StateInfo(STATE_NAME, this);
            base.Start();
            GEventManager.StartListening(GFriendsManager.ON_FRIENDS_LIST_UPDATED, OnRefreshFriendsList);
            GEventManager.StartListening(GBomberRTTConfigManager.ON_SEARCH_RESULTS_UPDATED, OnRefreshSearchResults);

            GCore.Wrapper.RTTService.RegisterRTTPresenceCallback(OnPresenceCallback);
#if UNITY_WEBGL || UNITY_STANDALONE
            searchInputField.onEndEdit.AddListener(delegate { OnEndEditHelper(); });
#endif
        }
예제 #6
0
        protected override void OnDestroy()
        {
            // stop listening to presence, once we go into gameplay
            if (!GCore.ApplicationIsQuitting)
            {
                GEventManager.StopListening(GFriendsManager.ON_FRIENDS_LIST_UPDATED, OnRefreshFriendsList);
                GEventManager.StopListening(GEventManager.ON_INVITED_FRIEND, OnInvitedFriend);
                GEventManager.StopListening(GEventManager.ON_REFUSED_INVITE_FRIEND, OnRefusedInviteFriend);
                GEventManager.StopListening(GEventManager.ON_RTT_ENABLED, OnEnableRTTSuccess);
                GEventManager.StopListening(GEventManager.ON_PLAYER_DATA_UPDATED, OnUpdateStats);
                (BombersNetworkManager.singleton as BombersNetworkManager).DisconnectGlobalChat();
            }

            base.OnDestroy();
        }
        protected override void OnDestroy()
        {
            GEventManager.StopListening(GFriendsManager.ON_FRIENDS_LIST_UPDATED, OnRefreshFriendsList);
            GEventManager.StopListening(GBomberRTTConfigManager.ON_SEARCH_RESULTS_UPDATED, OnRefreshSearchResults);

            // TODO: refactor thise presence callback ONLY in the FriendsMgr, and these two other places listen for updates!
            MainMenuState mainMenu = GStateManager.Instance.CurrentState as MainMenuState;

            if (mainMenu)
            {
                GCore.Wrapper.RTTService.RegisterRTTPresenceCallback(mainMenu.OnPresenceCallback);
            }

            base.OnDestroy();
        }
예제 #8
0
        private void onConnectComplete()
        {
            // check the attached identities
#if !STEAMWORKS_ENABLED
            if (GPlayerMgr.Instance.IsEmailAttached())
            {
                GCore.Instance.ProcessRetryQueue();
                onCompleteConnectingSubState();
            }
            else
#endif
            {
                GStateManager.Instance.EnableLoadingSpinner(true);
                GEventManager.StartListening(GEventManager.ON_IDENTITIES_UPDATED, onIdentitiesUpdated);
            }
        }
예제 #9
0
        public void AddLobbyChatMessage(Dictionary <string, object> in_jsonMessage)
        {
            BaseState lobbyState = GStateManager.Instance.FindSubState(LobbySubState.STATE_NAME);

            if (lobbyState != null && m_lobbyChatContent == null)
            {
                m_lobbyChatContent = lobbyState.transform.FindDeepChild("lobbyChatContent").gameObject;
            }
            if (m_lobbyChatContent == null)
            {
                return;
            }

            Transform contentTransform = m_lobbyChatContent.transform;

            lock (contentTransform)
            {
                // populate based on the incoming data
                if (contentTransform.childCount >= 30)
                {
                    Destroy(contentTransform.transform.GetChild(0).gameObject);
                }

                ChatCell   tempCell;
                GameObject tempObj;
                Dictionary <string, object> jsonData = in_jsonMessage.ContainsKey("data") ?
                                                       (Dictionary <string, object>)in_jsonMessage["data"] : in_jsonMessage;

                Dictionary <string, object> fromData = (Dictionary <string, object>)jsonData["from"];

                Dictionary <string, object> signalData = jsonData.ContainsKey("signalData") ?
                                                         (Dictionary <string, object>)jsonData["signalData"] : jsonData;
                string profileId = fromData["id"] as string;
                int    rank      = (int)signalData["rank"];

                tempObj = Instantiate(profileId == GCore.Wrapper.Client.ProfileId ? LobbyChatCellYou :                       // is you!
                                      profileId != ChatCell.SYSTEM_MESSAGE ? LobbyChatCellOther : LobbyChatCellSystem,       // A non system meessage?
                                      Vector3.zero, Quaternion.identity, contentTransform);

                tempCell = tempObj.GetComponent <ChatCell>();
                tempCell.Init(fromData["name"] as string, signalData["message"] as string, profileId, fromData.ContainsKey("pic") ? fromData["pic"] as string : null, "", rank);

                GEventManager.TriggerEvent("NEW_LOBBY_CHAT");
            }
        }
예제 #10
0
    private void createBGM()
    {
        m_MusicMixer = Resources.Load("Audio/AudioMixer_Music") as AudioMixer;
        m_SFXMixer   = Resources.Load("Audio/AudioMixer_SFX") as AudioMixer;
        m_VoiceMixer = Resources.Load("Audio/AudioMixer_Voice") as AudioMixer;
        updateVolume();
        GEventManager.StartListening(GEventManager.ON_VOLUME_CHANGED, updateVolume);

        GameObject obj = new GameObject("BGM");

        DontDestroyOnLoad(obj);

        m_BGM                       = obj.AddComponent <AudioSource>();
        m_BGM.playOnAwake           = false;
        m_BGM.outputAudioMixerGroup = m_MusicMixer.FindMatchingGroups("Master")[0];
        m_BGM.loop                  = true;
        m_BGM.spatialBlend          = 0.0f;
    }
예제 #11
0
        private void addChatMessageToContent(Dictionary <string, object> in_jsonMessage, Transform contentTransform, bool in_lobbyView = false)
        {
            lock (contentTransform)
            {
                // populate based on the incoming data
                if (contentTransform.childCount >= 30)
                {
                    Destroy(contentTransform.transform.GetChild(0).gameObject);
                }

                ChatCell   tempCell;
                GameObject tempObj;
                Dictionary <string, object> jsonData = in_jsonMessage.ContainsKey("data") ?
                                                       (Dictionary <string, object>)in_jsonMessage["data"] : in_jsonMessage;

                Dictionary <string, object> fromData    = (Dictionary <string, object>)jsonData["from"];
                Dictionary <string, object> contentData = (Dictionary <string, object>)jsonData["content"];
                Dictionary <string, object> richData    = contentData.ContainsKey("rich") ? (Dictionary <string, object>)contentData["rich"] : null;

                string profileId        = fromData["id"] as string;
                string lastConnectionId = richData != null?richData.ContainsKey("lastConnectionId") ? richData["lastConnectionId"] as string : "" : "";

                int rank = richData != null?richData.ContainsKey("rank") ? (int)richData["rank"] : 0 : 0;

                tempObj = Instantiate(profileId == GCore.Wrapper.Client.ProfileId ? in_lobbyView ? LobbyChatCellYou : ChatCellYou :                                                   // is you!
                                      profileId != ChatCell.SYSTEM_MESSAGE ? in_lobbyView ? LobbyChatCellOther : ChatCellOther : in_lobbyView ? LobbyChatCellSystem : ChatCellSystem, // A non system meessage?   // haven't done these yet, probably from presence we will do this [TODO]
                                      Vector3.zero, Quaternion.identity, contentTransform);
                tempCell = tempObj.GetComponent <ChatCell>();

                tempCell.Init(fromData["name"] as string, contentData["text"] as string, profileId, fromData.ContainsKey("pic") ? fromData["pic"] as string : null,
                              lastConnectionId,
                              rank,
                              Convert.ToUInt64(jsonData["msgId"]),
                              (int)jsonData["ver"], in_jsonMessage, in_lobbyView);

                if (in_lobbyView)
                {
                    GEventManager.TriggerEvent("NEW_GLOBAL_CHAT");
                }
            }
        }
예제 #12
0
        private void onIdentitiesUpdated()
        {
            GEventManager.StopListening(GEventManager.ON_IDENTITIES_UPDATED, onIdentitiesUpdated);
#if STEAMWORKS_ENABLED
            if (!GPlayerMgr.Instance.IsSteamIdAttached())
            {
                GSteamAuthManager.Instance.AttachSteamAccount(true, onAttachSteamAccount, onAuthFail);
                m_lastAuthType = AuthenticationType.Steam;
            }
            else
#endif
            if (GPlayerMgr.Instance.IsUniversalIdAttached())
            {
                // universal IS ATTACHED
                GCore.Instance.ProcessRetryQueue();
                onCompleteConnectingSubState();
            }
            else
            {
                GStateManager.Instance.EnableLoadingSpinner(false);
                Panel.SetActive(true);
            }
        }
예제 #13
0
 protected override void OnDestroy()
 {
     base.OnDestroy();
     GEventManager.StopListening(GEventManager.ON_VOLUME_CHANGED, updateVolume);
 }