/// <summary>
    /// 跳转到拼图选择界面(自定义模块)
    /// </summary>
    public void jumpSelectUI()
    {
        SoundUtil.playSoundClip(AudioButtonOnClickEnum.btn_sound_3);
        MenuSelectUIControl selectUIControl = mUIMasterControl.getUIByType <MenuSelectUIControl>(UIEnum.MenuSelectUI);

        mUIMasterControl.openUIByTypeAndCloseOther(UIEnum.MenuSelectUI);
        selectUIControl.setJigsawSelectData(JigsawResourcesEnum.Custom);
    }
Ejemplo n.º 2
0
    /// <summary>
    /// 创建按键
    /// </summary>
    /// <param name="resType"></param>
    private void createSelectItem(JigsawResourcesEnum resType)
    {
        string resTypeIconPath;
        string resName;

        EnumUtil.getResTypeInfo(resType, out resName, out resTypeIconPath);
        if (resName == null || resName.Length == 0 || resTypeIconPath == null || resTypeIconPath.Length == 0)
        {
            return;
        }
        GameObject buttonObj = Instantiate(ResourcesManager.LoadData <GameObject>(ResTypeSelectItemPath));

        //设置大小
        RectTransform rect      = buttonObj.GetComponent <RectTransform>();
        float         itemWith  = transform.GetComponent <RectTransform>().rect.width;
        float         itemHight = transform.GetComponent <RectTransform>().rect.width * 0.5f;

        rect.sizeDelta = new Vector2(itemWith, itemHight);

        TabButton tabButton = buttonObj.GetComponent <TabButton>();

        buttonObj.name = resType.ToString();
        buttonObj.transform.SetParent(transform);
        buttonObj.transform.localScale = new Vector3(1, 1, 1);
        tabButton.setResType(resType);
        //设置按键
        Button selectBT = buttonObj.GetComponent <Button>();

        selectBT.onClick.AddListener(delegate()
        {
            SoundUtil.playSoundClip(AudioButtonOnClickEnum.btn_sound_1);
            TabButton[] listTab = transform.GetComponentsInChildren <TabButton>();
            foreach (TabButton itemTab in listTab)
            {
                if (tabButton != null && tabButton == itemTab)
                {
                    itemTab.setSelect(true);
                }
                else
                {
                    itemTab.setSelect(false);
                }
            }
            menuSelectUIControl.setJigsawSelectData(resType);
        });

        //设置文本信息
        Text resTypeNameTV = CptUtil.getCptFormParentByName <Transform, Text>(buttonObj.transform, "ResTypeName");

        resTypeNameTV.text = resName;

        //设置图片信息
        Image resTypeIcon = CptUtil.getCptFormParentByName <Transform, Image>(buttonObj.transform, "ResTypeIcon");

        StartCoroutine(ResourcesManager.LoadAsyncDataImage(resTypeIconPath, resTypeIcon));
    }
Ejemplo n.º 3
0
    /// <summary>
    /// 创建自定义样式
    /// </summary>
    /// <param name="itemInfo"></param>
    private GameObject createCustomItem(PuzzlesGameInfoBean itemInfo)
    {
        PuzzlesInfoBean          infoBean          = itemInfo.puzzlesInfo;
        PuzzlesCompleteStateBean completeStateBean = itemInfo.completeStateInfo;

        GameObject itemObj = Instantiate(ResourcesManager.LoadData <GameObject>(JigsawSelectCustomItemPath));

        //设置大小
        setItemSize(itemObj);

        itemObj.name = infoBean.Mark_file_name;
        itemObj.transform.SetParent(transform);

        //设置背景图片
        Image  backImage = CptUtil.getCptFormParentByName <Transform, Image>(itemObj.transform, "JigsawPic");
        string filePath  = infoBean.Data_file_path + infoBean.Mark_file_name;

        StartCoroutine(ResourcesManager.LoadAsyncLocationImage(filePath, backImage));

        //设置按键
        Button startBT = CptUtil.getCptFormParentByName <Transform, Button>(itemObj.transform, "JigsawStart");

        startBT.onClick.AddListener(delegate()
        {
            SoundUtil.playSoundClip(AudioButtonOnClickEnum.btn_sound_1);
            CommonData.SelectPuzzlesInfo = itemInfo;
            SceneUtil.jumpGameScene();
        });
        //最好分数
        Transform bestScoreTF = CptUtil.getCptFormParentByName <Transform, Transform>(itemObj.transform, "JigsawBestScore");
        Text      bestScore   = CptUtil.getCptFormParentByName <Transform, Text>(itemObj.transform, "JigsawBestScoreText");

        if (completeStateBean != null && completeStateBean.completeTime != null)
        {
            bestScore.text = GameUtil.GetTimeStr(completeStateBean.completeTime.totalSeconds);
        }
        else
        {
            bestScoreTF.gameObject.SetActive(false);
        }

        //设置文本信息
        Text jigsawNameText = CptUtil.getCptFormParentByName <Transform, Text>(itemObj.transform, "JigsawName");
        Text startBTText    = CptUtil.getCptFormParentByName <Transform, Text>(itemObj.transform, "JigsawStartText");

        if (itemInfo.progressInfo != null)
        {
            startBTText.text = CommonData.getText(85);
        }
        else
        {
            startBTText.text = CommonData.getText(14);
        }


        jigsawNameText.text = infoBean.Name;

        //设置按钮信息
        //编辑按钮
        //Button editBT = CptUtil.getCptFormParentByName<Transform, Button>(itemObj.transform, "JigsawEdit");
        //editBT.onClick.AddListener(delegate ()
        //{
        //    SoundUtil.playSoundClip(AudioButtonOnClickEnum.btn_sound_1);
        //    MenuCustomUpLoadUIControl upLoadUIControl = menuSelectUIControl.mUIMasterControl.getUIByType<MenuCustomUpLoadUIControl>(UIEnum.MenuCustomUpLoadUI);
        //    upLoadUIControl.setInitData(infoBean);
        //    menuSelectUIControl.mUIMasterControl.openUIByTypeAndCloseOther(UIEnum.MenuCustomUpLoadUI);
        //});
        //删除按钮
        Button deleteBT = CptUtil.getCptFormParentByName <Transform, Button>(itemObj.transform, "JigsawDelete");

        deleteBT.onClick.AddListener(delegate()
        {
            SoundUtil.playSoundClip(AudioButtonOnClickEnum.btn_sound_1);
            FileUtil.DeleteFile(filePath);
            CustomPuzzlesInfoDSHandle handle = (CustomPuzzlesInfoDSHandle)DataStorageManage.getCustomPuzzlesInfoDSHandle();
            handle.removeData(infoBean);
            menuSelectUIControl.setJigsawSelectData(JigsawResourcesEnum.Custom);
        });
        return(itemObj);
    }