/// <summary> /// 初始化数据 /// </summary> private void initData() { if (mListStatus == null) { return; } Transform switchItem = CptUtil.getCptFormParentByName <Transform, Transform>(transform, "SwitchImage"); Button switchBT = transform.GetComponent <Button>(); if (switchItem == null) { return; } mListSwitchItem = new List <GameObject>(); for (int i = 0; i < mListStatus.Count; i++) { GameObject itemObj = createSwitchImage(switchItem, i); mListSwitchItem.Add(itemObj); } Destroy(switchItem.gameObject); if (switchBT != null) { switchBT.onClick.AddListener(switchClick); } }
private void Awake() { timeText = CptUtil.getCptFormParentByName <Transform, Text>(transform, "GameTimerText"); timeMinuteHand = CptUtil.getCptFormParentByName <Transform, Image>(transform, "TimeMinuteHand"); timeSecondHand = CptUtil.getCptFormParentByName <Transform, Image>(transform, "TimeSecondHand"); mTimeSeoundText = CptUtil.getCptFormParentByName <Transform, Text>(transform, "GameTimerSeoundText"); mTimeMinuteText = CptUtil.getCptFormParentByName <Transform, Text>(transform, "GameTimerMinuteText"); mTimeHoursText = CptUtil.getCptFormParentByName <Transform, Text>(transform, "GameTimerHoursText"); mTimeDayText = CptUtil.getCptFormParentByName <Transform, Text>(transform, "GameTimerDayText"); mMinuteAnimaotr = mTimeMinuteText.GetComponent <Animator>(); mHourAnimaotr = mTimeHoursText.GetComponent <Animator>(); mDayAnimaotr = mTimeDayText.GetComponent <Animator>(); if (timeMinuteHand != null) { timeMinuteAnimaotr = timeMinuteHand.GetComponent <Animator>(); } if (timeSecondHand != null) { timeSecondAnimaotr = timeSecondHand.GetComponent <Animator>(); } gameObject.SetActive(false); }
private new void Awake() { base.Awake(); //初始化标题栏 mJigsawSelectTiltebar = CptUtil.getCptFormParentByName <Transform, Transform>(transform, "TitleBar"); mTitleBarExitBT = CptUtil.getCptFormParentByName <Transform, Button>(mJigsawSelectTiltebar, "ExitBT"); if (mTitleBarExitBT != null) { mTitleBarExitBT.onClick.AddListener(addExitOnClick); } //初始化语言下拉 mLanguageSelectionTitle = CptUtil.getCptFormParentByName <Transform, Text>(transform, "LanguageSelectionTitle"); mLanguageSelectionDropdown = CptUtil.getCptFormParentByName <Transform, Dropdown>(transform, "LanguageSelectionDropdown"); //初始化BGM mMusicSelectionTitle = CptUtil.getCptFormParentByName <Transform, Text>(transform, "MusicSelectionTitle"); mMusicSelectionSwith = CptUtil.getCptFormParentByName <Transform, SwitchButton>(transform, "MusicSelectionSwitch"); //初始化音效 mSoundSelectionTitle = CptUtil.getCptFormParentByName <Transform, Text>(transform, "SoundSelectionTitle"); mSoundSelectionSwitch = CptUtil.getCptFormParentByName <Transform, SwitchButton>(transform, "SoundSelectionSwitch"); //初始化模式选择 mScreenModeTitle = CptUtil.getCptFormParentByName <Transform, Text>(transform, "ScreenModeTitle"); mScreenModeDropdown = CptUtil.getCptFormParentByName <Transform, Dropdown>(transform, "ScreenModeDropdown"); //初始化分辨率选择 //mScreenResolutionTitle = CptUtil.getCptFormParentByName<Transform, Text>(transform, "ScreenResolutionTitle"); //mScreenResolutionDropdown = CptUtil.getCptFormParentByName<Transform, Dropdown>(transform, "ScreenResolutionDropdown"); musicSlider.onValueChanged.AddListener(musicSliderListener); soundSlider.onValueChanged.AddListener(soundSliderListener); refreshUI(); }
private void createLeaderBoardItem(LeaderBoardItemData itemData) { GameObject itemObj = Instantiate(ResourcesManager.LoadData <GameObject>(LeaderBoardItemPath)); //设置大小 RectTransform rect = itemObj.GetComponent <RectTransform>(); float itemWith = mWorldRank.GetComponent <RectTransform>().rect.width; float itemHight = mWorldRank.GetComponent <RectTransform>().rect.width * 0.05f; rect.sizeDelta = new Vector2(itemWith, itemHight); itemObj.name = itemData.userId; itemObj.transform.SetParent(mWorldRank); itemObj.transform.localScale = Vector3.one; //设置头像图片 Image userIcon = CptUtil.getCptFormParentByName <Transform, Image>(itemObj.transform, "UserIcon"); StartCoroutine(ResourcesManager.LoadAsyncHttpImage(itemData.steamUserItemInfo.avatarmedium, userIcon)); //设置名字 Text userName = CptUtil.getCptFormParentByName <Transform, Text>(itemObj.transform, "UserName"); userName.text = itemData.steamUserItemInfo.personaname; //设置排名 Text userRank = CptUtil.getCptFormParentByName <Transform, Text>(itemObj.transform, "UserRank"); userRank.text = itemData.leaderboardEntries.rank + ""; //设置分数 Text userScore = CptUtil.getCptFormParentByName <Transform, Text>(itemObj.transform, "UserScore"); userScore.text = GameUtil.GetTimeStr(itemData.leaderboardEntries.score); }
private new void Awake() { base.Awake(); gameTimerTF = CptUtil.getCptFormParentByName <Transform, Transform>(transform, "GameTimer"); if (gameTimerTF != null) { gameTimerControlCpt = gameTimerTF.gameObject.AddComponent <GameTimerControlCpt>(); } gameInfoBT = CptUtil.getCptFormParentByName <Transform, Button>(transform, "GameInfoBT"); gamePauseBT = CptUtil.getCptFormParentByName <Transform, Button>(transform, "GamePauseBT"); gameOIBT = CptUtil.getCptFormParentByName <Transform, Button>(transform, "GameOIBT"); // gameMusicBT = CptUtil.getCptFormParentByName<Transform, Button>(transform, "GameMusicBT"); gameInfoBT.onClick.AddListener(openGameInfo); gamePauseBT.onClick.AddListener(openPauseBT); gameOIBT.onClick.AddListener(openOI); CanvasGroup timeUI = gameTimerTF.GetComponent <CanvasGroup>(); if (CommonConfigure.IsOpenTimeUI == EnabledEnum.ON) { timeUI.alpha = 1; } else { timeUI.alpha = 0; } // gameMusicBT.onClick.AddListener(openGameMusic); }
private new void Awake() { base.Awake(); startGameBT = CptUtil.getCptFormParentByName <Canvas, Button>(mUICanvas, "StartGameBT"); startGameText = CptUtil.getCptFormParentByName <Button, Text>(startGameBT, "StartGameText"); customBT = CptUtil.getCptFormParentByName <Canvas, Button>(mUICanvas, "CustomBT"); customText = CptUtil.getCptFormParentByName <Button, Text>(customBT, "CustomText"); settingBT = CptUtil.getCptFormParentByName <Canvas, Button>(mUICanvas, "SettingBT"); settingText = CptUtil.getCptFormParentByName <Button, Text>(settingBT, "SettingText"); exitBT = CptUtil.getCptFormParentByName <Canvas, Button>(mUICanvas, "ExitBT"); exitText = CptUtil.getCptFormParentByName <Button, Text>(exitBT, "ExitText"); workshopBT = CptUtil.getCptFormParentByName <Canvas, Button>(mUICanvas, "WorkshopBT"); workshopText = CptUtil.getCptFormParentByName <Button, Text>(workshopBT, "WorkshopText"); mLogoTitle1 = CptUtil.getCptFormParentByName <Transform, Image>(transform, "LogoTitle1"); mLogoTitle2 = CptUtil.getCptFormParentByName <Transform, Image>(transform, "LogoTitle2"); mLogoTitleBT1 = CptUtil.getCptFormParentByName <Transform, Button>(transform, "LogoTitle1"); mLogoTitleBT2 = CptUtil.getCptFormParentByName <Transform, Button>(transform, "LogoTitle2"); startGameBT.onClick.AddListener(startGameOnClick); customBT.onClick.AddListener(customOnClick); settingBT.onClick.AddListener(settingOnClick); exitBT.onClick.AddListener(exitOnClick); workshopBT.onClick.AddListener(workshopOnClick); mLogoTitleBT1.onClick.AddListener(makerOnClick); mLogoTitleBT2.onClick.AddListener(makerOnClick); refreshUI(); }
private JigsawResourcesEnum currentResType;//当前选择数据类型 private new void Awake() { base.Awake(); //初始化拼图选择类型数据 resTypeSelectView = CptUtil.getCptFormParentByName <Transform, ScrollRect>(transform, "ResTypeSelectView"); resTypeSelectContentTF = CptUtil.getCptFormParentByName <ScrollRect, Transform>(resTypeSelectView, "Content"); if (resTypeSelectContentTF != null) { resTypeSelectContentSC = resTypeSelectContentTF.gameObject.AddComponent <JigsawResTypeSelect>(); resTypeSelectContentSC.setMenuSelectUIControl(this); } //初始化拼图选择数据 jigsawSelectView = CptUtil.getCptFormParentByName <Transform, ScrollRect>(transform, "JigsawSelectView"); jigsawSelectContentTF = CptUtil.getCptFormParentByName <ScrollRect, Transform>(jigsawSelectView, "Content"); if (jigsawSelectContentTF != null) { jigsawSelectContentSC = jigsawSelectContentTF.gameObject.AddComponent <JigsawSelect>(); jigsawSelectContentSC.setMenuSelectUIControl(this); } //初始化标题栏 jigsawSelectTiltebar = CptUtil.getCptFormParentByName <Transform, Transform>(transform, "TitleBar"); titleBarExitBT = CptUtil.getCptFormParentByName <Transform, Button>(jigsawSelectTiltebar, "ExitBT"); titleBarJigsawPointTV = CptUtil.getCptFormParentByName <Transform, Text>(jigsawSelectTiltebar, "PuzzlesPointText"); titleBarTitleName = CptUtil.getCptFormParentByName <Transform, Text>(jigsawSelectTiltebar, "TitleName"); if (titleBarExitBT != null) { titleBarExitBT.onClick.AddListener(addExitOnClick); } refreshUI(); }
private new void Awake() { base.Awake(); uploadImage = CptUtil.getCptFormParentByName <Transform, Image>(transform, "UploadImageContent"); uploadBT = CptUtil.getCptFormParentByName <Transform, Button>(transform, "UploadImage"); inputName = CptUtil.getCptFormParentByName <Transform, InputField>(transform, "InputName"); inputHorizontalNumber = CptUtil.getCptFormParentByName <Transform, InputField>(transform, "InputHorizontalNumber"); inputVerticalNumber = CptUtil.getCptFormParentByName <Transform, InputField>(transform, "InputVerticalNumber"); inputNameTitle = CptUtil.getCptFormParentByName <Transform, Text>(transform, "InputNameTitle"); inputHorizontalNumberTitle = CptUtil.getCptFormParentByName <Transform, Text>(transform, "InputHorizontalNumberTitle"); inputVerticalNumberTitle = CptUtil.getCptFormParentByName <Transform, Text>(transform, "InputVerticalNumberTitle"); tvCancel = CptUtil.getCptFormParentByName <Transform, Text>(transform, "CancelText"); tvSubmit = CptUtil.getCptFormParentByName <Transform, Text>(transform, "SubmitText"); tvHint = CptUtil.getCptFormParentByName <Transform, Text>(transform, "UploadHint"); submitBT = CptUtil.getCptFormParentByName <Transform, Button>(transform, "SubmitBT"); cancelBT = CptUtil.getCptFormParentByName <Transform, Button>(transform, "CancelBT"); cancelBT.onClick.AddListener(delegate { jumpSelectUI(); }); refreshUI(); }
/// <summary> /// 创建文本控件 /// </summary> /// <param name="title"></param> /// <param name="content"></param> private void createTextItem(string title, string content, int contentTextSize) { GameObject textObj = Instantiate(ResourcesManager.LoadData <GameObject>(GameInfoTextItem)); Text titleText = CptUtil.getCptFormParentByName <Transform, Text>(textObj.transform, "GameInfoTextTitle"); Text contentText = CptUtil.getCptFormParentByName <Transform, Text>(textObj.transform, "GameInfoTextContent"); //设置内容 titleText.text = title; contentText.text = content; //设置样式 if (contentTextSize != 0) { contentText.fontSize = contentTextSize; contentText.resizeTextMaxSize = contentTextSize; } //设置高度 RectTransform textTF = textObj.GetComponent <RectTransform>(); float contentTextHight = contentText.preferredHeight; if (textTF != null) { textTF.sizeDelta = new Vector2(textTF.rect.width, contentTextHight); } //添加文本 textObj.transform.parent = transform; //设置大小 RectTransform rect = textObj.GetComponent <RectTransform>(); float itemWith = transform.GetComponent <RectTransform>().rect.width; float itemHight = textObj.GetComponent <RectTransform>().rect.height + 10; rect.sizeDelta = new Vector2(itemWith, itemHight); }
private new void Awake() { base.Awake(); restartBT = CptUtil.getCptFormParentByName <Transform, Button>(transform, "RestartButton"); restartText = CptUtil.getCptFormParentByName <Transform, Text>(transform, "RestartText"); exitBT = CptUtil.getCptFormParentByName <Transform, Button>(transform, "ExitButton"); exitText = CptUtil.getCptFormParentByName <Transform, Text>(transform, "ExitText"); replayBT = CptUtil.getCptFormParentByName <Transform, Button>(transform, "ReplayButton"); replayText = CptUtil.getCptFormParentByName <Transform, Text>(transform, "ReplayText"); saveAndExitBT = CptUtil.getCptFormParentByName <Transform, Button>(transform, "SaveAndExitButton"); saveAndExitText = CptUtil.getCptFormParentByName <Transform, Text>(transform, "SaveAndExitText"); restartBT.onClick.AddListener(restartOnClick); exitBT.onClick.AddListener(exitOnClick); replayBT.onClick.AddListener(replayOnClick); saveAndExitBT.onClick.AddListener(saveAndExitOnClick); gameCancelBT = CptUtil.getCptFormParentByName <Transform, Button>(transform, "GameCancelBT"); gameCancelBT.onClick.AddListener(cancelUI); restartText.text = CommonData.getText(38); exitText.text = CommonData.getText(39); replayText.text = CommonData.getText(40); saveAndExitText.text = CommonData.getText(84); }
private void InitTags() { if (tagsGroup == null) { return; } List <string> tags = new List <string>(); tags.Add("other"); tags.Add("painting"); tags.Add("anime"); tags.Add("life"); tags.Add("movie"); tags.Add("people"); tags.Add("animal"); tags.Add("scenery"); tags.Add("starrysky"); tags.Add("food"); tags.Add("game"); tags.Add("celebrity"); listTag = new List <Toggle>(); for (int i = 0; i < tags.Count; i++) { GameObject tagObj = Instantiate(tagModel); tagObj.name = tags[i]; tagObj.SetActive(true); tagObj.transform.parent = tagsGroup.transform; tagObj.transform.localScale = new Vector3(1f, 1f, 1f); Text tagText = CptUtil.getCptFormParentByName <Transform, Text>(tagObj.transform, "Label"); tagText.text = tags[i]; listTag.Add(tagObj.GetComponent <Toggle>()); } }
/// <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)); }
// Use this for initialization void Start() { mTVToast = CptUtil.getCptFormParentByName <Transform, Text>(transform, "ToastText"); mTVToast.text = mToastText; transform .DOScale(new Vector3(1, 1, 1), mToastTime) .OnComplete(delegate() { Destroy(gameObject); }); }
void Start() { mPuzzlesPointIcon = CptUtil.getCptFormParentByName <Transform, Image>(transform, "PuzzlesPointIcon"); mPuzzelsPointContent = CptUtil.getCptFormParentByName <Transform, Text>(transform, "PuzzlesPointContent"); mPuzzlesPointAdd = CptUtil.getCptFormParentByName <Transform, CanvasGroup>(transform, "PuzzlesPointAdd"); mPuzzlesPointAddIcon = CptUtil.getCptFormParentByName <Transform, Image>(transform, "PuzzlesPointAddIcon"); mPuzzlesPointAddContent = CptUtil.getCptFormParentByName <Transform, Text>(transform, "PuzzlesPointAddContent"); initData(); startAdd(); }
private void createMusicSelectItem(BGMInfoBean itemData) { GameObject itemObj = Instantiate(ResourcesManager.LoadData <GameObject>(GameMusicSelectItem)); Button itemBT = itemObj.GetComponent <Button>(); itemBT.onClick.AddListener(() => changeMusic(itemBT, itemData)); Text itemText = CptUtil.getCptFormParentByName <Transform, Text>(itemObj.transform, "MusicSelectItemText"); itemObj.transform.SetParent(transform); itemText.text = itemData.Name; }
void Start() { mDialogCanvas = GetComponent <Canvas>(); mDialogCanvas.renderMode = RenderMode.ScreenSpaceCamera; mDialogCanvas.worldCamera = Camera.main; mDialogCanvas.sortingLayerName = "UITop"; mBTBackGround = CptUtil.getCptFormParentByName <Transform, Button>(transform, "DialogBackGround"); mUnlockPuzzlesImage = CptUtil.getCptFormParentByName <Transform, Image>(transform, "UnlockPuzzlesImage"); mBTUnlockPuzzles = CptUtil.getCptFormParentByName <Transform, Button>(transform, "UnlockPuzzles"); mUnlockPuzzlesName = CptUtil.getCptFormParentByName <Transform, Text>(transform, "UnlockPuzzlesName"); mBTBackGround.onClick.AddListener(cancel); mBTUnlockPuzzles.onClick.AddListener(cancel); initData(); }
private new void Awake() { base.Awake(); //初始化标题栏 mJigsawSelectTiltebar = CptUtil.getCptFormParentByName <Transform, Transform>(transform, "TitleBar"); mTitleBarExitBT = CptUtil.getCptFormParentByName <Transform, Button>(mJigsawSelectTiltebar, "ExitBT"); mMakerContent = CptUtil.getCptFormParentByName <Transform, Transform>(transform, "Content"); mMakerSelect = mMakerContent.gameObject.AddComponent <MakerSelect>(); if (mTitleBarExitBT != null) { mTitleBarExitBT.onClick.AddListener(addExitOnClick); } }
private new void Awake() { base.Awake(); gameCancelBT = CptUtil.getCptFormParentByName <Transform, Button>(transform, "GameCancelBT"); gameCancelBT.onClick.AddListener(cancelUI); mTVTitle = CptUtil.getCptFormParentByName <Transform, Text>(transform, "GameOITitle"); mTVMouseSelectContent = CptUtil.getCptFormParentByName <Transform, Text>(transform, "GameOIMouseSelectText"); mTVMouseMoveContent = CptUtil.getCptFormParentByName <Transform, Text>(transform, "GameOIMouseMoveText"); mTVMouseZoomContent = CptUtil.getCptFormParentByName <Transform, Text>(transform, "GameOIMouseZoomText"); mTVKeyMoveContent = CptUtil.getCptFormParentByName <Transform, Text>(transform, "GameOIKeyMoveText"); mTVPauseContent = CptUtil.getCptFormParentByName <Transform, Text>(transform, "GameOIPauseText"); mTVPuzzlesInfoContent = CptUtil.getCptFormParentByName <Transform, Text>(transform, "GameOIPuzzlesInfoText"); mTVPuzzlesOIContent = CptUtil.getCptFormParentByName <Transform, Text>(transform, "GameOIOperatingInstructionsText"); mTVKeyRotateContent = CptUtil.getCptFormParentByName <Transform, Text>(transform, "GameOIKeyRotateText"); loadUIData(); }
private new void Awake() { base.Awake(); //初始化背景信息 gameInfoUIBackground = GetComponent <Image>(); //初始化信息介绍 gameInfoDetailsBackground = CptUtil.getCptFormParentByName <Transform, Image>(transform, "GameInfoDetails"); gameInfoDetails = CptUtil.getCptFormParentByName <Transform, ScrollRect>(transform, "GameInfoDetails"); gameInfoDetailsContentTF = CptUtil.getCptFormParentByName <ScrollRect, Transform>(gameInfoDetails, "Content"); if (gameInfoDetailsContentTF != null && CommonData.SelectPuzzlesInfo != null) { gameInfoDetailsContentSC = gameInfoDetailsContentTF.gameObject.AddComponent <GameInfoDetails>(); gameInfoDetailsContentSC.loadData(CommonData.SelectPuzzlesInfo.puzzlesInfo); } //初始化图片 gameInfoPic = CptUtil.getCptFormParentByName <Transform, ScrollRect>(transform, "GameInfoPic"); gameInfoPicImage = CptUtil.getCptFormParentByName <ScrollRect, Image>(gameInfoPic, "Image"); if (gameInfoPic != null) { gameInfoPicTF = gameInfoPic.GetComponent <RectTransform>(); } if (gameInfoPicImage != null && CommonData.SelectPuzzlesInfo != null) { string picPath = CommonData.SelectPuzzlesInfo.puzzlesInfo.Data_file_path + CommonData.SelectPuzzlesInfo.puzzlesInfo.Mark_file_name; if (CommonData.SelectPuzzlesInfo.puzzlesInfo.Data_type.Equals((int)JigsawResourcesEnum.Custom)) { StartCoroutine (ResourcesManager.LoadAsyncLocationImage(picPath, gameInfoPicImage, this)); } else { StartCoroutine (ResourcesManager.LoadAsyncAssetBundlesImageForBytes(picPath, CommonData.SelectPuzzlesInfo.puzzlesInfo.Mark_file_name, gameInfoPicImage, this)); } } gameCancelBT = CptUtil.getCptFormParentByName <Transform, Button>(transform, "GameCancelBT"); gameCancelBT.onClick.AddListener(cancelUI); }
void Start() { mBTBackGround = CptUtil.getCptFormParentByName <Transform, Button>(transform, "DialogBackGround"); mBTSubmit = CptUtil.getCptFormParentByName <Transform, Button>(transform, "SubmitBT"); mBTCancel = CptUtil.getCptFormParentByName <Transform, Button>(transform, "CancelBT"); mTXTitle = CptUtil.getCptFormParentByName <Transform, Text>(transform, "TitleText"); mTXContent = CptUtil.getCptFormParentByName <Transform, Text>(transform, "ContentText"); mTXCancel = CptUtil.getCptFormParentByName <Transform, Text>(transform, "CancelText"); mTXSubmit = CptUtil.getCptFormParentByName <Transform, Text>(transform, "SubmitText"); mTXTitle.text = mTitleStr; mTXContent.text = mContentStr; mTXCancel.text = mCancelStr; mTXSubmit.text = mSubmitStr; mBTBackGround.onClick.AddListener(cancel); mBTCancel.onClick.AddListener(cancel); mBTSubmit.onClick.AddListener(submit); }
/// <summary> /// 设置拼图等级 /// </summary> private void setLevel(GameObject itemObj, int level) { //设置拼图等级 Image levelPic = CptUtil.getCptFormParentByName <Transform, Image>(itemObj.transform, "JigsawLevelPic"); Text levelText = CptUtil.getCptFormParentByName <Transform, Text>(itemObj.transform, "JigsawLevelText"); Sprite levelTX; if (level > 0 && level <= 10) { levelTX = mLevel1; } else if (level > 10 && level <= 20) { levelTX = mLevel2; } else { levelTX = mLevel3; } levelPic.sprite = levelTX; levelText.text = "x" + level; }
/// <summary> /// 创建ITEM /// </summary> /// <param name="itemData"></param> private GameObject createMakerItem(MakerDataBean itemData) { GameObject itemObj = Instantiate(ResourcesManager.LoadData <GameObject>(MakerItemPath)); //设置大小 RectTransform rect = itemObj.GetComponent <RectTransform>(); float itemWith = transform.GetComponent <RectTransform>().rect.width; float itemHight = transform.GetComponent <RectTransform>().rect.width * 0.1f; rect.sizeDelta = new Vector2(itemWith, itemHight); itemObj.name = itemData.makerTitle; itemObj.transform.SetParent(transform); itemObj.transform.localScale = new Vector3(1, 1, 1); Text markTitle = CptUtil.getCptFormParentByName <RectTransform, Text>(rect, "MakerTitle"); Text markName = CptUtil.getCptFormParentByName <RectTransform, Text>(rect, "MakerName"); markTitle.text = itemData.makerTitle; markName.text = itemData.makeName; return(itemObj); }
private new void Awake() { base.Awake(); musicSelectTF = CptUtil.getCptFormParentByName <Transform, Transform>(transform, "Content"); if (musicSelectTF != null) { musicSelect = musicSelectTF.gameObject.AddComponent <GameMusicDetails>(); musicSelect.addMusicSelectCallBack(this); musicSelect.loadData(); } musicSwitchGroup = CptUtil.getCptFormParentByName <Transform, ToggleGroup>(transform, "GameMusicSwitch"); if (musicSwitchGroup != null) { musicSwitchCpt = musicSwitchGroup.gameObject.AddComponent <GameMusicSwitch>(); musicSwitchCpt.addRadioButtonCallBack(this); } gameCancelBT = CptUtil.getCptFormParentByName <Transform, Button>(transform, "GameCancelBT"); gameCancelBT.onClick.AddListener(cancelUI); }
/// <summary> /// 创建自定义增加拼图样式 /// </summary> public GameObject createAddItem() { GameObject itemObj = Instantiate(ResourcesManager.LoadData <GameObject>(JigsawSelectAddItemPath)); //设置大小 setItemSize(itemObj); itemObj.name = "Add"; itemObj.transform.SetParent(transform); //设置按键 Button addTextBT = CptUtil.getCptFormParentByName <Transform, Button>(itemObj.transform, "JigsawAdd"); Button addPicBT = CptUtil.getCptFormParentByName <Transform, Button>(itemObj.transform, "JigsawPic"); addTextBT.onClick.AddListener(jumpAddCustomUI); addPicBT.onClick.AddListener(jumpAddCustomUI); //设置文本信息 Text jigsawAddText = CptUtil.getCptFormParentByName <Transform, Text>(itemObj.transform, "JigsawAddText"); jigsawAddText.text = CommonData.getText(7); return(itemObj); }
private void Start() { mCurrentScore = CptUtil.getCptFormParentByName <Transform, Transform>(transform, "CurrentScore"); mCurrentScoreTitle = CptUtil.getCptFormParentByName <Transform, Text>(transform, "CurrentScoreTitle"); mCurrentScoreContent = CptUtil.getCptFormParentByName <Transform, Text>(transform, "CurrentScoreContent"); mRankTitle = CptUtil.getCptFormParentByName <Transform, Text>(transform, "RankTitle"); mRankContent = CptUtil.getCptFormParentByName <Transform, Text>(transform, "RankContent"); mBestScoreTitle = CptUtil.getCptFormParentByName <Transform, Text>(transform, "BestScoreTitle"); mBestScoreContent = CptUtil.getCptFormParentByName <Transform, Text>(transform, "BestScoreContent"); mTrophyName = CptUtil.getCptFormParentByName <Transform, Text>(transform, "TrophyName"); mCancelBT = CptUtil.getCptFormParentByName <Transform, Button>(transform, "CancelBT"); mCancelText = CptUtil.getCptFormParentByName <Button, Text>(mCancelBT, "Text"); mSubmitBT = CptUtil.getCptFormParentByName <Transform, Button>(transform, "SubmitBT"); mSubmitText = CptUtil.getCptFormParentByName <Button, Text>(mSubmitBT, "Text"); mWorldRank = CptUtil.getCptFormParentByName <Transform, Transform>(transform, "Content"); mTrophy = CptUtil.getCptFormParentByName <Transform, Transform>(transform, "Trophy"); mLoading = CptUtil.getCptFormParentByName <Transform, Transform>(transform, "Loading"); mCancelBT.onClick.AddListener(cancelOnClick); mSubmitBT.onClick.AddListener(submitOnClick); initData(); //设置本地最好分数 PuzzlesCompleteStateBean completeData = mGameInfoBean.completeStateInfo; if (completeData != null && completeData.completeTime != null) { mBestScore = completeData.completeTime.totalSeconds; mBestScoreContentStr = GameUtil.GetTimeStr(completeData.completeTime.totalSeconds); mBestScoreContent.text = mBestScoreContentStr; } //查询网络数据 mLeaderboardHandle.findLeaderboard(mGameInfoBean.puzzlesInfo.Id + "_" + mGameInfoBean.puzzlesInfo.Mark_file_name, this); }
private new void Awake() { base.Awake(); //初始化标题栏 jigsawSelectTiltebar = CptUtil.getCptFormParentByName <Transform, Transform>(transform, "TitleBar"); titleBarExitBT = CptUtil.getCptFormParentByName <Transform, Button>(jigsawSelectTiltebar, "ExitBT"); titleBarJigsawPointTV = CptUtil.getCptFormParentByName <Transform, Text>(jigsawSelectTiltebar, "PuzzlesPointText"); titleBarTitleName = CptUtil.getCptFormParentByName <Transform, Text>(jigsawSelectTiltebar, "TitleName"); if (titleBarExitBT != null) { titleBarExitBT.onClick.AddListener(addExitOnClick); } mBTPuzzlesShape = CptUtil.getCptFormParentByName <Transform, Button>(transform, "PuzzlesShape"); mTVPuzzlesShape = CptUtil.getCptFormParentByName <Transform, Text>(transform, "PuzzlesShapeTitle"); mBTBorderShape = CptUtil.getCptFormParentByName <Transform, Button>(transform, "BorderShape"); mTVBorderShape = CptUtil.getCptFormParentByName <Transform, Text>(transform, "BorderShapeTitle"); mBTBorderColor = CptUtil.getCptFormParentByName <Transform, Button>(transform, "BorderColor"); mTVBorderColor = CptUtil.getCptFormParentByName <Transform, Text>(transform, "BorderColorTitle"); mBTBackgroundColor = CptUtil.getCptFormParentByName <Transform, Button>(transform, "BackgroundColor"); mTVBackgroundColor = CptUtil.getCptFormParentByName <Transform, Text>(transform, "BackgroundColorTitle"); mEquipContent = CptUtil.getCptFormParentByName <Transform, Transform>(transform, "EquipContent"); tabCpt = CptUtil.getCptFormParentByName <Transform, TabCpt>(transform, "TypeSelect"); mBTPuzzlesShape.onClick.AddListener(addPuzzlesShapeOnClick); mBTBorderShape.onClick.AddListener(addBorderShapeOnClick); mBTBorderColor.onClick.AddListener(addBorderColorOnClick); mBTBackgroundColor.onClick.AddListener(addBackgroundOnClick); equipSelect = gameObject.AddComponent <EquipSelect>(); equipSelect.setMenuSelectUIControl(this); refreshUI(); }
/// <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 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); }
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> /// 创建obj /// </summary> /// <param name="content"></param> /// <param name="data"></param> public void createEquipItem(Transform content, EquipInfoBean data) { GameObject equipObj = Instantiate(ResourcesManager.LoadData <GameObject>(s_ResTypeSelectItemPath)); //设置大小 RectTransform itemRect = equipObj.GetComponent <RectTransform>(); float itemWith = content.GetComponent <RectTransform>().rect.height * 0.52f; float itemHight = content.GetComponent <RectTransform>().rect.height * 0.8f; itemRect.sizeDelta = new Vector2(itemWith, itemHight); TabButton tabButton = equipObj.GetComponent <TabButton>(); equipObj.transform.SetParent(content); equipObj.transform.SetSiblingIndex((int)data.equipTypeId); equipObj.name = data.equipName; equipObj.transform.localScale = new Vector3(1, 1, 1); //背景 Image backgroundImage = CptUtil.getCptFormParentByName <Transform, Image>(equipObj.transform, "Background"); //设置名字 Text equipName = CptUtil.getCptFormParentByName <Transform, Text>(equipObj.transform, "EquipName"); equipName.text = data.equipName; //设置资源图片 Image equipImage = CptUtil.getCptFormParentByName <Transform, Image>(equipObj.transform, "EquipImage"); StartCoroutine(ResourcesManager.LoadAsyncDataImage(data.equipImageUrl, equipImage)); if (data.equipImageColor != null && data.equipImageColor.Length != 0) { if (data.equipTypeId == 0) { data.equipImageColor = "#EFEFEF"; } ColorUtil.setImageColor(equipImage, data.equipImageColor); } //获取是否锁定 ((EquipDSHandle)DataStorageManage.getEquipDSHandle()).getData(data); Image equipLock = CptUtil.getCptFormParentByName <Transform, Image>(equipObj.transform, "EquipLock"); Button equipButton = CptUtil.getCptFormParentByName <Transform, Button>(equipObj.transform, "EquipButton"); Image equipButtonImage = CptUtil.getCptFormParentByName <Transform, Image>(equipObj.transform, "EquipButton"); Text equipButtonText = CptUtil.getCptFormParentByName <Transform, Text>(equipObj.transform, "EquipButtonText"); if (data.equipTypeId != 0 && data.unlockType == 0) { //未解锁处理 equipLock.enabled = true; equipButtonText.text = CommonData.getText(13) + "(" + data.unlockPoint + "PP)"; equipButton.onClick.AddListener(delegate() { unlockEquip(content, data, equipObj); }); } else { //已解锁处理 equipLock.enabled = false; int equipId = 0; if (data.equipType == (int)EquipTypeEnum.PuzzlesShape) { equipId = (int)CommonConfigure.PuzzlesShape; } else if (data.equipType == (int)EquipTypeEnum.BorderShape) { equipId = (int)CommonConfigure.BorderShape; } else if (data.equipType == (int)EquipTypeEnum.BorderColor) { equipId = (int)CommonConfigure.BorderColor; } else if (data.equipType == (int)EquipTypeEnum.Background) { equipId = (int)CommonConfigure.Background; } if (equipId == data.equipTypeId) { equipButtonText.text = CommonData.getText(90); equipButton.onClick.RemoveAllListeners(); ColorUtil.setImageColor(backgroundImage, "#CCCCCC"); ColorUtil.setImageColor(equipButtonImage, "#CCCCCC"); } else { equipButtonText.text = CommonData.getText(89); equipButton.onClick.AddListener(delegate() { useEquip(content, data, equipObj); }); } } }