コード例 #1
0
        public override void BindData(int currentIndex, Room data)
        {
            _data = data;
            if (data == null)
            {
                // 如果没有数据的话,应该怎么显示房间按钮呢?
                // 房间可以不显示,但是是不是要显示在线人数。
                return;
            }

            // 载入人数和底注。
            BaseMoney.SetCurrency(_data.base_money, CurrencyType.GOLDEN_EGG);
            PlayerCount.text = "" + data.current_player_num;

            // 载入房间图片。
            if (string.IsNullOrEmpty(data.room_pic))
            {
                RoomPic.Reset();
            }
            else
            {
                var resourcePath = GetAssetBundleByPicNameMap.GetAssetBundleName(data.room_pic);
                RoomPic.SetTargetPic(data.room_pic, resourcePath, data.room_pic_url);
            }

            if (data.type == RoomType.Ad)
            {
                RoomContainer.SetActive(false);
                TagContainer.SetActive(false);
                var hintItem = data.hint_item;
                if (hintItem != null && !string.IsNullOrEmpty(hintItem.content_pic))
                {
                    var contentPic = _resourceCache.LoadSpriteFromLocalFile(hintItem.content_pic);
                    if (!contentPic)
                    {
                        if (!string.IsNullOrEmpty(hintItem.content_pic_url) &&
                            !_resourceCache.ContainsDownloadTask(hintItem.content_pic))
                        {
                            _resourceCache.StartDownload(
                                hintItem.content_pic,
                                hintItem.content_pic_url,
                                ContentType.Image);
                        }
                    }
                }
            }
            else
            {
                RoomContainer.SetActive(true);
                TagContainer.SetActive(true);
            }

            // 设置标签。
            if (!string.IsNullOrEmpty(data.tag))
            {
                if (!Tag1Group.activeSelf)
                {
                    Tag1Group.SetActive(true);
                }

                Tag1.text = data.tag;
            }
            else
            {
                if (Tag1Group.activeSelf)
                {
                    Tag1Group.SetActive(false);
                }
            }

            if (!string.IsNullOrEmpty(data.tag1))
            {
                if (!Tag2Group.activeSelf)
                {
                    Tag2Group.SetActive(true);
                }

                Tag2.text = data.tag1;
            }
            else
            {
                if (Tag2Group.activeSelf)
                {
                    Tag2Group.SetActive(false);
                }
            }

            if (!Button.gameObject.activeSelf)
            {
                Button.gameObject.SetActive(true);
            }
        }
コード例 #2
0
        public void Update()
        {
            if (Status != StatusChecking)
            {
                return;
            }

            // 更新WaitingImage:
            if (WaitingImage)
            {
                var tr        = WaitingImage.transform;
                var curAngle  = tr.rotation.eulerAngles.z;
                var destAngle = curAngle - (360f / WaitingRotateTime) * Time.deltaTime;
                if (destAngle < 0)
                {
                    destAngle += 360f;
                }
                tr.rotation = Quaternion.Euler(0, 0, destAngle);
            }

            // 检查图片是否已经存在。
            if (!ContentImage)
            {
                return;
            }

            if (Time.time - LastCheckTime < _checkInterval)
            {
                return;
            }

            LastCheckTime = Time.time;

            Sprite sprite;

            if (_downLoadByUrl)
            {
                sprite = _resourceCache.LoadSpriteFromLocalFile(PicName);
            }
            else
            {
                if (string.IsNullOrEmpty(ResourcePath))
                {
                    MyLog.ErrorWithFrame(name, "从图片名找不到Assetbundle :" + PicName);
                    return;
                }

                sprite = _resource.GetResource <Sprite>(ResourcePath, PicName);
                if (sprite)
                {
                    _resourceCache.AddSpriteToCache(PicName, sprite);
                }
            }

            if (sprite)
            {
                ContentImage.sprite = sprite;
                if (NativeSize)
                {
                    ContentImage.SetNativeSize();
                }

                SwitchToStatus(StatusComplete);
            }
        }