Пример #1
0
    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);
    }
Пример #2
0
    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();
    }
Пример #3
0
    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;
            }
        }
    }
Пример #4
0
    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);
    }
Пример #5
0
    public void ShowBesideMonthCalendar(bool nextOrLast)
    {
        if (nextOrLast)
        {
            //跳至下一个月
            DateTime nextCalendarDateTime = currentCalendarDateTime.AddMonths(1);
            DateTime firstDateOfNext      = new DateTime(nextCalendarDateTime.Year, nextCalendarDateTime.Month, 1);

            if (firstDateOfNext > TimeUtil.getDateTimeByInt((int)(SignInMgr.GetInstance().MaxDay)))
            {
                //如果下一個月的第一天沒有配置
                return;
            }

            //设置currentCalendarDateTime
            currentCalendarDateTime = currentCalendarDateTime.AddMonths(1);
            Debug.Log(currentCalendarDateTime.Year + " " + currentCalendarDateTime.Month + " " + currentCalendarDateTime.Day);
            nextCalendarDateTime = currentCalendarDateTime.AddMonths(1);


            //TODO:加入动画而非直接变换位置
            StartCoroutine(moveRectTrans(rectTrans, rectTrans.anchoredPosition + Vector2.left * panelWidth, 0.2f, () =>
            {
                // rectTrans.anchoredPosition = rectTrans.anchoredPosition + Vector2.left * panelWidth;

                //TODO:动画播完后,改变子节点的排序,即多个日历的排序,由于horizontalLayout的作用会改变每个日历的位置,将第一个日历放到最后时,当前展示的日历会往左移动,因此整个panel需要再往右移动

                //TODO:原本的第一个子节点,即第一个日历放到最后之后,将第一个日历变为当前查看的日历的下一月份的日历
                Transform firstCalendarTrans = rectTrans.GetChild(0);
                firstCalendarTrans.SetAsLastSibling();

                CalendarTest firstCalendar = firstCalendarTrans.GetComponent <CalendarTest>();

                firstCalendar.InitCalendar(nextCalendarDateTime.Month, nextCalendarDateTime.Year);

                Debug.Log("move back");
                rectTrans.anchoredPosition = rectTrans.anchoredPosition + Vector2.right * panelWidth;
            }));
        }
        else
        {
            //跳至上一个月
            DateTime lastCalendarDateTime = currentCalendarDateTime.AddMonths(-1);
            DateTime lastDateOfLast       = new DateTime(currentCalendarDateTime.Year, currentCalendarDateTime.Month, 1).AddDays(-1);
            if (lastDateOfLast < TimeUtil.getDateTimeByInt((int)(SignInMgr.GetInstance().MinDay)))
            {
                //如果上一個月的最後一天也沒有配置
                return;
            }

            //设置currentCalendarDateTime
            currentCalendarDateTime = currentCalendarDateTime.AddMonths(-1);
            Debug.Log(currentCalendarDateTime.Year + " " + currentCalendarDateTime.Month + " " + currentCalendarDateTime.Day);
            lastCalendarDateTime = currentCalendarDateTime.AddMonths(-1);

            //TODO:加入动画而非直接变换位置
            StartCoroutine(moveRectTrans(rectTrans, rectTrans.anchoredPosition + Vector2.right * panelWidth, 0.2f, () =>
            {
                //TODO:动画播完后,改变子节点的排序,即多个日历的排序,由于horizontalLayout的作用会改变每个日历的位置,将最后一个日历放到开头时,当前展示的日历会往右移动,因此整个panel需要再往左移动

                //TODO:原本的最后一个子节点,即最后一个日历放到开头之后,将最后一个日历变为当前查看的日历的前一月份的日历
                Transform lastCalendarTrans = rectTrans.GetChild(rectTrans.childCount - 1);
                lastCalendarTrans.SetAsFirstSibling();

                CalendarTest lastCalendar = lastCalendarTrans.GetComponent <CalendarTest>();
                lastCalendar.InitCalendar(lastCalendarDateTime.Month, lastCalendarDateTime.Year);

                rectTrans.anchoredPosition = rectTrans.anchoredPosition + Vector2.left * panelWidth;
            }));
            // rectTrans.anchoredPosition = rectTrans.anchoredPosition + Vector2.right * panelWidth;
        }
    }