コード例 #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 static void EnterCore(int picId, int sliceId)
    {
        // save status
        lastPicId   = picId;
        lastSliceId = sliceId;

        // hide bg and show core page
        UIEngine.HideFlaoting <BackgroundFloating>();

        UIEngineHelper.WateAdmissionComplete(() => {
            UIEngine.Forward <CorePage>();
        });

        // load picture which player select
        var picFile       = StaticDataLite.GetCell <string>("pic", picId.ToString(), "file");
        var contentSprite = PicLibrary.LoadContentSprite(picFile);

        // load slice info
        var piceSize = StaticDataLite.GetCell <int>("pice_slice", sliceId.ToString(), "cell_size");

        // test code
        // piceSize = 400;

        // start core game
        Puzzle.Instance.StartPuzzle(contentSprite, piceSize);

        // when compelte
        Puzzle.Instance.Complete += OnCoreGameCompelte;

        //LocalNotification.SendNotification(1, 5000, "Title", "Long message text", new Color32(0xff, 0x44, 0x44, 255));
    }
コード例 #3
0
ファイル: PicLibrary.cs プロジェクト: Peng-Zhiyuan/puzzle
    public static Sprite LoadContentSpriteById(int id)
    {
        var row      = LoadDataRow(id);
        var fileName = row.Get <string>("file");
        var sprite   = PicLibrary.LoadContentSprite(fileName);

        return(sprite);
    }
コード例 #4
0
ファイル: DisplayPage.cs プロジェクト: Peng-Zhiyuan/puzzle
    public override void OnPush()
    {
        //button_gift.gameObject.SetActive(SDKManager.IsAdLoaded);
        image_pic.gameObject.SetActive(false);
        button_layout.gameObject.SetActive(false);
        var sprite = PicLibrary.LoadContentSpriteById(PicId);

        image_pic.sprite = sprite;
        CoroutineManager.Create(TimeTaks());
    }
コード例 #5
0
    void SetData(MainPage_Item item, MainPage_ItemData data)
    {
        // var sw = new Stopwatch();
        // sw.Start();

        item.data = data;
        item.gameObject.SetActive(data.visible);
        if (data.pageType == PicturePageType.Uncomplete)
        {
            uncompleteItem = item;
        }
        else if (data.pageType == PicturePageType.Complete)
        {
            completeItem = item;
        }
        if (!data.visible)
        {
            return;
        }

        // 如果是一个图片分类
        if (data.pageType == PicturePageType.Pictype)
        {
            item.label.text = data.row.Get <string>("display_name");
            var picType = data.row.Get <string>("id");
            var row     = PicLibrary.FindFirstRowOfType(picType);
            var file    = row?.Get <string>("file");
            var sprite  = PicLibrary.LoadContentSprite(file);
            item.Facade = sprite;

            item.name = data.row.TryGet <string>("id", "no_id");
            if (item.name == "animal")
            {
                animal = item;
            }
        }

        // 如果是未完成的拼图
        if (data.pageType == PicturePageType.Uncomplete)
        {
            item.label.text = "未完成";
            if (PlayerStatus.uncompletePuzzle.Count > 0)
            {
                var firstCoreInfo = PlayerStatus.FirstUncompletePuzzleInfo;
                var picId         = firstCoreInfo.picId;
                var picRow        = StaticDataLite.GetRow("pic", picId.ToString());
                var fileName      = picRow.Get <string>("file");
                var sprite        = PicLibrary.LoadContentSprite(fileName);
                item.Facade = sprite;
            }
        }

        // 如果是已完成的拼图
        if (data.pageType == PicturePageType.Complete)
        {
            item.label.text = "已完成";
            CompleteInfo firstInfo = null;
            foreach (var kv in PlayerStatus.completeDic)
            {
                firstInfo = kv.Value;
                break;
            }
            var picId    = firstInfo.pid;
            var picRow   = StaticDataLite.GetRow("pic", picId.ToString());
            var fileName = picRow.Get <string>("file");
            var sprite   = PicLibrary.LoadContentSprite(fileName);
            item.Facade = sprite;
        }


        // sw.Stop();
        // Debug.Log("set item: " + sw.Elapsed.TotalSeconds);
    }