コード例 #1
0
    public void SetUp(PlayerIndexProfileData _data)
    {
        profileData = _data;
        Debug.Assert(!string.IsNullOrEmpty(profileData.profileModel));
        profileModel         = GameUtil.ConvertToPlayFabPlayerProfilemodel(profileData.profileModel);
        player_name_txt.text = profileModel.DisplayName;
        Debug.Log(player_name_txt.text + "time " + profileData.playerFinishTime);
        var TimeSpan = System.TimeSpan.FromTicks(System.Convert.ToInt64(profileData.playerFinishTime));

        player_time_txt.text = TimeSpan.ToString(@"mm\:ss\:fff");
    }
コード例 #2
0
    public void SetData(Player playerData, Color color)
    {
        Debug.Log("player " + playerData.CustomProperties);
        if (!playerData.CustomProperties.ContainsKey(PlayerPropertiesKey.PLAYFAB_PROFILE))
        {
            Debug.LogError(PlayerPropertiesKey.PLAYFAB_PROFILE + "Key not found");
            return;
        }
        var playerProfileJson = playerData.CustomProperties[PlayerPropertiesKey.PLAYFAB_PROFILE] as string;

        if (!string.IsNullOrEmpty(playerProfileJson))
        {
            profilemodel = GameUtil.ConvertToPlayFabPlayerProfilemodel(playerProfileJson.ToString());
        }
        else
        {
            Debug.LogError("playerProfileJson is string empty or null");
        }
        userId = playerData.UserId;
        playername_text.text = profilemodel.DisplayName;
        playerColor          = color;
        // bg_image.color = color;
    }
コード例 #3
0
    void CreateSlider()
    {
        Debug.Log("createSlider ");

        Hashtable property        = PhotonNetwork.CurrentRoom.CustomProperties;
        Hashtable playerData      = property[RoomPropertyKeys.PLAYER_DATA] as Hashtable;
        Hashtable playerIndexData = property[RoomPropertyKeys.PLAYER_INDEX] as Hashtable;

        Debug.LogWarningFormat("playerindex data {0}", playerIndexData);
        /// เกมถัดไปจากครั้งแรกมักเจอ error
        foreach (var playerIndex in playerIndexData)
        {
            Debug.Log(string.Format("index key {0} vale {1}", playerIndex.Key, playerIndex.Value));
            var slider = Instantiate(playerSliderPrefab, Vector3.zero, Quaternion.identity, transformParent);
            Debug.Log("transformParent " + transformParent);
            Debug.Log("Slider " + slider);
            slider.name = playerIndex.Key.ToString();
            slider.transform.localPosition = Vector3.zero;
            PlayerSliderPrefab sliderPrefab   = slider.GetComponent <PlayerSliderPrefab>();
            sliderPrefab.GetSlider().minValue = startPoint;
            sliderPrefab.GetSlider().maxValue = finishPoint;
            Debug.Assert(!dic_playerSlider.ContainsKey(playerIndex.Key.ToString()));
            if (dic_playerSlider.ContainsKey(playerIndex.Key.ToString()))
            {
                Debug.Log("Destroy dic_playerslider");
                Destroy(dic_playerSlider[playerIndex.Key.ToString()].gameObject);
                dic_playerSlider.Remove(playerIndex.Key.ToString());
            }
            dic_playerSlider.Add(playerIndex.Key.ToString(), sliderPrefab);
            var playerIndexProfileData = JsonConvert.DeserializeObject <PlayerIndexProfileData>(playerIndex.Value.ToString());
            var playerProfileModel     = GameUtil.ConvertToPlayFabPlayerProfilemodel(playerIndexProfileData.profileModel);


            var playerDistanceData = new PlayerDistanceData {
                playerIndex = playerIndexProfileData.index,
                userID      = playerIndexProfileData.userId,
                playerName  = playerProfileModel.DisplayName,
                distance    = startPoint
            };
            if (dic_playerDistance.ContainsKey(playerIndex.Key.ToString()))
            {
                Debug.Log("remove dic_playerslider");
                dic_playerDistance[playerIndex.Key.ToString()] = null;
                dic_playerDistance.Remove(playerIndex.Key.ToString());
            }
            print(Depug.Log("CheckplayerKey " + playerIndex.Key, Color.white));
            print(Depug.Log("dic_playerDistance null? " + dic_playerDistance, Color.white));



            dic_playerDistance.Add(playerIndex.Key.ToString(), playerDistanceData);
            print(Depug.Log("dic_playerDistance containkey? " + dic_playerDistance.ContainsKey(playerIndex.Key.ToString()), Color.green));
            if (playerIndex.Key.ToString() == PhotonNetwork.LocalPlayer.UserId)
            {
                localUserId    = PhotonNetwork.LocalPlayer.UserId;
                myDistanceData = playerDistanceData;
                mySliderPrefab = sliderPrefab;
            }
            sliderPrefab.SetUpData(playerData, colorRank[playerDistanceData.playerIndex]);
        }
        if (mySliderPrefab != null)
        {
            mySliderPrefab.transform.parent.SetAsLastSibling();
        }


        print(Depug.Log("stripstringkey = " + PhotonNetwork.CurrentRoom.CustomProperties.StripToStringKeys(), Color.red));
    }