/// <summary> /// 保存并退出 /// </summary> public void saveAndExitOnClick() { if (CommonData.GameStatus == 1) { CommonData.GameStatus = 4; PuzzlesProgressBean progressBean = new PuzzlesProgressBean(); GameMainUIControl gameMainUI = mUIMasterControl.getUIByType <GameMainUIControl>(UIEnum.GameMainUI); if (gameMainUI != null) { //设置游戏时间 progressBean.gameTime = gameMainUI.getGameTimer(); } //设置ID progressBean.puzzleId = CommonData.SelectPuzzlesInfo.puzzlesInfo.id; progressBean.markFileName = CommonData.SelectPuzzlesInfo.puzzlesInfo.mark_file_name; progressBean.progress = GameUtil.getGameProgress(); DataStorageManage.getPuzzlesProgressDSHandle().saveData(progressBean); SceneUtil.jumpMainScene(); } else { DialogManager.createToastDialog().setToastText("不能进行此操作"); } }
//--------------------------------------------------------------------------------------------- /// <summary> /// 开始游戏 /// </summary> public void gameStart() { //判断是否有存档 PuzzlesProgressBean paramsData = new PuzzlesProgressBean(); paramsData.puzzleId = CommonData.SelectPuzzlesInfo.puzzlesInfo.id; paramsData.markFileName = CommonData.SelectPuzzlesInfo.puzzlesInfo.mark_file_name; PuzzlesProgressBean progressData = DataStorageManage.getPuzzlesProgressDSHandle().getData(paramsData); TimeBean gameTime = null; if (progressData != null) { gameTime = progressData.gameTime; GameUtil.setGameProgress(this, progressData); } else { } CommonData.IsCheating = false; CommonData.GameStatus = 1; CommonData.IsDargMove = true; Camera.main.gameObject.AddComponent <SecretCodeCpt>(); GameMainUIControl gameMainUI = uiMasterControl.getUIByType <GameMainUIControl>(UIEnum.GameMainUI); if (gameMainUI != null) { gameMainUI.startTimer(gameTime); } }
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); }
private void deleteData() { PuzzlesProgressBean paramsData = new PuzzlesProgressBean(); paramsData.markFileName = CommonData.SelectPuzzlesInfo.puzzlesInfo.mark_file_name; paramsData.puzzleId = CommonData.SelectPuzzlesInfo.puzzlesInfo.id; ((PuzzlesProgressDSHandle)DataStorageManage .getPuzzlesProgressDSHandle()) .deleteData(paramsData); }
/// <summary> /// 读取拼图进度 /// </summary> /// <param name="content"></param> /// <param name="progressBean"></param> public static void setGameProgress(BaseMonoBehaviour content, PuzzlesProgressBean progressBean) { JigsawContainerCpt[] cptList = UnityEngine.Object.FindObjectsOfType <JigsawContainerCpt>(); if (cptList == null || cptList.Length == 0) { return; } List <PuzzlesProgressItemBean> progress = progressBean.progress; foreach (PuzzlesProgressItemBean itemProgress in progress) { JigsawContainerCpt tempCpt = null; //其次需要合并的子对象 List <JigsawContainerCpt> tempListCpt = new List <JigsawContainerCpt>(); foreach (JigsawContainerCpt itemCpt in cptList) { //首先获取父对象 if (itemCpt.listJigsaw[0].MarkLocation == itemProgress.markPostion) { tempCpt = itemCpt; } foreach (Vector2 listPuzzleItem in itemProgress.listPuzzles) { if (listPuzzleItem == itemCpt.listJigsaw[0].MarkLocation) { tempListCpt.Add(itemCpt); } } } JigsawContainerCpt[] tempArraryCpt = DevUtil.listToArray(tempListCpt); if (tempCpt != null) { //设置不可在拖拽 CommonData.IsDargMove = false; content.StartCoroutine(delayComplete(content, tempArraryCpt, tempCpt, 1f)); } } }
/// <summary> /// 游戏完成 /// </summary> public void gameFinsh() { CommonData.GameStatus = 2; CommonData.IsDargMove = false; CommonData.IsMoveCamera = false; //删除游戏进度 PuzzlesProgressBean progressTemp = new PuzzlesProgressBean(); progressTemp.puzzleId = CommonData.SelectPuzzlesInfo.puzzlesInfo.id; progressTemp.markFileName = CommonData.SelectPuzzlesInfo.puzzlesInfo.mark_file_name; ((PuzzlesProgressDSHandle)DataStorageManage.getPuzzlesProgressDSHandle()).deleteData(progressTemp); float startCameraOrthographicSize = cameraControl.startCameraOrthographicSize; //结束游戏时间 GameMainUIControl gameMainUI = uiMasterControl.getUIByType <GameMainUIControl>(UIEnum.GameMainUI); TimeBean completeTime = null; if (gameMainUI != null) { gameMainUI.endTimer(); completeTime = gameMainUI.getGameTimer(); } if (!CommonData.IsCheating) { if (CommonData.SelectPuzzlesInfo.puzzlesInfo.data_type.Equals((int)JigsawResourcesEnum.Custom)) { } else { //增加PP int addPuzzlesPoint = CommonData.SelectPuzzlesInfo.puzzlesInfo.level * 2; DialogManager.createPuzzlesPointAddDialog(addPuzzlesPoint); } //保存数据 GameUtil.FinshSaveCompleteData(CommonData.SelectPuzzlesInfo, completeTime); } //动画结束后显示排行榜 transform.DOScale(new Vector3(1, 1), gameFinshAnimTime).OnComplete(delegate() { if (CommonData.SelectPuzzlesInfo.puzzlesInfo.data_type.Equals((int)JigsawResourcesEnum.Custom)) { SceneUtil.jumpMainScene(); } else { int leaderType = 0; if (CommonData.IsCheating) { leaderType = 1; } else { //没有作弊 放烟花 //GameObject dialogObj = Instantiate(ResourcesManager.LoadData<GameObject>("Prefab/Particle/Background/GameFinshParticle")); //Canvas gameFinshCanvas = dialogObj.GetComponent<Canvas>(); //gameFinshCanvas.renderMode = RenderMode.ScreenSpaceCamera; //gameFinshCanvas.worldCamera = Camera.main; } DialogManager .createLeaderBoradDialog(leaderType, CommonData.SelectPuzzlesInfo) .setUserScore(completeTime.totalSeconds) .setCallBack(this) .setCancelButtonStr(CommonData.getText(21)) .setSubmitButtonStr(CommonData.getText(23)); } CommonData.IsCheating = false; }); //镜头移动 cameraControl.transform.DOMove(cameraControl.startCameraPosition, gameFinshAnimTime); Tween cameraTW = DOTween .To(() => Camera.main.orthographicSize, x => Camera.main.orthographicSize = x, startCameraOrthographicSize, gameFinshAnimTime); //图像归位 int containerListSize = containerList.Count; for (int i = 0; i < containerListSize; i++) { GameObject container = containerList[i]; if (container != null) { JigsawContainerCpt containerCpt = container.GetComponent <JigsawContainerCpt>(); Rigidbody2D containerRB = container.GetComponent <Rigidbody2D>(); containerRB.Sleep(); container.transform.DORotate(new Vector3(containerCpt.startRotation.x, containerCpt.startRotation.y), gameFinshAnimTime); container.transform.DOMove(containerCpt.startPosition, gameFinshAnimTime); break; } } //设置成就 List <PuzzlesCompleteStateBean> listCompleteState = ((PuzzlesCompleteDSHandle)DataStorageManage.getPuzzlesCompleteDSHandle()).getDefAllData(); if (listCompleteState != null && listCompleteState.Count != 0) { int completeNumber = 0; foreach (PuzzlesCompleteStateBean itemState in listCompleteState) { if (itemState.completeTime != null && itemState.completeTime.totalSeconds != 0) { completeNumber++; } } IUserAchievementHandle userAchievement = new UserStatsHandleImpl(); userAchievement.userCompleteNumberChange(completeNumber); } }