public override void OnExit(params object[] argv) { GameObject nextLevelButton = argv[0] as GameObject; nextLevelButton.SetActive(false); int selectedDateTimeInt = XPlayerPrefs.GetInt(ChallengeController.selectedDateTimeStr); Debug.Log("sign:" + (selectedDateTimeInt - GameConfig.SignInDay).ToString()); SignInMgr.GetInstance().Sign(selectedDateTimeInt - GameConfig.SignInDay); }
public int GetNumOfComplete() { for (int i = 0; i < m_config.Items.Count; i++) { if (XPlayerPrefs.GetInt(m_config.Items[i].LevelId.ToString() + "isCompleted") == 0) { return(i); } } return(m_config.Items.Count); }
private void OnApplicationPause(bool pause) { if (pause) { m_last_timestamp = Time.time; } else { if (Time.time - m_last_timestamp >= Time_Interval) { int count = XPlayerPrefs.GetInt(StartUpCount_Tag) + 1; XPlayerPrefs.SetInt(StartUpCount_Tag, count); } } }
IEnumerator ShadowInit2() { type = XPlayerPrefs.GetInt(shadowType); int waittime = (type == -1) ? 0 : 1; black.alpha = 1.0f; yield return(new WaitForSeconds(0.2f * waittime)); black.alpha = 0.0f; if (type != -1) { shadows[type].localScale = shadowMin; } yield return(new WaitForSeconds(0.02f * waittime)); isShadowFromList = true; }
public LevelConfig GetNewLevel() { for (int i = 0; i < m_config.Items.Count; i++) { if (m_config.Items[i].LevelType == 1 && XPlayerPrefs.GetInt(m_config.Items[i].LevelId.ToString() + "isCompleted") == 0) { return(m_config.Items[i]); } } for (int i = m_config.Items.Count - 1; i >= 0; i--) { if (m_config.Items[i].LevelType == 1) { return(m_config.Items[i]); } } return(m_config.Items[m_config.Items.Count - 1]); }
public void Init() { Debuger.Init(); Debuger.EnableLog = GameConfig.IsDebug; LanguageMgr.GetInstance().SetUp(); int count = XPlayerPrefs.GetInt(StartUpCount_Tag) + 1; XPlayerPrefs.SetInt(StartUpCount_Tag, count); Application.targetFrameRate = 60; //UIMgr.ShowPage(UIPageEnum.Main_Page); processList = new List <PreProcess>() { new BinProcess(), new AtlasProcess(), new AbProcess() }; StartCoroutine(Preprocess()); }
public void ClickEnterLevel() { if (XPlayerPrefs.GetInt(levelID.ToString() + isUnlock) == -1) { Debug.Log("enter"); if (buttonCheck) { buttonCheck = false; setState(); gameObject.transform.GetComponentInParent <UILevelList>().EnterLevel(); XPlayerPrefs.SetInt(curLevel, (int)levelID); XPlayerPrefs.Save(); } } else { Debug.Log("未解锁"); } }
public void InterstitialTrigger(Action onReward = null, Action onFail = null, Action onClose = null) { if (isPaid()) { if (onReward != null) { onReward(); } return; } tmpCount = XPlayerPrefs.GetInt("StartUpCount"); //int startUpCount = XPlayerPrefs.GetInt("StartUpCount"); if (startUpCount != tmpCount) { startUpCount = tmpCount; Debug.Log("StartUpCount" + startUpCount); if (startUpCount > config.Params1[config.Params1.Count - 1]) { index = config.Params1.Count - 1; } else { index = config.Params1.IndexOf(startUpCount); } Debug.Log("first" + index); playTimes = config.Params2[index]; } if (playTimes == 0) { playTimes = config.Params3[index]; } playTimes--; Debug.Log("playTimes" + playTimes); if (playTimes == 0) { //TODO:播放广告 SDKMgr.GetInstance().showIntersitialAD(onReward, onFail, onClose); #if UNITY_EDITOR Debug.Log("激励广告"); #endif } }
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(); }
IEnumerator ShadowInit() { type = XPlayerPrefs.GetInt(shadowType); int waittime = (type == -1) ? 0 : 1; //Debug.Log("after" + shadowType + type); //Debug.Log("play" + waittime); yield return(new WaitForSeconds(0.2f * waittime)); black.alpha = 0.0f; if (type != -1) { shadows[type].localScale = shadowMin; } yield return(new WaitForSeconds(0.02f * waittime)); if (type != -1) { isShadow = true; } }
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 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)); } } }
public bool isPaid() { return(XPlayerPrefs.GetInt(AdMgr.Pay2RemoveAD_Tag) == 1); }
private void LoadLevelBtn(UILevelBtn uiLevelBtn, uint id, string picture, int levelCnt, int themeCnt) { //加载关卡名字,缩略图; //uiLevelBtn.levelText.text = themeCnt.ToString() + "-" + (levelCnt + 1).ToString(); //string picname = "level_s";//string.Format("s_{0}", picture); string altasname = AltasMgr.GetInstance().GetConfigByID(id).AltasName; UIAtlas ats = UIAtlasUtil.GetAtlas(altasname); UIAtlas ats2 = UIAtlasUtil.GetAtlas("uncomplete"); ats.Sp = uiLevelBtn.levelImg; ats2.Sp = uiLevelBtn.levelImg; if (ats != null) { if (XPlayerPrefs.GetInt(id.ToString() + isCompleted) == 1) { ats.SetSprite("s_" + picture);//ats.SetSprite("p_"+picture); ats.Sp.rectTransform.localScale = Vector3.one; uiLevelBtn.star.SetActive(true); uiLevelBtn._new.SetActive(false); //uiLevelBtn.levelText.text = LevelMgr.GetInstance().GetLevelConfig(id).Config.LevelName; //uiLevelBtn.levelText.text = themeCnt.ToString() + "-" + (levelCnt + 1).ToString(); } else if (XPlayerPrefs.GetInt(id.ToString() + isUnlock) == -1) { //Debug.Log("isunlock"); ats2.SetSprite("unknown"); ats.Sp.rectTransform.localScale = new Vector3(0.8f, 0.8f, 0.8f); uiLevelBtn._new.SetActive(true); uiLevelBtn.star.SetActive(false); //uiLevelBtn.levelText.text = (levelCnt+1).ToString(); //uiLevelBtn.levelText.text = "? ? ?"; } else { uiLevelBtn.star.SetActive(false); uiLevelBtn._new.SetActive(false); uiLevelBtn.SetGray(); //Debug.Log("islock"); //未解锁 ats2.SetSprite("lock"); ats.Sp.rectTransform.localScale = new Vector3(0.8f, 0.8f, 0.8f); } } #region starandlock ////加载星星 //if (UnpackStarNum(XPlayerPrefs.GetInt(id.ToString() + numStar)) >= 1) //{ // int stars = UnpackStarNum(XPlayerPrefs.GetInt(id.ToString() + numStar)); // Debug.Log(stars); // for (int i = 0; i < 3; i++) // { // UIAtlas starAts = ResMgr.GetAtlas("levelStar"); // starAts.Sp = uiLevelBtn.stars[i]; // if (i < stars) // { // starAts.SetSprite("guanqiaxuanzexing1"); // } // else // { // starAts.SetSprite("guanqiaxuanzexing2"); // } // } //} //else //{ // for (int i = 0; i < 3; i++) // { // uiLevelBtn.stars[i].color = new Color(255, 255, 255, 0); // } //} ////设置解锁状态; //UIAtlas unlockAts = ResMgr.GetAtlas("unlock"); //unlockAts.Sp = uiLevelBtn.unlockBtn; //switch (LevelMgr.GetInstance().GetLevelConfig(id).Config.LevelUnlock) //{ // case 0: // XPlayerPrefs.SetInt(id.ToString() + isUnlock, -1); // Destroy(uiLevelBtn.unlockBtn.gameObject); // break; // case 1: // if(XPlayerPrefs.GetInt(id.ToString()+isUnlock)==-1) // { // Destroy(uiLevelBtn.unlockBtn.gameObject); // break; // } // XPlayerPrefs.SetInt(id.ToString() + isUnlock, 1); // unlockAts.SetSprite("guanggao"); // break; // case 2: // if (XPlayerPrefs.GetInt(id.ToString() + isUnlock) == -1) // { // Destroy(uiLevelBtn.unlockBtn.gameObject); // break; // } // XPlayerPrefs.SetInt(id.ToString() + isUnlock, 2); // unlockAts.SetSprite("zuanshi"); // break; //} #endregion }
public void InitAllCalendars() { calendarList = new List <CalendarTest>(); int selectedDateTimeInt = XPlayerPrefs.GetInt(ChallengeController.selectedDateTimeStr); Debug.Log("selectedDay:" + selectedDateTimeInt); if (selectedDateTimeInt != 0) { currentCalendarDateTime = TimeUtil.getDateTimeByInt(selectedDateTimeInt); } else { currentCalendarDateTime = DateTime.Today; X.Res.SignInConfig todaySignInConfig = SignInMgr.GetInstance().GetConfigByID((uint)TimeUtil.getIntByDateTime(currentCalendarDateTime)); if (todaySignInConfig != null && LevelMgr.GetInstance().GetLevelConfig(todaySignInConfig.LevelId).Config != null) { XPlayerPrefs.SetInt(ChallengeController.selectedDateTimeStr, TimeUtil.getIntByDateTime(currentCalendarDateTime)); } else { XPlayerPrefs.SetInt(ChallengeController.selectedDateTimeStr, (int)SignInMgr.GetInstance().MaxValidDay); } } selectedDateTimeInt = XPlayerPrefs.GetInt(ChallengeController.selectedDateTimeStr); Debug.Log("selectedDay:" + selectedDateTimeInt); int calendarCount = transform.childCount; int centerCalendar = calendarCount / 2; int offsetMonth = 0; for (int i = centerCalendar; i >= 0; i--) { Transform calendarTrans = transform.GetChild(i); CalendarTest calendar = calendarTrans.GetComponent <CalendarTest>(); calendarList.Add(calendar); DateTime calendarDateTime = currentCalendarDateTime.AddMonths(offsetMonth); calendar.InitCalendar(calendarDateTime.Month, calendarDateTime.Year); offsetMonth--; } offsetMonth = 1; for (int i = centerCalendar + 1; i < calendarCount; i++) { Transform calendarTrans = transform.GetChild(i); CalendarTest calendar = calendarTrans.GetComponent <CalendarTest>(); calendarList.Add(calendar); DateTime calendarDateTime = currentCalendarDateTime.AddMonths(offsetMonth); calendar.InitCalendar(calendarDateTime.Month, calendarDateTime.Year); offsetMonth++; } currentCalendarDateTime = new DateTime(currentCalendarDateTime.Year, currentCalendarDateTime.Month, 1); Debug.Log(currentCalendarDateTime.Year + " " + currentCalendarDateTime.Month + " " + currentCalendarDateTime.Day); }