Пример #1
0
    void SetItem(PictruePage_Item item, PictruePage_ItemData data)
    {
        item.data = data;
        item.name = data.picRow.TryGet <string>("id", "none-id");
        if (item.name == "1")
        {
            pic1 = item;
        }
        switch (data.status)
        {
        case PicturePage_ItemStatus.Locked:
            item.IsShowPuzzleMask  = true;
            item.IsShowUnlockLayer = true;
            item.IsShowPice        = false;
            var unlockGold       = data.picRow.Get <int>("cost");
            var unlockButotnText = unlockGold + "金币解锁";
            item.UnlockButtonText = unlockButotnText;
            break;

        case PicturePage_ItemStatus.Unlocked:
        {
            item.IsShowPuzzleMask  = true;
            item.IsShowUnlockLayer = false;

            var picId = data.picRow.Get <int>("id");
            var info  = PlayerStatus.TryGetUncompleteOfPicId(picId);
            if (info != null)
            {
                var sliceCount = StaticDataLite.GetCell <int>("pice_slice", info.sliceId.ToString(), "count");
                item.PiceCount  = sliceCount;
                item.IsShowPice = true;
            }
            else
            {
                item.IsShowPice = false;
            }
            break;
        }

        case PicturePage_ItemStatus.Complete:
        {
            item.IsShowPuzzleMask  = false;
            item.IsShowUnlockLayer = false;
            item.IsShowPice        = true;
            var picId = data.picRow.Get <int>("id");
            var info  = PlayerStatus.GetCompleteInfoOfPicId(picId);
            if (info != null)
            {
                var sliceCount = StaticDataLite.GetCell <int>("pice_slice", info.sliceId.ToString(), "count");
                item.PiceCount = sliceCount;
            }
            break;
        }
        }
        item.LabelText = data.picRow.Get <string>("name");
        var file   = data.picRow.Get <string>("file");
        var sprite = PicLibrary.LoadContentSprite(file);

        item.Sprite = sprite;
    }
Пример #2
0
    public override void OnPush()
    {
        // 如果要显示的是某个图片分类
        if (p.pageType == PicturePageType.Pictype)
        {
            // 从 pic 表中找出所有 type 是 param 的数据行
            // 并且包装成 PicturePage_ItemData
            var sheet    = StaticDataLite.GetSheet("pic");
            var pictype  = this.p.picTypeId;
            var dataList = new List <PictruePage_ItemData>();
            foreach (string key in sheet.Keys)
            {
                var row = sheet[key];
                if (row.Get <string>("type") == pictype)
                {
                    var data = new PictruePage_ItemData
                    {
                        picRow = row,
                    };
                    // check unlock info
                    var unlocked = LevelStorage.IsPictureUnlocked(key);
                    var complete = PlayerStatus.IsPictureComplete(int.Parse(key));
                    var status   = PicturePage_ItemStatus.Locked;
                    if (complete)
                    {
                        status = PicturePage_ItemStatus.Complete;
                    }
                    else if (unlocked)
                    {
                        status = PicturePage_ItemStatus.Unlocked;
                    }
                    data.status = status;
                    dataList.Add(data);
                }
            }
            this.setDataList(dataList);

            // set picture count
            var completePictureCount = 0;
            var pictureCount         = dataList.Count;
            foreach (var data in dataList)
            {
                if (data.status == PicturePage_ItemStatus.Complete)
                {
                    completePictureCount++;
                }
            }
            text_pictureCount.text = completePictureCount + "/" + pictureCount;
        }

        // 如果要显示的是未完成的拼图
        if (p.pageType == PicturePageType.Uncomplete)
        {
            var dataList = new List <PictruePage_ItemData>();
            foreach (var kv in PlayerStatus.uncompletePuzzle)
            {
                var info   = kv.Value;
                var picRow = StaticDataLite.GetRow("pic", info.picId.ToString());

                var data = new PictruePage_ItemData
                {
                    picRow = picRow,
                };
                data.status = PicturePage_ItemStatus.Unlocked;
                dataList.Add(data);
            }
            this.setDataList(dataList);

            text_pictureCount.text = PlayerStatus.uncompletePuzzle.Count.ToString();
        }

        // 如果要显示已完成的图片
        if (p.pageType == PicturePageType.Complete)
        {
            var dataList = new List <PictruePage_ItemData>();
            foreach (var kv in PlayerStatus.completeDic)
            {
                var info   = kv.Value;
                var picId  = info.pid;
                var picRow = StaticDataLite.GetRow("pic", picId.ToString());

                var data = new PictruePage_ItemData
                {
                    picRow = picRow,
                };
                data.status = PicturePage_ItemStatus.Complete;
                dataList.Add(data);
            }
            text_pictureCount.text = dataList.Count.ToString();
            this.setDataList(dataList);
        }
    }