/// <summary> /// 开关切换 /// </summary> /// <param name="view"></param> /// <param name="status"></param> public void onSwitchChange(GameObject view, int status) { SoundUtil.playSoundClip(AudioButtonOnClickEnum.btn_sound_3); if (view == mMusicSelectionSwith.gameObject) { CommonConfigure.IsOpenBGM = (EnabledEnum)Enum.ToObject(typeof(EnabledEnum), status); if ((int)CommonConfigure.IsOpenBGM == 0) { SoundUtil.stopBGMClip(); } else { SoundUtil.playBGMClip(); } } else if (view == mSoundSelectionSwitch.gameObject) { CommonConfigure.IsOpenSound = (EnabledEnum)Enum.ToObject(typeof(EnabledEnum), status); } else if (view == mTimeUISelectionSwith.gameObject) { CommonConfigure.IsOpenTimeUI = (EnabledEnum)Enum.ToObject(typeof(EnabledEnum), status); } CommonConfigure.saveData(); CommonConfigure.refreshData(); CommonData.refreshData(); }
/// <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); }
/// <summary> /// 创意工坊 /// </summary> private void workshopOnClick() { SoundUtil.playSoundClip(AudioButtonOnClickEnum.btn_sound_1); if (mUIMasterControl == null) { return; } mUIMasterControl.openUIByTypeAndCloseOther(UIEnum.MenuWorkshop); }
/// <summary> /// 进入拼图选择界面 /// </summary> private void startGameOnClick() { SoundUtil.playSoundClip(AudioButtonOnClickEnum.btn_sound_1); if (mUIMasterControl == null) { return; } mUIMasterControl.openUIByTypeAndCloseOther(UIEnum.MenuSelectUI); }
/// <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)); }
/// <summary> /// 进入自定义装扮界面 /// </summary> private void customOnClick() { SoundUtil.playSoundClip(AudioButtonOnClickEnum.btn_sound_1); //DialogManager.createToastDialog().setToastText(CommonData.getText(27)); if (mUIMasterControl == null) { return; } mUIMasterControl.openUIByTypeAndCloseOther(UIEnum.MenuEquipUI); }
/// <summary> /// 语言选择 /// </summary> /// <param name="position"></param> private void languageSelection(int position) { SoundUtil.playSoundClip(AudioButtonOnClickEnum.btn_sound_3); GameConfigureBean configure = DataStorageManage.getGameConfigureDSHandle().getData(0); configure.gameLanguage = position; DataStorageManage.getGameConfigureDSHandle().saveData(configure); CommonConfigure.refreshData(); CommonData.refreshData(); mUIMasterControl.refreshAllUI(); }
/// <summary> /// 开始上传图片 /// </summary> public void showUploadImage() { SoundUtil.playSoundClip(AudioButtonOnClickEnum.btn_sound_1); uploadPath = FileUtil.OpenFileDialog(); if (uploadPath == null || uploadPath.Length == 0) { uploadImage.color = new Color(0, 0, 0, 0); return; } uploadImage.color = Color.white; SelectCallBack callBack = new SelectCallBack(this); StartCoroutine(ResourcesManager.LoadAsyncLocationImage(uploadPath, uploadImage, callBack)); }
/// <summary> /// 屏幕模式 /// </summary> /// <param name="position"></param> private void screenModeSelection(int position) { SoundUtil.playSoundClip(AudioButtonOnClickEnum.btn_sound_3); if (position == 0) { Screen.fullScreen = true; } else { Screen.fullScreen = false; } GameConfigureBean configure = DataStorageManage.getGameConfigureDSHandle().getData(0); configure.screenMode = position; DataStorageManage.getGameConfigureDSHandle().saveData(configure); }
/// <summary> /// 提交数据 /// </summary> public void submitCustomData() { if (!checkData()) { return; } SoundUtil.playSoundClip(AudioButtonOnClickEnum.btn_sound_1); string markFileName = SystemUtil.getUUID(); PuzzlesInfoBean infoBean = new PuzzlesInfoBean(); infoBean.id = -1; infoBean.Name = inputName.text; infoBean.Horizontal_number = Convert.ToInt32(inputHorizontalNumber.text); infoBean.Vertical_number = Convert.ToInt32(inputVerticalNumber.text); infoBean.Level = 1; infoBean.Data_type = (int)JigsawResourcesEnum.Custom; infoBean.Mark_file_name = markFileName; infoBean.Data_file_path = CommonInfo.Custom_Res_Save_Path + "/"; FileUtil.CreateDirectory(CommonInfo.Custom_Res_Save_Path); FileUtil.CopyFile(uploadPath, CommonInfo.Custom_Res_Save_Path + "/" + markFileName, true); List <PuzzlesInfoBean> listInfoData = DataStorageManage.getCustomPuzzlesInfoDSHandle().getAllData(); if (listInfoData == null) { listInfoData = new List <PuzzlesInfoBean>(); } listInfoData.Add(infoBean); //保存数据 CustomPuzzlesInfoDSHandle handle = (CustomPuzzlesInfoDSHandle)DataStorageManage.getCustomPuzzlesInfoDSHandle(); handle.saveAllData(listInfoData); jumpSelectUI(); }
/// <summary> /// 解锁装备 /// </summary> /// <param name="data"></param> private void unlockEquip(Transform content, EquipInfoBean data, GameObject oldObj) { SoundUtil.playSoundClip(AudioButtonOnClickEnum.btn_sound_1); long userPoint = DataStorageManage.getUserInfoDSHandle().getData(0).puzzlesPoint; if (userPoint < data.unlockPoint) { //如果没有PP则提示不足 DialogManager.createToastDialog().setToastText(CommonData.getText(16)); } else { //如果有PP则解锁 //保存信息 ((UserInfoDSHandle)DataStorageManage.getUserInfoDSHandle()).decreaseUserPuzzlesPoint(data.unlockPoint); m_EquipUIControl.refreshPuzzlesPoint(); data.unlockType = 1; DataStorageManage.getEquipDSHandle().saveData(data); createEquipItem(content, data); Destroy(oldObj); } }
/// <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); }
/// <summary> /// 跳转自定义拼图界面 /// </summary> private void jumpAddCustomUI() { SoundUtil.playSoundClip(AudioButtonOnClickEnum.btn_sound_1); menuSelectUIControl.mUIMasterControl.openUIByTypeAndCloseOther(UIEnum.MenuCustomUpLoadUI); }
/// <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 void addExitOnClick() { SoundUtil.playSoundClip(AudioButtonOnClickEnum.btn_sound_2); StopAllCoroutines(); mUIMasterControl.openUIByTypeAndCloseOther(UIEnum.MenuMainUI); }
/// <summary> /// 离开游戏 /// </summary> private void exitOnClick() { SoundUtil.playSoundClip(AudioButtonOnClickEnum.btn_sound_1); SystemUtil.exitGame(); }
/// <summary> /// 退出游戏 /// </summary> private void exitOnClick() { SoundUtil.playSoundClip(AudioButtonOnClickEnum.btn_sound_3); deleteData(); SceneUtil.jumpMainScene(); }
/// <summary> /// 打开暂停菜单 /// </summary> public void openPauseBT() { SoundUtil.playSoundClip(AudioButtonOnClickEnum.btn_sound_1); mUIMasterControl.openUIByTypeAndCloseOther(UIEnum.GamePauseUI); }
/// <summary> /// 重新开始游戏 /// </summary> private void restartOnClick() { SoundUtil.playSoundClip(AudioButtonOnClickEnum.btn_sound_1); deleteData(); SceneUtil.jumpGameScene(); }
/// <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> public void addExitOnClick() { SoundUtil.playSoundClip(AudioButtonOnClickEnum.btn_sound_2); CommonConfigure.saveData(); mUIMasterControl.openUIByTypeAndCloseOther(UIEnum.MenuMainUI); }
/// <summary> /// 创建 /// </summary> public void CreateOnClick() { SoundUtil.playSoundClip(AudioButtonOnClickEnum.btn_sound_1); mUIMasterControl.openUIByTypeAndCloseOther(UIEnum.MenuWorkshopCreate); }
/// <summary> /// 关闭当前页面 /// </summary> public void cancelUI() { SoundUtil.playSoundClip(AudioButtonOnClickEnum.btn_sound_3); mUIMasterControl.openUIByTypeAndCloseOther(UIEnum.GameMainUI); }
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> private void ExitOnClick() { loadingBT.gameObject.SetActive(false); SoundUtil.playSoundClip(AudioButtonOnClickEnum.btn_sound_2); mUIMasterControl.openUIByTypeAndCloseOther(UIEnum.MenuWorkshop); }