Ejemplo n.º 1
0
        private void Start()
        {
            initializePoolWhenPlayerItemPrefabIsLoaded = false;
            profileDataList    = new List <ProfileData>();
            membershipDataList = new List <MembershipData>();
            pooledScrollRect   = GetComponentInChildren <VerticalGridPooledScrollRect>();
            addPooledScrollRectObservers();
            playerAvatarRenderer = GetComponent <AvatarImageComponent>();
            AvatarImageComponent avatarImageComponent = playerAvatarRenderer;

            avatarImageComponent.OnImageReady = (Action <DataEntityHandle, Texture2D>)Delegate.Combine(avatarImageComponent.OnImageReady, new Action <DataEntityHandle, Texture2D>(onImageReady));
            initPlayersList();
            dataEntityCollection.EventDispatcher.AddListener <DataEntityEvents.ComponentAddedEvent <ProfileData> >(onProfileDataAdded);
            dataEntityCollection.EventDispatcher.AddListener <DataEntityEvents.ComponentAddedEvent <MembershipData> >(onMembershipDataAdded);
            PromptManager promptManager = Service.Get <PromptManager>();

            promptManager.PromptCreated = (Action <GameObject>)Delegate.Combine(promptManager.PromptCreated, new Action <GameObject>(onPromptCreated));
            List <string> playerSwids = getPlayerSwids();

            if (playerSwids.Count > 0)
            {
                Service.Get <INetworkServicesManager>().PlayerStateService.GetOnlinePlayersBySwids(playerSwids);
            }
            else
            {
                onlineStatusReceived = true;
            }
            Content.LoadAsync(onPlayerItemPrefabLoaded, PlayerItemContentKey);
            start();
            isInitialized = true;
        }
Ejemplo n.º 2
0
        private void OnDestroy()
        {
            if (playerAvatarRenderer != null)
            {
                AvatarImageComponent avatarImageComponent = playerAvatarRenderer;
                avatarImageComponent.OnImageReady = (Action <DataEntityHandle, Texture2D>)Delegate.Remove(avatarImageComponent.OnImageReady, new Action <DataEntityHandle, Texture2D>(onImageReady));
            }
            if (dataEntityCollection != null)
            {
                dataEntityCollection.EventDispatcher.RemoveListener <DataEntityEvents.ComponentAddedEvent <ProfileData> >(onProfileDataAdded);
            }
            if (profileDataList != null)
            {
                for (int i = 0; i < profileDataList.Count; i++)
                {
                    profileDataList[i].ProfileDataUpdated -= onProfileDataUpdated;
                }
            }
            if (membershipDataList != null)
            {
                for (int i = 0; i < membershipDataList.Count; i++)
                {
                    membershipDataList[i].MembershipDataUpdated -= onMembershipDataUpdated;
                }
            }
            removePooledScrollRectObservers();
            PromptManager promptManager = Service.Get <PromptManager>();

            promptManager.PromptCreated = (Action <GameObject>)Delegate.Remove(promptManager.PromptCreated, new Action <GameObject>(onPromptCreated));
            onDestroy();
        }
        private void Start()
        {
            dataEntityCollection = Service.Get <CPDataEntityCollection>();
            membershipDataList   = new List <MembershipData>();
            friendAvatarRenderer = GetComponent <AvatarImageComponent>();
            AvatarImageComponent avatarImageComponent = friendAvatarRenderer;

            avatarImageComponent.OnImageReady = (Action <DataEntityHandle, Texture2D>)Delegate.Combine(avatarImageComponent.OnImageReady, new Action <DataEntityHandle, Texture2D>(onImageReady));
            dataEntityCollection.EventDispatcher.AddListener <DataEntityEvents.ComponentAddedEvent <MembershipData> >(onMembershipDataAdded);
            incomingFriendInvitationsList = FriendsDataModelService.IncomingInvitationsList;
            createIncomingFriendInvitations(incomingFriendInvitationsList);
            bool active = incomingFriendInvitationsList.Count > 0;

            FriendsRequestsHeader.SetActive(active);
            screenTitle    = Service.Get <Localizer>().GetTokenTranslation("Friends.FriendRequestContent.FriendRequestText");
            TitleText.text = string.Format(screenTitle, incomingFriendInvitationsList.Count);
            isInitialized  = true;
        }
        private void Start()
        {
            avatarImageComponent = GetComponent <AvatarImageComponent>();
            AvatarImageComponent obj = avatarImageComponent;

            obj.OnImageReady = (Action <DataEntityHandle, Texture2D>)Delegate.Combine(obj.OnImageReady, new Action <DataEntityHandle, Texture2D>(onImageReady));
            CPDataEntityCollection cPDataEntityCollection = Service.Get <CPDataEntityCollection>();
            DataEntityHandle       localPlayerHandle      = cPDataEntityCollection.LocalPlayerHandle;

            if (!localPlayerHandle.IsNull)
            {
                AvatarAnimationFrame avatarAnimationFrame = new AvatarAnimationFrame(AnimationStateName, AnimationNormalizedTime);
                avatarImageComponent.RequestImage(localPlayerHandle, avatarAnimationFrame, Context);
            }
            else
            {
                Log.LogError(this, "Local player handle was null");
            }
        }
 private void OnDestroy()
 {
     if (dataEntityCollection != null)
     {
         dataEntityCollection.EventDispatcher.RemoveListener <DataEntityEvents.ComponentAddedEvent <MembershipData> >(onMembershipDataAdded);
     }
     if (friendAvatarRenderer != null)
     {
         AvatarImageComponent avatarImageComponent = friendAvatarRenderer;
         avatarImageComponent.OnImageReady = (Action <DataEntityHandle, Texture2D>)Delegate.Remove(avatarImageComponent.OnImageReady, new Action <DataEntityHandle, Texture2D>(onImageReady));
     }
     if (membershipDataList != null)
     {
         for (int i = 0; i < membershipDataList.Count; i++)
         {
             membershipDataList[i].MembershipDataUpdated -= onMembershipDataUpdated;
         }
     }
 }