/// <summary> /// 刷新制定ITEM /// </summary> public void refreshItemJigsawSelectData(int position, GameObject itemObj, PuzzlesGameInfoBean itemInfo) { GameObject newItem = jigsawSelectContentSC.createNormalItem(itemInfo); newItem.transform.SetParent(jigsawSelectContentTF); newItem.transform.SetSiblingIndex(position); Destroy(itemObj); }
public static List <PuzzlesGameInfoBean> MergePuzzlesInfo(List <PuzzlesInfoBean> listInfo, List <PuzzlesCompleteStateBean> listCompleteState, List <PuzzlesProgressBean> listProgressInfo) { List <PuzzlesGameInfoBean> listData = new List <PuzzlesGameInfoBean>(); if (listInfo == null) { LogUtil.log("合并拼图数据和完成数据失败-没有原始数据"); return(listData); } int listInfoSize = listInfo.Count; for (int i = 0; i < listInfoSize; i++) { PuzzlesGameInfoBean itemData = new PuzzlesGameInfoBean(); PuzzlesInfoBean tempInfo = listInfo[i]; itemData.puzzlesInfo = tempInfo; //合并完成状态 if (listCompleteState != null) { int listCompleteStateSize = listCompleteState.Count; for (int f = 0; f < listCompleteStateSize; f++) { PuzzlesCompleteStateBean tempCompleteState = listCompleteState[f]; if (tempInfo.data_type.Equals((int)JigsawResourcesEnum.Custom)) { if (tempInfo.mark_file_name.Equals(tempCompleteState.puzzleMarkName) && tempInfo.Data_type.Equals(tempCompleteState.puzzleType)) { itemData.completeStateInfo = tempCompleteState; } } else { if (tempInfo.Id.Equals(tempCompleteState.puzzleId) && tempInfo.Data_type.Equals(tempCompleteState.puzzleType)) { itemData.completeStateInfo = tempCompleteState; } } } } //合并进度信息 if (listProgressInfo != null) { int listProgressSize = listProgressInfo.Count; for (int f = 0; f < listProgressSize; f++) { PuzzlesProgressBean tempProgressInfo = listProgressInfo[f]; if (tempInfo.id.Equals(tempProgressInfo.puzzleId) && tempInfo.mark_file_name.Equals(tempProgressInfo.markFileName)) { itemData.progressInfo = tempProgressInfo; } } } listData.Add(itemData); } return(listData); }
/// <summary> /// 创建盘排行榜弹窗 /// </summary> /// <param name="dialogType">0有当前成绩 1无当前成绩</param> /// <param name="gameInfoBean">拼图相关数据</param> /// <returns></returns> public static LeaderBoardDialog createLeaderBoradDialog(int dialogType, PuzzlesGameInfoBean gameInfoBean) { if (gameInfoBean == null || gameInfoBean.puzzlesInfo == null) { return(null); } GameObject dialogObj = Instantiate(ResourcesManager.LoadData <GameObject>("Prefab/UI/Common/LeaderBoardDialog")); LeaderBoardDialog dialog = dialogObj.GetComponent <LeaderBoardDialog>(); dialog.setDialogType(dialogType); dialog.setPuzzlesInfo(gameInfoBean); return(dialog); }
public void CreateInstallItemList(List <SteamWorkshopQueryInstallInfoBean> listData) { //删除原数据 for (int i = 0; i < transform.childCount; i++) { if (transform.GetChild(i).gameObject.activeSelf) { Destroy(transform.GetChild(i).gameObject); } } List <PuzzlesInfoBean> listPuzzlesInfo = CreateGameInfoListByInstallInfo(listData); List <PuzzlesCompleteStateBean> listCompleteData = DataStorageManage.getPuzzlesCompleteDSHandle().getAllData(); List <PuzzlesProgressBean> listProgressData = DataStorageManage.getPuzzlesProgressDSHandle().getAllData(); List <PuzzlesGameInfoBean> listGameInfoData = PuzzlesDataUtil.MergePuzzlesInfo(listPuzzlesInfo, listCompleteData, listProgressData); for (int itemPosition = 0; itemPosition < listData.Count; itemPosition++) { PuzzlesGameInfoBean itemInfo = listGameInfoData[itemPosition]; CreateInstallItem(itemInfo); } }
/// <summary> /// 读取拼图信息 /// </summary> /// <param name="resourcesEnum"></param> public void loadJigsaw(JigsawResourcesEnum resourcesEnum) { StopAllCoroutines(); resourcesType = resourcesEnum; //删除原数据 for (int i = 0; i < transform.childCount; i++) { Destroy(transform.GetChild(i).gameObject); } //加载该类型下所有拼图数据 List <PuzzlesInfoBean> listInfoData = null; if (resourcesEnum.Equals(JigsawResourcesEnum.Custom)) { listInfoData = DataStorageManage.getCustomPuzzlesInfoDSHandle().getAllData(); createAddItem(); } else { listInfoData = PuzzlesInfoManager.LoadAllPuzzlesDataByType(resourcesEnum); } if (listInfoData == null || listInfoData.Count == 0) { return; } listInfoData.Sort((x, y) => x.Level.CompareTo(y.Level)); List <PuzzlesCompleteStateBean> listCompleteData = DataStorageManage.getPuzzlesCompleteDSHandle().getAllData(); List <PuzzlesProgressBean> listProgressData = DataStorageManage.getPuzzlesProgressDSHandle().getAllData(); List <PuzzlesGameInfoBean> listData = PuzzlesDataUtil.MergePuzzlesInfo(listInfoData, listCompleteData, listProgressData); for (int itemPosition = 0; itemPosition < listData.Count; itemPosition++) { PuzzlesGameInfoBean itemInfo = listData[itemPosition]; createSelectItem(itemPosition, itemInfo); } }
/// <summary> /// 创建相对应按钮 /// </summary> /// <param name="itemInfo"></param> private void createSelectItem(int position, PuzzlesGameInfoBean itemInfo) { PuzzlesInfoBean infoBean = itemInfo.puzzlesInfo; PuzzlesCompleteStateBean completeStateBean = itemInfo.completeStateInfo; GameObject selectItem; if (infoBean.data_type.Equals((int)JigsawResourcesEnum.Custom)) { selectItem = createCustomItem(itemInfo); } else { if (completeStateBean == null || completeStateBean.unlockState.Equals(JigsawUnlockEnum.Lock)) { if (infoBean.level == 1) { selectItem = createNormalItem(itemInfo); } else { selectItem = createLockItem(position, itemInfo); } } else { selectItem = createNormalItem(itemInfo); } } //添加动画 //if(selectItem!=null) //{ // CanvasGroup itemCG= selectItem.GetComponent<CanvasGroup>(); // itemCG.alpha = 0; // itemCG.DOFade(1, 1); //} }
private GameObject CreateInstallItem(PuzzlesGameInfoBean itemInfo) { PuzzlesInfoBean infoBean = itemInfo.puzzlesInfo; PuzzlesCompleteStateBean completeStateBean = itemInfo.completeStateInfo; itemInfo.completeStateInfo = completeStateBean; itemInfo.puzzlesInfo = infoBean; GameObject itemObj = Instantiate(installModel); itemObj.transform.parent = this.transform; itemObj.transform.localScale = new Vector3(1f, 1f, 1f); itemObj.SetActive(true); itemObj.name = infoBean.Mark_file_name; itemObj.transform.SetParent(transform); //设置背景图片 Image backImage = CptUtil.getCptFormParentByName <Transform, Image>(itemObj.transform, "JigsawPic"); string filePath = infoBean.thumb_file_path; StartCoroutine(ResourcesManager.LoadAsyncHttpImage(filePath, backImage)); //设置按键 Button startBT = CptUtil.getCptFormParentByName <Transform, Button>(itemObj.transform, "JigsawStart"); Text startBTText = CptUtil.getCptFormParentByName <Transform, Text>(itemObj.transform, "JigsawStartText"); if (!CheckUtil.StringIsNull(infoBean.data_file_path)) { startBT.onClick.AddListener(delegate() { SoundUtil.playSoundClip(AudioButtonOnClickEnum.btn_sound_1); CommonData.SelectPuzzlesInfo = itemInfo; SceneUtil.jumpGameScene(); }); if (itemInfo.progressInfo != null) { startBTText.text = CommonData.getText(85); } else { startBTText.text = CommonData.getText(14); } } else { startBTText.text = CommonData.getText(130); } //最好分数 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"); jigsawNameText.text = infoBean.Name; return(itemObj); }
/// <summary> /// 记录完成时间 /// </summary> /// <param name="selectItem"></param> /// <param name="completeTime"></param> public static void FinshSaveCompleteData(PuzzlesGameInfoBean selectItem, TimeBean completeTime) { PuzzlesInfoBean puzzlesInfo = selectItem.puzzlesInfo; PuzzlesCompleteStateBean completeStateBean = selectItem.completeStateInfo; if (completeStateBean == null) { completeStateBean = new PuzzlesCompleteStateBean(); } List <PuzzlesCompleteStateBean> listCompleteState = DataStorageManage.getPuzzlesCompleteDSHandle().getAllData(); if (listCompleteState == null || listCompleteState.Count == 0) { listCompleteState = new List <PuzzlesCompleteStateBean>(); completeStateBean.puzzleId = puzzlesInfo.id; completeStateBean.puzzleType = puzzlesInfo.data_type; completeStateBean.puzzleName = puzzlesInfo.name; completeStateBean.puzzleMarkName = puzzlesInfo.mark_file_name; completeStateBean.completeTime = completeTime; completeStateBean.unlockState = JigsawUnlockEnum.UnLock; listCompleteState.Add(completeStateBean); } else { int listCompleteSize = listCompleteState.Count; bool hasData = false; for (int i = 0; i < listCompleteSize; i++) { PuzzlesCompleteStateBean itemCompleteBean = listCompleteState[i]; bool isThisPuzzles = false; if (itemCompleteBean.puzzleType.Equals((int)JigsawResourcesEnum.Custom)) { if (itemCompleteBean.puzzleMarkName.Equals(puzzlesInfo.mark_file_name)) { isThisPuzzles = true; } } else { if (itemCompleteBean.puzzleId.Equals(puzzlesInfo.Id)) { isThisPuzzles = true; } } if (isThisPuzzles) { hasData = true; if (itemCompleteBean.completeTime.totalSeconds != 0 && !TimeUtil.isFasterTime(itemCompleteBean.completeTime, completeTime)) { //存时间更快的 } else { itemCompleteBean.puzzleId = puzzlesInfo.id; itemCompleteBean.puzzleType = puzzlesInfo.data_type; completeStateBean.puzzleName = puzzlesInfo.name; completeStateBean.puzzleMarkName = puzzlesInfo.mark_file_name; itemCompleteBean.unlockState = JigsawUnlockEnum.UnLock; itemCompleteBean.completeTime = completeTime; completeStateBean = itemCompleteBean; } break; } } if (!hasData) { completeStateBean.puzzleId = puzzlesInfo.id; completeStateBean.puzzleType = puzzlesInfo.data_type; completeStateBean.puzzleName = puzzlesInfo.name; completeStateBean.puzzleMarkName = puzzlesInfo.mark_file_name; completeStateBean.completeTime = completeTime; completeStateBean.unlockState = JigsawUnlockEnum.UnLock; listCompleteState.Add(completeStateBean); } } DataStorageManage.getPuzzlesCompleteDSHandle().saveAllData(listCompleteState); }
/// <summary> /// 设置拼图信息 /// </summary> /// <param name="gameInfoBean"></param> public void setPuzzlesInfo(PuzzlesGameInfoBean gameInfoBean) { mGameInfoBean = gameInfoBean; }
/// <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); }
/// <summary> /// 创建正常样式 /// </summary> public GameObject createNormalItem(PuzzlesGameInfoBean itemInfo) { PuzzlesInfoBean infoBean = itemInfo.puzzlesInfo; PuzzlesCompleteStateBean completeStateBean = itemInfo.completeStateInfo; GameObject itemObj = Instantiate(ResourcesManager.LoadData <GameObject>(JigsawSelectItemPath)); Button itemBT = itemObj.GetComponent <Button>(); //设置大小 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.LoadAsyncDataImage(filePath + "_Thumb", backImage)); //设置状态 Text puzzleStatus = CptUtil.getCptFormParentByName <Transform, Text>(itemObj.transform, "JigsawStatus"); if (completeStateBean == null || completeStateBean.completeTime == null || completeStateBean.completeTime.totalSeconds == 0) { Material material = new Material(Shader.Find("Custom/Gray")); backImage.material = material; puzzleStatus.gameObject.SetActive(true); puzzleStatus.text = CommonData.getText(32); } else { puzzleStatus.gameObject.SetActive(false); puzzleStatus.text = CommonData.getText(32); } //设置按键 Button startBT = CptUtil.getCptFormParentByName <Transform, Button>(itemObj.transform, "JigsawStart"); startBT.onClick.AddListener(delegate() { SoundUtil.playSoundClip(AudioButtonOnClickEnum.btn_sound_1); CommonData.SelectPuzzlesInfo = itemInfo; SceneUtil.jumpGameScene(); }); Button scoreBT = CptUtil.getCptFormParentByName <Transform, Button>(itemObj.transform, "JigsawScore"); scoreBT.onClick.AddListener(delegate() { SoundUtil.playSoundClip(AudioButtonOnClickEnum.btn_sound_1); DialogManager.createLeaderBoradDialog(1, itemInfo); }); //设置文本信息 Text jigsawNameText = CptUtil.getCptFormParentByName <Button, Text>(itemBT, "JigsawName"); Text startBTText = CptUtil.getCptFormParentByName <Button, Text>(itemBT, "JigsawStartText"); Text scoreBTText = CptUtil.getCptFormParentByName <Button, Text>(itemBT, "JigsawScoreText"); jigsawNameText.text = infoBean.Name; scoreBTText.text = CommonData.getText(15); if (itemInfo.progressInfo != null) { startBTText.text = CommonData.getText(85); } else { startBTText.text = CommonData.getText(14); } //设置拼图等级 setLevel(itemObj, infoBean.level); return(itemObj); }
/// <summary> /// 创建未解锁样式 /// </summary> /// <param name="itemInfo"></param> private GameObject createLockItem(int position, PuzzlesGameInfoBean itemInfo) { PuzzlesInfoBean infoBean = itemInfo.puzzlesInfo; PuzzlesCompleteStateBean completeStateBean = itemInfo.completeStateInfo; //解锁点数处理 if (infoBean.unlock_point == 1) { infoBean.unlock_point = infoBean.level; } GameObject itemObj = Instantiate(ResourcesManager.LoadData <GameObject>(JigsawSelectLockItemPath)); Button itemBT = itemObj.GetComponent <Button>(); //设置大小 setItemSize(itemObj); itemObj.name = infoBean.Mark_file_name; itemObj.transform.SetParent(transform); //设置按键 Button unLockBT = CptUtil.getCptFormParentByName <Transform, Button>(itemObj.transform, "JigsawUnLock"); unLockBT.onClick.AddListener( delegate() { SoundUtil.playSoundClip(AudioButtonOnClickEnum.btn_sound_1); long userPoint = DataStorageManage.getUserInfoDSHandle().getData(0).puzzlesPoint; if (userPoint < infoBean.unlock_point) { //如果没有PP则提示不足 DialogManager.createToastDialog().setToastText(CommonData.getText(16)); } else { //如果有PP则解锁 //保存信息 ((UserInfoDSHandle)DataStorageManage.getUserInfoDSHandle()).decreaseUserPuzzlesPoint(infoBean.unlock_point); menuSelectUIControl.refreshPuzzlesPoint(); //解锁拼图 if (completeStateBean == null) { completeStateBean = new PuzzlesCompleteStateBean(); completeStateBean.puzzleId = infoBean.id; completeStateBean.puzzleType = infoBean.data_type; } completeStateBean.unlockState = JigsawUnlockEnum.UnLock; DataStorageManage.getPuzzlesCompleteDSHandle().saveData(completeStateBean); //menuSelectUIControl.refreshJigsawSelectData(); menuSelectUIControl.refreshItemJigsawSelectData(position, itemObj, itemInfo); //解锁成功动画 string filePath = infoBean.Data_file_path + infoBean.Mark_file_name; DialogManager.createUnlockPuzzlesDialog(infoBean.name, infoBean.mark_file_name, filePath); } }); //设置文本信息 Text jigsawUnLockText = CptUtil.getCptFormParentByName <Button, Text>(itemBT, "JigsawUnLockText"); jigsawUnLockText.text = CommonData.getText(13) + "( " + infoBean.unlock_point + "PP )"; //设置拼图等级 setLevel(itemObj, infoBean.level); return(itemObj); }