private void SetScrollValue() { uint curLevelID = LevelMgr.GetInstance().GetNewLevel().LevelId; if (curLevelID == 0) { scrollValue = 1.0f; } else { List <int> index = LevelMgr.GetInstance().GetLevelIndex(curLevelID); float curLen = 0.0f; if (index.Count == 1 && index[0] <= 9) { scrollValue = 1.0f; return; } curLen += index.Count * offsetMenu; for (int i = 0; i < index.Count; i++) { curLen += Mathf.CeilToInt(index[i] / 3.0f) * offsetY; } scrollValue = 1 - curLen / totalLen; //len = curLen; } }
private void RefreshLevelList() { SetScrollValue(); SetTopText(); int levelCnt = 0; int themeCnt = 0; for (int i = 0; i < LevelContent.gameObject.transform.childCount; i++) { if (LevelContent.gameObject.transform.GetChild(i).name == "menu(Clone)") { themeCnt++; levelCnt = 0; } if (LevelContent.gameObject.transform.GetChild(i).name == "UILevelBtn(Clone)") { UILevelBtn uibtn = LevelContent.gameObject.transform.GetChild(i).GetComponent <UILevelBtn>(); if (levelCnt == 1) { uibtn.line.SetActive(true); } LevelConfig config = LevelMgr.GetInstance().GetLevelConfig(uibtn.levelID).Config; LoadLevelBtn(uibtn, config.LevelId, config.LevelPicture.ToString(), levelCnt, themeCnt); } } }
public override void OnEnter(params object[] argv) { Text txt = (Text)argv[0]; uint curlevelid = LevelMgr.GetInstance().CurLevelID; txt.text = "LEVEL " + LevelMgr.GetInstance().GetIndexByID(curlevelid);//modify at 20191108 wuhuolong }
private void SetTopText() { int AllNum = LevelMgr.GetInstance().GetNumOfLevel(); int CompleteNum = LevelMgr.GetInstance().GetNumOfComplete(); topText.text = CompleteNum.ToString() + "/" + AllNum.ToString(); }
private static void PassAllStage_Func(object[] objs) { Debug.Log("pass"); //string numAllStar = "numAllStar"; string isUnlock = "isUnlock"; string isCompleted = "isCompleted"; //string numStar = "numStar"; LevelConfig_ARRAY m_config = LevelMgr.GetInstance().GetLevelConfigArray(); for (int i = 0; i < m_config.Items.Count; i++) { string id = m_config.Items[i].LevelId.ToString(); //设置关卡解锁状态 XPlayerPrefs.SetInt(id + isUnlock, -1); XPlayerPrefs.SetInt(id + isCompleted, 1); ////设置当前关卡星星 //int preStar = XPlayerPrefs.GetInt(id + numStar); //XPlayerPrefs.SetInt(id + numStar, 3); ////设置总星星数量 //int curNum = XPlayerPrefs.GetInt(numAllStar); //XPlayerPrefs.SetInt(numAllStar, curNum + 3 - preStar); } //保存 XPlayerPrefs.Save(); }
public static void OnGui(LevelMapArray config, MapEditor wind) { if (!string.IsNullOrEmpty(wind.selectedLevel) && !EditorTool.IsMatch(config.ConfigID, wind.selectedLevel)) { return; } if (wind.selectedLevel_Type != 0 && wind.selectedLevel_Type != LevelMgr.GetInstance().GetLevelConfig(config.ConfigID).Config.LevelType) { return; } GUILayout.BeginHorizontal(); GUILayout.Label(config.Id.ToString(), GUILayout.Width(200)); GUILayout.Label(string.Format("{0}", config.ConfigID), GUILayout.Width(250)); GUILayout.Label(string.Format("{0} X {1}", config.MapWidth, config.MapHeight), GUILayout.Width(200)); bool isEdit = GUILayout.Button("修改", GUILayout.Width(50)); if (isEdit) { wind.curLevelId = config.Id; wind.Pagetype = MapEditor.PageType.Editor; } bool isDelete = GUILayout.Button("删除", GUILayout.Width(50)); if (isDelete) { m_deletegroup.Add(config); } GUILayout.EndHorizontal(); }
private void OnEnable() { black.alpha = 0.0f; buttonCheck = true; canClick = false; levelID = LevelMgr.GetInstance().CurLevelID; data = LevelMgr.GetInstance().GetLevelConfig(levelID); value = LevelMgr.GetInstance().GetValueConfig(); OnShow(); }
public void Click() { if (buttonCheck) { buttonCheck = false; LevelMgr.GetInstance().CurPlayMode = GamePlayModule.Normal; Debug.Log(LevelMgr.GetInstance().CurPlayMode); UIMgr.GetInstance().ShowPage_Play(UIPageEnum.Play_Page); } }
/// <summary> /// 加载主题 /// </summary> private void LoadMenu(GameObject menu, string n) { //加载主题名字 Text name = menu.GetComponentInChildren <Text>(); //name.text = LevelMgr.GetInstance().GetThemeConfig(n).ThemeName; uint id = LevelMgr.GetInstance().GetThemeConfig(n).ThemeName; //Debug.Log(name.text + id); LanguageMgr.GetInstance().GetLangStrByID(name, id); }
//Google.Protobuf.Collections.RepeatedField<int>[] starRaings; private void OnEnable() { black.alpha = 0.0f; buttonCheck = true; //UIMgr.ShowPage(UIPageEnum.Play_Page); levelID = LevelMgr.GetInstance().CurLevelID; data = LevelMgr.GetInstance().GetLevelConfig(levelID); value = LevelMgr.GetInstance().GetValueConfig(); ShadowInit(); OnShow(); }
private void LoadLevelList() { //LoadNumOfStars(); LevelMgr.GetInstance().DoLoadLevelListLen(LoadLevelListLen); LevelContent.sizeDelta = new Vector2(rectWidth, totalLen); SetScrollValue(); SetTopText(); curTheme = ""; levelCnt = 0; LevelMgr.GetInstance().DoLoadLevelListContent(LoadLevelListContent); }
private void StartChallenge() { if (LevelMgr.GetInstance().GetLevelConfig(m_selectedLevelID).Config == null) { Debug.Log("当前关卡id无效"); return; } else { LevelMgr.GetInstance().GotoLevel(m_selectedLevelID); } }
private void LoadOriginImg() { //加载原图 X.Res.LevelConfig levelConfig = LevelMgr.GetInstance().GetLevelConfig(levelID).Config; Debug.Log("levelID:" + levelID); int pitcureId = levelConfig.LevelPicture; string altasname = AltasMgr.GetInstance().GetConfigByID((uint)pitcureId).AltasName2; Debug.Log(altasname); UIAtlas ats = UIAtlasUtil.GetAtlas(altasname); ats.Sp = originImg; ats.SetSprite("p_" + levelConfig.LevelPicture.ToString()); }
public void LevelRestartCorou() { if (buttonCheck) { buttonCheck = false; //Debug.Log("restart"); // Resume(); uint curLevelID = LevelMgr.GetInstance().CurLevelID; XPlayerPrefs.DelRec(curLevelID); // pausePage.SetActive(false); CloseUIPlay(); UIMgr.GetInstance().ShowPage_Play(UIPageEnum.Play_Page); } }
private void InitUIPlay() { mask.SetActive(false); needMask = 0; if (LevelMgr.GetInstance().GetIndexByID(LevelMgr.GetInstance().CurLevelID) == "1-1") { Debug.Log("1-1"); needMask = 1; } if (LevelMgr.GetInstance().GetIndexByID(LevelMgr.GetInstance().CurLevelID) == "1-2") { needMask = 2; } buttonCheck = true; animator = GetComponent <Animator>(); UIEvent.RegEvent(UIEvent.UI_LEVELSTART, LevelStart); //UIEvent.RegEvent(UIEvent.UI_LEVEL_USEREC, LevelUseRec); //显示关卡拼图面板原图 levelID = LevelMgr.GetInstance().CurLevelID; if (!debugFlag) { LoadOriginImg(); } operationHistoryRecorder.SetLevelId(levelID); // data = LevelMgr.GetInstance().GetLevelConfig(levelID); // value = LevelMgr.GetInstance().GetValueConfig(); //显示关卡序号 BaseLevel levelmode = LevelMgr.GetInstance().CurLevelMode; levelmode.OnEnter(levelText); //levelText.text="LEVEL "+LevelMgr.GetInstance().GetIndexByID(levelID);//modify at 20191108 wuhuolong // Debug.LogError(LevelMgr.GetInstance().GetIndexByID(levelID)); //heimu-test //black.alpha = 1.0f; //isShadow = false; //// levelTimer.SetTime(0); //StartCoroutine(ShadowInit()); UIEvent.Broadcast(UIEvent.UI_LEVELSTART); //heimu-test StartCoroutine(Guiding()); }
public void ClickQuit() { if (canClick) { if (buttonCheck) { buttonCheck = false; BaseLevel levelmode = LevelMgr.GetInstance().CurLevelMode; levelmode.OnClickQuit(); //返回关卡列表 //toList = true; //isShadow = true; } } }
public bool CheckOver() { foreach (int i in playout) { if (i == (int)GridType.Blank) { return(false); } } uint curLevelID = LevelMgr.GetInstance().CurLevelID; XPlayerPrefs.DelRec(curLevelID); SDKMgr.GetInstance().Track(SDKMsgType.OnLevelClear, (int)curLevelID); return(true); }
private void LoadOriginImg() { //加载原图 Image img = gameObject.transform.Find("GameObject").transform.Find("Image").GetComponent <Image>(); int pitcureId = LevelMgr.GetInstance().GetLevelConfig(levelID).Config.LevelPicture; string altasname = AltasMgr.GetInstance().GetConfigByID((uint)pitcureId).AltasName2; Debug.Log(altasname); UIAtlas ats = UIAtlasUtil.GetAtlas(altasname); ats.Sp = img; ats.SetSprite("p_" + data.Config.LevelPicture.ToString()); //加载关卡名字 //menuText.text = LevelMgr.GetInstance().GetIndexByID(levelID); }
private void SetToNextLevel() { //设置本关卡已完成 XPlayerPrefs.SetInt(levelID + isCompleted, 1); //Debug.Log(XPlayerPrefs.GetInt(levelID + isCompleted)); //下一关 if (LevelMgr.GetInstance().GetNextLevelIDByID(levelID) == 0) { //Debug.Log("没有下一关了"); return; } nextLevelID = LevelMgr.GetInstance().GetNextLevelIDByID(levelID); XPlayerPrefs.SetInt(curLevel, (int)nextLevelID); XPlayerPrefs.SetInt(nextLevelID + isUnlock, -1); LevelMgr.GetInstance().CurLevelID = nextLevelID; }
private void ModiMapAndInfo() { updateFlag = false; //修改图片和信息的显示 //获得表 int dayId = TimeUtil.getIntByDateTime(m_selectedDateTime); SignInConfig signInConfig = SignInMgr.GetInstance().GetConfigByID((uint)dayId); m_selectedLevelID = signInConfig.LevelId; LevelData levelData = LevelMgr.GetInstance().GetLevelConfig(m_selectedLevelID); LevelConfig levelConfig = levelData.Config; if (levelConfig == null) { Debug.LogError("获取不到关卡 " + m_selectedLevelID + " 的Config"); return; } //TODO:修改mapIcon的图标,需要通过读表获取对应的图集 AltasConfig altasConfig = AltasMgr.GetInstance().GetConfigByID(m_selectedLevelID); string altasname = altasConfig.AltasName2; UIAtlas ats = UIAtlasUtil.GetAtlas(altasname); if (ats != null) { ats.Sp = mapIcon; if (SignInMgr.GetInstance().IsSign(dayId - GameConfig.SignInDay)) { ats.SetSprite("p_" + levelConfig.LevelPicture.ToString()); } else { ats.SetSprite("s_" + levelConfig.LevelPicture.ToString()); } } //TODO:修改info,包括了编号、名字、剩余时间和按钮的状态、文字等 levelNumText.text = "#" + (SignInMgr.GetInstance().GetIndexByID((uint)dayId) + 1).ToString(); LanguageMgr.GetInstance().GetLangStrByID(levelNameText, signInConfig.DailylevelName); StartCoroutine(TimeLeftUpdate(m_selectedDateTime.AddDays(1))); ModiTryButton(); }
public IEnumerator InitPuzzleContainPanel(bool isregen = false) { yield return(new WaitForFixedUpdate()); //TODO:如果有存档,就根据存档把拼图加进去 if (isregen) { uint curLevelID = LevelMgr.GetInstance().CurLevelID; Recorder rec = XPlayerPrefs.GetRec(curLevelID); List <SettlePuzzle> settlePuzzleList = rec.settlePuzzleList; Debug.Log("settlePuzzleList length:" + settlePuzzleList.Count); foreach (SettlePuzzle settlePuzzle in settlePuzzleList) { SettlePuzzleFunc(settlePuzzle); } } }
public void LevelReturn() { //Debug.Log("return"); // Resume(); //heimu-test //RandomType(); //ShadowInit2(); //isShadowToList = true; SaveOperation(); CloseUIPlay(); BaseLevel levelmode = LevelMgr.GetInstance().CurLevelMode; levelmode.OnClickQuit(); // UIMgr.ShowPage(UIPageEnum.LevelList_Page); }
public void ClickNextLevel() { if (canClick) { if (buttonCheck) { buttonCheck = false; if (LevelMgr.GetInstance().GetNextLevelIDByID(levelID) == 0) { UIMgr.GetInstance().ShowPage(UIPageEnum.LevelList_Page); return; } //heimu-test //Debug.Log("next"); //isShadow = true; //toLevel = true; UIMgr.GetInstance().ShowPage_Play(UIPageEnum.Play_Page); } } }
private void OnEnable() { levelID = LevelMgr.GetInstance().GetNewLevel().LevelId; Debug.Log("levelID" + levelID); LevelMgr.GetInstance().CurLevelID = levelID; XPlayerPrefs.SetInt(levelID + isUnlock, -1); //XPlayerPrefs.Save(); buttonCheck = true; type = XPlayerPrefs.GetInt(shadowType); updateFlag = false; StartCoroutine(TimeLeftUpdate(DateTime.Today.AddDays(1))); //if(isFlashOver==true && type!=-1) //{ // black.alpha = 1.0f; // StartCoroutine(ShadowInit2()); //} //ShadowInit(); }
public override void OnExit(params object[] argv) { GameObject nextLevelButton = argv[0] as GameObject; nextLevelButton.SetActive(true); X.Res.FuncParamConfig config = FuncMgr.GetInstance().GetConfigByID(1); if (config != null) { uint curlevelid = LevelMgr.GetInstance().CurLevelID; //int showcount = XPlayerPrefs.GetInt(Evaluation_Tag); for (int i = 0; i < config.Params1.Count; i++) { if (config.Params1[i] == curlevelid /*&& config.Params2[i] > showcount*/) { SDKMgr.GetInstance().Track(SDKMsgType.OnCallEvaluation); //showcount++; //XPlayerPrefs.SetInt(Evaluation_Tag, showcount); return; } } } }
public void ClickRanking() { UIMgr.GetInstance().ShowWindows(UIPageEnum.Calendar_Page); LevelMgr.GetInstance().CurPlayMode = GamePlayModule.SignIn; }
public void InitDay(DateTime dateTime) { isLocked = false; isEmpty = false; this.dateTime = dateTime; this.dateTimeInt = TimeUtil.getIntByDateTime(dateTime); //TODO:首先获取配置表,如果今天没有配置任何信息,就不显示任何 SignInConfig signInConfig = SignInMgr.GetInstance().GetConfigByID((uint)dateTimeInt); if (signInConfig == null || LevelMgr.GetInstance().GetLevelConfig(signInConfig.LevelId).Config == null) { // InitInvisible(); dayBGSelectFinish.color = Color.clear; dayBGSelectUnFinish.color = Color.clear; dayBGUnSelectFinish.color = Color.clear; lockImage.color = Color.clear; dayText.text = dateTime.Day.ToString(); dayText.color = emptyColor; isEmpty = true; return; } //TODO:和今天对比,如果是今天,字體显示为todaycolor;如果是今天之后,就先上锁,字體顯示爲lockcolor;如果是今天之前,就顯示爲normalcolor DateTime todayDateTime = DateTime.Today; dayBGSelectFinish.color = Color.clear; dayBGSelectUnFinish.color = Color.clear; dayBGUnSelectFinish.color = Color.clear; dayText.text = dateTime.Day.ToString(); bool todayOrPast = false; if (dateTime == todayDateTime) { dayText.color = todayColor; lockImage.color = Color.clear; todayOrPast = true; } else if (dateTime > todayDateTime) { dayText.color = lockColor; lockImage.color = Color.white; isLocked = true; } else { dayText.color = normalColor; lockImage.color = Color.clear; todayOrPast = true; } //如果是今天或者今天之前才要读取当天的完成状态 if (todayOrPast) { //TODO:读取当天的完成状态 via 存档/如果存档中记录的是一系列二进制数,那么读取存档应该放在上层,获取当天的状态后,传入一个bool即可 // int isChallengedInt = XPlayerPrefs.GetInt(TimeUtil.getIntByDateTime(dateTime) + challengeStr); //!just for test // Debug.Log(dateTime.ToShortDateString() + " " + dateTimeInt.ToString()); // Debug.Log(GameConfig.SignInDay); // Debug.Log(dateTimeInt - GameConfig.SignInDay); isChallenged = SignInMgr.GetInstance().IsSign(dateTimeInt - GameConfig.SignInDay); //FINISH:判断当前日期是否被选中 bool isSelected = XPlayerPrefs.GetInt(ChallengeController.selectedDateTimeStr) == dateTimeInt ? true : false; if (isChallenged && isSelected) { //如果當前日期是選中+完成 dayBGSelectFinish.color = Color.white; dayText.color = Color.white; //还要通知一下ChallengeController LogicEvent.Broadcast(LogicEvent.CALENDAR_SELECTED, dateTime, this.gameObject); } else if (!isChallenged && isSelected) { //如果當前日期是選中+未完成 dayBGSelectUnFinish.color = Color.white; // Debug.Log("select unfinish:" + dateTime.ToShortDateString()); // Debug.Log("select unfinish color?:" + dayBGSelectUnFinish.color.ToString()); // Debug.Log("select finish color?:" + dayBGSelectFinish.color.ToString()); LogicEvent.Broadcast(LogicEvent.CALENDAR_SELECTED, dateTime, this.gameObject); } else if (isChallenged && !isSelected) { //如果當前日期是未選中+完成 dayBGUnSelectFinish.color = Color.white; dayText.color = Color.white; } } }
private void setState() { XPlayerPrefs.SetInt(curLevel, (int)levelID); LevelMgr.GetInstance().CurLevelID = levelID; //LevelMgr.GetInstance().SetCurThemeID(themeID); }
private void FixedUpdate() { if (isShadow) { if (shadows[type].localScale != shadowMin) { shadows[type].localScale = Vector3.Lerp(shadows[type].localScale, shadowMin, Time.deltaTime * shadowSpeed); if (Mathf.Abs(shadows[type].localScale.x - shadowMin.x) <= 0.1f) { shadows[type].localScale = Vector3.zero; //进入下一关 isShadow = false; black.alpha = 1.0f; //從結算界面退出: //1 如果是Normal模式,回到關卡選擇 //2 如果是每日挑戰模式,回到每日挑戰界面并且設置好選擇的日期 if (toLevel) { UIMgr.GetInstance().ShowPage_Play(UIPageEnum.Play_Page); return; } if (toList) { BaseLevel levelmode = LevelMgr.GetInstance().CurLevelMode; levelmode.OnClickQuit(); return; } } } } #region xx //if(starEffectsCheck[0]) //{ // if(starEffects[0].transform.position.x != allStar.transform.position.x) // { // starEffects[0].transform.position = Vector3.Lerp(starEffects[0].transform.position, allStar.transform.position, Time.deltaTime); // if(Mathf.Abs(starEffects[0].transform.position.x-allStar.transform.position.x)<=0.1f) // { // starEffectsCheck[0] = false; // starEffects[0].SetActive(false); // int numStar = XPlayerPrefs.GetInt(numAllStar); // XPlayerPrefs.SetInt(numAllStar, numStar + 1); // Debug.Log("add star1"); // starsText.text = XPlayerPrefs.GetInt(numAllStar).ToString(); // } // } //} //if (starEffectsCheck[1]) //{ // if (starEffects[1].transform.position.x != allStar.transform.position.x) // { // starEffects[1].transform.position = Vector3.Lerp(starEffects[0].transform.position, allStar.transform.position, Time.deltaTime); // if (Mathf.Abs(starEffects[1].transform.position.x - allStar.transform.position.x) <= 0.1f) // { // starEffectsCheck[1] = false; // starEffects[1].SetActive(false); // int numStar = XPlayerPrefs.GetInt(numAllStar); // XPlayerPrefs.SetInt(numAllStar, numStar + 1); // Debug.Log("add star2"); // starsText.text = XPlayerPrefs.GetInt(numAllStar).ToString(); // } // } //} //if (starEffectsCheck[2]) //{ // if (starEffects[2].transform.position.x != allStar.transform.position.x) // { // starEffects[2].transform.position = Vector3.Lerp(starEffects[0].transform.position, allStar.transform.position, Time.deltaTime * 5.0f); // if (Mathf.Abs(starEffects[0].transform.position.x - allStar.transform.position.x) <= 0.1f) // { // starEffectsCheck[2] = false; // starEffects[2].SetActive(false); // int numStar = XPlayerPrefs.GetInt(numAllStar); // XPlayerPrefs.SetInt(numAllStar, numStar + 1); // Debug.Log("add star3"); // starsText.text = XPlayerPrefs.GetInt(numAllStar).ToString(); // } // } //} #endregion }
//private bool adPuzzleUseFlag = false;//没有用于实际判断,暂时注释 public void InitPuzzleBar() { //FINISH:读入数据,获得界面下方的PuzzlePanel中要放的拼图的种类的信息 uint curLevelID = LevelMgr.GetInstance().CurLevelID; LevelData curLevelData = LevelMgr.GetInstance().GetLevelConfig(curLevelID); Dictionary <string, int[]> FillTypeMap = new Dictionary <string, int[]>(); Dictionary <string, int> WidthMap = new Dictionary <string, int>(); Google.Protobuf.Collections.RepeatedField <string> usablePuzzleStrList = new Google.Protobuf.Collections.RepeatedField <string>(); int adPuzzleAvailFlagInt = 0; if (curLevelData == null || curLevelData.Config == null) { //!模拟读入 FillTypeMap = new Dictionary <string, int[]>() { { "0", new int[] { 0, 0, 1, 1, 1, 1 } }, { "1", new int[] { 1, 1 } }, { "2", new int[] { 1, 1, 0, 0 } }, { "3", new int[] { 1 } }, }; WidthMap = new Dictionary <string, int>() { { "0", 3 }, { "1", 2 }, { "2", 2 }, { "3", 1 }, }; usablePuzzleStrList = new Google.Protobuf.Collections.RepeatedField <string>() { "0", "1", "3" }; adPuzzleAvailFlagInt = 1; } else { ToolMapArray toolMapArray = LevelMgr.GetInstance().GetToolMapArray(); FillTypeMap = toolMapArray.FillTypeMap; WidthMap = toolMapArray.WidthMap; usablePuzzleStrList = curLevelData.Config.LevelPixel; adPuzzleAvailFlagInt = curLevelData.Config.AdPuzzle; } //Debug.Log("usablePuzzleStrList.Count" + usablePuzzleStrList.Count); //FINISH:读入数据后,根据数据生成相应的若干PuzzleItem int i = 0; foreach (string usablePuzzleStr in usablePuzzleStrList) { int[] usablePuzzleLayout = new int[] { }; if (FillTypeMap.TryGetValue(usablePuzzleStr, out usablePuzzleLayout)) { int[] puzzleLayout = MatrixUtil.ArrayCopy(usablePuzzleLayout); int puzzleWidth = WidthMap[usablePuzzleStr]; int puzzleHeight = puzzleLayout.Length / puzzleWidth; int puzzleCenterX = 0; int puzzleCenterY = 0; float puzzleCenterXFloor = Mathf.Floor((float)puzzleWidth / 2.0f); float puzzleCenterYFloor = Mathf.Floor((float)puzzleHeight / 2.0f); if ((float)puzzleWidth / 2.0f - puzzleCenterXFloor > 0.9f) { puzzleCenterX = (int)puzzleCenterXFloor + 1; } else { puzzleCenterX = (int)puzzleCenterXFloor; } if ((float)puzzleHeight / 2.0f - puzzleCenterYFloor > 0.9f) { puzzleCenterY = (int)puzzleCenterYFloor + 1; } else { puzzleCenterY = (int)puzzleCenterYFloor; } // Debug.Log("puzzleCenterX" + puzzleCenterX); // Debug.Log("puzzleCenterY" + puzzleCenterY); int[] puzzleCenter = new int[2] { puzzleCenterX, puzzleCenterY }; GameObject puzzleItem = GameObject.Instantiate(puzzleItemPrefab, this.transform); PuzzleItemUI puzzleItemUI = puzzleItem.GetComponent <PuzzleItemUI>(); // puzzleItemUIList.Add(puzzleItemUI); // puzzleItemUI.InitComp(playFieldCamera, generalPanelUI, puzzleMoveTrans, dragControlMgr, canvasScaler); puzzleItemUI.InitComp(generalPanelUI, puzzleMoveTrans, dragController); puzzleItemUI.puzzleItemData.InitButtomPuzzleItemData(i, puzzleWidth, puzzleHeight, puzzleLayout, puzzleCenter); puzzleItemUI.InitButtomPuzzleItemUI(); puzzleItemUI.ScaleRatioOfPanelGrid = scaleRatioOfPanelGrid; i++; } else { Debug.Log("NOT usablePuzzstr:" + usablePuzzleStr); } } //TODO:判断是否可用广告方块 if (adPuzzleAvailFlagInt == 0) { //不可用广告方块 if (puzzleBarForFreeLayoutTrans.childCount > 0) { Transform adButtonTrans = puzzleBarForFreeLayoutTrans.GetChild(0); adButtonTrans.gameObject.SetActive(false); } } else//adPuzzleAvailFlagInt==1 { //可用广告方块 //TODO:添加广告方块 GameObject adPuzzle = AddAdPuzzle(); //TODO:添加看广告按钮 Transform adButtonTrans; if (puzzleBarForFreeLayoutTrans.childCount > 0) { adButtonTrans = puzzleBarForFreeLayoutTrans.GetChild(0); } else { GameObject adButton = GameObject.Instantiate(adButtonPrefab, puzzleBarForFreeLayoutTrans); adButtonTrans = adButton.transform; } //添加判断是否已经付费去广告 if (XPlayerPrefs.GetInt(AdMgr.Pay2RemoveAD_Tag) == 1) { adButtonTrans.gameObject.SetActive(false); if (adPuzzleNum == 1) { Transform adPuzzleTrans = this.transform.GetChild(this.transform.childCount - 1); PuzzleItemUI adPuzzleUI = adPuzzleTrans.GetComponent <PuzzleItemUI>(); PuzzleItemData adPuzzleData = adPuzzleUI.puzzleItemData; adPuzzleData.Plockstate = false; } } else { //TODO:设置按钮的方法 Button adButtonComp = adButtonTrans.GetComponent <Button>(); adButtonComp.onClick.RemoveAllListeners(); adButtonComp.onClick.AddListener(() => { UnlockAdPuzzle(); }); //TODO:设置按钮位置,在协程中等待到当前帧的fixedupdate时进行,原因是adPuzzle的位置受horizontalLayout的影响会在fixedupdate时才生效 StartCoroutine(SetAdButtonPos(adButtonTrans, adPuzzle)); } } }