Ejemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        ByteBuffer buffer = MyUtilTools.tryToLogic("Regist");

        if (buffer != null)
        {
            //注册成功
            DialogUtil.tip(buffer.ReadString());
            clearInputs();
        }
        buffer = MyUtilTools.tryToLogic("Token");
        if (buffer != null)
        {
            startTime = System.DateTime.Now.Ticks / 10000000;
            tokenButton.SetState(UIButtonColor.State.Disabled, true);
        }
        if (startTime > 0)
        {
            long now = System.DateTime.Now.Ticks / 10000000;
            int  fix = (int)(now - startTime);
            if (fix >= 60)
            {
                init();
            }
            else
            {
                tokenLabe.text = "重发(" + MyUtilTools.numToString(60 - fix) + ")秒";
            }
        }
    }
Ejemplo n.º 2
0
    public void rec()
    {
        int num = int.Parse(label.text);
        int len = flag ? min : 1;

        num -= len;
        if (num < min)
        {
            num = max;
        }
        label.text = MyUtilTools.numToString(num);
    }
Ejemplo n.º 3
0
    public void add()
    {
        int num = int.Parse(label.text);
        int len = flag ? min : 1;

        num += len;
        if (num >= max)
        {
            num = min;
        }
        label.text = MyUtilTools.numToString(num);
    }
Ejemplo n.º 4
0
    void update_time()
    {
        Transform time_trans = transform.FindChild("time");
        UIInput   hour_input = time_trans.FindChild("hour").GetComponent <UIInput>();

        hour_input.value = MyUtilTools.numToString(_hour);
        UIInput minute_input = time_trans.FindChild("minute").GetComponent <UIInput>();

        minute_input.value = MyUtilTools.numToString(_minute);
        UIInput second_input = time_trans.FindChild("second").GetComponent <UIInput>();

        second_input.value = MyUtilTools.numToString(_second);
    }
Ejemplo n.º 5
0
 void Start()
 {
     panel    = GameObject.Find("main").GetComponent <UIPanel>();
     base_obj = GameObject.Find("base");
     if (!flag)
     {
         year   = transform.parent.FindChild("year").GetComponent <UIInput>();
         month  = transform.parent.FindChild("month").GetComponent <UIInput>();
         day    = transform.parent.FindChild("day").GetComponent <UIInput>();
         hour   = transform.parent.FindChild("hour").GetComponent <UIInput>();
         minute = transform.parent.FindChild("minute").GetComponent <UIInput>();
         System.DateTime now = System.DateTime.Now;
         year.value   = MyUtilTools.numToString(now.Year);
         month.value  = MyUtilTools.numToString(now.Month);
         day.value    = MyUtilTools.numToString(now.Day);
         hour.value   = MyUtilTools.numToString(23);
         minute.value = MyUtilTools.numToString(59);
     }
 }
Ejemplo n.º 6
0
    void update_days(bool flag)
    {
        GameObject days_obj = transform.FindChild("days").gameObject;
        GameObject select   = null;
        int        maxDays  = DateTime.DaysInMonth(_year, _month);
        DateTime   fisrt    = new DateTime(_year, _month, 1);
        DayOfWeek  week     = fisrt.DayOfWeek;
        int        start    = MyUtilTools.GetWeekDays(week);//这个月的第一天
        int        preMonth = _month - 1;
        int        preYear  = _year;

        if (preMonth == 0)
        {
            preMonth = 12;
            preYear--;
        }
        int  stand          = start == 0 ? 1 : 0;
        int  temp           = start == 0 ? 7 : start;
        int  preLastDay     = DateTime.DaysInMonth(preYear, preMonth);
        int  dayIndex       = preLastDay - temp + 1;
        int  dayCount       = 0;
        int  nextMonth      = _month;
        int  nextYear       = _year;
        bool nextMonthStart = false;
        bool thisMonthStart = false;

        for (int i = 0; i < 6; i++)
        {
            GameObject row_obj = days_obj.transform.FindChild("row" + i).gameObject;
            if (i <= stand)
            {
                for (int j = 0; j < 7; j++)
                {
                    GameObject day = row_obj.transform.FindChild("col" + j).gameObject;
                    if (flag)
                    {
                        UIButton      button       = day.GetComponent <UIButton>();
                        EventDelegate event_select = new EventDelegate(this, "doSelect");
                        event_select.parameters[0]     = new EventDelegate.Parameter();
                        event_select.parameters[0].obj = day;
                        button.onClick.Add(event_select);
                    }
                    if (dayIndex < preLastDay - 1 && !thisMonthStart)
                    {
                        day.SetActive(false);
                    }
                    else
                    {
                        if (!thisMonthStart && dayIndex > preLastDay)
                        {
                            thisMonthStart = true;
                            dayIndex       = 1;
                            preMonth++;
                            if (preMonth > 12)
                            {
                                preMonth = 1;
                                preYear++;
                            }
                        }
                        day.SetActive(true);
                        UILabel label = day.transform.FindChild("gl").GetComponent <UILabel>();
                        label.text = dayIndex + "";
                        label      = day.transform.FindChild("nl").GetComponent <UILabel>();
                        if (dayIndex == DateTime.Now.Day && preMonth == DateTime.Now.Month && preYear == DateTime.Now.Year)
                        {
                            label.text = "今天";
                        }
                        else
                        {
                            DateTime dateTime = DateTime.Parse(preYear + "-" + MyUtilTools.numToString(preMonth) + "-" + MyUtilTools.numToString(dayIndex) + " 00:00:00");
                            CNDate   cnDate   = ChinaDate.getChinaDate(dateTime);
                            if (!cnDate.cnFtvl.Equals(""))
                            {
                                label.text = cnDate.cnFtvl;
                            }
                            else if (!cnDate.cnFtvs.Equals(""))
                            {
                                label.text = cnDate.cnFtvs;
                            }
                            else if (!cnDate.cnSolarTerm.Equals(""))
                            {
                                label.text = cnDate.cnSolarTerm;
                            }
                            else
                            {
                                label.text = cnDate.cnStrDay;
                            }
                        }
                        if (selectIndex == -1 && _day == dayIndex && nextMonth == _month && nextYear == _year)
                        {
                            selectIndex = dayCount;
                        }
                    }
                    CalendarData cd = day.GetComponent <CalendarData>();
                    cd.Value = MyUtilTools.numToString(preYear) + "-" + MyUtilTools.numToString(preMonth) + "-" + MyUtilTools.numToString(dayIndex);
                    cd.Index = dayCount;
                    dayIndex++;
                    dayCount++;
                }
            }
            else
            {
                for (int j = 0; j < 7; j++)
                {
                    GameObject day = row_obj.transform.FindChild("col" + j).gameObject;
                    if (flag)
                    {
                        UIButton      button       = day.GetComponent <UIButton>();
                        EventDelegate event_select = new EventDelegate(this, "doSelect");
                        event_select.parameters[0]     = new EventDelegate.Parameter();
                        event_select.parameters[0].obj = day;
                        button.onClick.Add(event_select);
                    }
                    if (nextMonthStart)
                    {
                        day.SetActive(false);
                    }
                    else
                    {
                        day.SetActive(true);
                        UILabel label = day.transform.FindChild("gl").GetComponent <UILabel>();
                        label.text = dayIndex + "";
                        label      = day.transform.FindChild("nl").GetComponent <UILabel>();
                        if (dayIndex == DateTime.Now.Day && nextMonth == DateTime.Now.Month && nextYear == DateTime.Now.Year)
                        {
                            label.text = "今天";
                        }
                        else
                        {
                            DateTime dateTime = DateTime.Parse(nextYear + "-" + MyUtilTools.numToString(nextMonth) + "-" + MyUtilTools.numToString(dayIndex) + " 00:00:00");
                            CNDate   cnDate   = ChinaDate.getChinaDate(dateTime);
                            if (!cnDate.cnFtvl.Equals(""))
                            {
                                label.text = cnDate.cnFtvl;
                            }
                            else if (!cnDate.cnFtvs.Equals(""))
                            {
                                label.text = cnDate.cnFtvs;
                            }
                            else if (!cnDate.cnSolarTerm.Equals(""))
                            {
                                label.text = cnDate.cnSolarTerm;
                            }
                            else
                            {
                                label.text = cnDate.cnStrDay;
                            }
                        }
                        if (selectIndex == -1 && _day == dayIndex && nextMonth == _month && nextYear == _year)
                        {
                            selectIndex = dayCount;
                        }
                        CalendarData cd = day.GetComponent <CalendarData>();
                        cd.Value = MyUtilTools.numToString(nextYear) + "-" + MyUtilTools.numToString(nextMonth) + "-" + MyUtilTools.numToString(dayIndex);
                        cd.Index = dayCount;
                        dayIndex++;
                        if (dayIndex > maxDays)
                        {//下一个月的天数
                            nextMonthStart = true;
                            dayIndex       = 1;
                            nextMonth++;
                            if (nextMonth > 12)
                            {
                                nextMonth = 1;
                                nextYear++;
                            }
                        }
                    }
                    dayCount++;
                }
            }
        }
        int row = selectIndex / 7;
        int col = selectIndex % 7;

        select = days_obj.transform.FindChild("row" + row).FindChild("col" + col).gameObject;
        if (flag)
        {
            selectIndex = -1;
        }
        doSelect(select);
    }
Ejemplo n.º 7
0
    void update_year_month()
    {
        UILabel label_year = transform.FindChild("year").FindChild("year-moth").GetComponent <UILabel>();

        label_year.text = _year + "年" + MyUtilTools.numToString(_month) + "月";
    }
Ejemplo n.º 8
0
    void _update()
    {
        if (list_container == null)
        {
            list_container = needshow[0].transform.FindChild("list").FindChild("body").FindChild("container");
            texture1       = Resources.Load <Texture>("pic/time-event1");
            texture2       = Resources.Load <Texture>("pic/time-event2");
            texture3       = Resources.Load <Texture>("pic/time-event3");
            texture4       = Resources.Load <Texture>("pic/time-event4");
            TimeLineRefresh refresh = needshow[0].AddComponent <TimeLineRefresh>();
            refresh.timeEvent = this;
        }
        if (Calendar.selectTexture == null)
        {
            Calendar.selectTexture = Resources.Load <Texture>("pic/time-sb");
        }
        list_container.parent.GetComponent <UIPanel>().clipOffset = Vector2.zero;
        list_container.parent.localPosition = new Vector3(0, 0, 0);
        UILabel year_label = list_container.FindChild("up").GetComponent <UILabel>();

        year_label.text = MyUtilTools.numToString(_year) + "年" + MyUtilTools.numToString(_month) + "月";
        Transform days_trans = list_container.FindChild("days");
        int       maxDays    = DateTime.DaysInMonth(_year, _month);
        DateTime  fisrt      = new DateTime(_year, _month, 1);
        DayOfWeek week       = fisrt.DayOfWeek;
        int       start      = MyUtilTools.GetWeekDays(week);//这个月的第一天
        int       preMonth   = _month - 1;
        int       preYear    = _year;

        if (preMonth == 0)
        {
            preMonth = 12;
            preYear--;
        }
        int  stand          = start == 0 ? 1 : 0;
        int  temp           = start == 0 ? 7 : start;
        int  preLastDay     = DateTime.DaysInMonth(preYear, preMonth);
        int  dayIndex       = preLastDay - temp + 1;
        int  dayCount       = 0;
        int  nextMonth      = _month;
        int  nextYear       = _year;
        bool nextMonthStart = false;
        bool thisMonthStart = false;

        for (int i = 0; i < 6; i++)
        {
            GameObject row_obj = days_trans.FindChild("row" + i).gameObject;
            if (i <= stand)
            {
                for (int j = 0; j < 7; j++)
                {
                    GameObject day    = row_obj.transform.FindChild("col" + j).gameObject;
                    UIButton   button = day.GetComponent <UIButton>();
                    if (button.onClick.Count == 0)
                    {
                        EventDelegate event_select = new EventDelegate(this, "doSelect");
                        event_select.parameters[0]     = new EventDelegate.Parameter();
                        event_select.parameters[0].obj = day;
                        button.onClick.Add(event_select);
                    }
                    if (dayIndex < preLastDay - 1 && !thisMonthStart)
                    {
                        day.SetActive(false);
                    }
                    else
                    {
                        if (!thisMonthStart && dayIndex > preLastDay)
                        {
                            thisMonthStart = true;
                            dayIndex       = 1;
                            preMonth++;
                            if (preMonth > 12)
                            {
                                preMonth = 1;
                                preYear++;
                            }
                        }
                        day.SetActive(true);
                        UILabel label = day.transform.FindChild("gl").GetComponent <UILabel>();
                        label.text = dayIndex + "";
                        label      = day.transform.FindChild("nl").GetComponent <UILabel>();
                        if (dayIndex == DateTime.Now.Day && preMonth == DateTime.Now.Month && preYear == DateTime.Now.Year)
                        {
                            label.text = "今天";
                        }
                        else
                        {
                            DateTime dateTime = DateTime.Parse(preYear + "-" + MyUtilTools.numToString(preMonth) + "-" + MyUtilTools.numToString(dayIndex) + " 00:00:00");
                            CNDate   cnDate   = ChinaDate.getChinaDate(dateTime);
                            if (!cnDate.cnFtvl.Equals(""))
                            {
                                label.text = cnDate.cnFtvl;
                            }
                            else if (!cnDate.cnFtvs.Equals(""))
                            {
                                label.text = cnDate.cnFtvs;
                            }
                            else if (!cnDate.cnSolarTerm.Equals(""))
                            {
                                label.text = cnDate.cnSolarTerm;
                            }
                            else
                            {
                                label.text = cnDate.cnStrDay;
                            }
                        }
                        if (selectIndex == -1 && _day == dayIndex && nextMonth == _month && nextYear == _year)
                        {
                            selectIndex = dayCount;
                        }
                    }
                    _update_flags(day, preYear, preMonth, dayIndex);
                    CalendarData cd = day.GetComponent <CalendarData>();
                    cd.Value = MyUtilTools.numToString(preYear) + "-" + MyUtilTools.numToString(preMonth) + "-" + MyUtilTools.numToString(dayIndex);
                    cd.Index = dayCount;
                    dayIndex++;
                    dayCount++;
                }
            }
            else
            {
                for (int j = 0; j < 7; j++)
                {
                    GameObject day    = row_obj.transform.FindChild("col" + j).gameObject;
                    UIButton   button = day.GetComponent <UIButton>();
                    if (button.onClick.Count == 0)
                    {
                        EventDelegate event_select = new EventDelegate(this, "doSelect");
                        event_select.parameters[0]     = new EventDelegate.Parameter();
                        event_select.parameters[0].obj = day;
                        button.onClick.Add(event_select);
                    }
                    if (nextMonthStart)
                    {
                        day.SetActive(false);
                    }
                    else
                    {
                        day.SetActive(true);
                        UILabel label = day.transform.FindChild("gl").GetComponent <UILabel>();
                        label.text = dayIndex + "";
                        label      = day.transform.FindChild("nl").GetComponent <UILabel>();
                        if (dayIndex == DateTime.Now.Day && nextMonth == DateTime.Now.Month && nextYear == DateTime.Now.Year)
                        {
                            label.text = "今天";
                        }
                        else
                        {
                            DateTime dateTime = DateTime.Parse(nextYear + "-" + MyUtilTools.numToString(nextMonth) + "-" + MyUtilTools.numToString(dayIndex) + " 00:00:00");
                            CNDate   cnDate   = ChinaDate.getChinaDate(dateTime);
                            if (!cnDate.cnFtvl.Equals(""))
                            {
                                label.text = cnDate.cnFtvl;
                            }
                            else if (!cnDate.cnFtvs.Equals(""))
                            {
                                label.text = cnDate.cnFtvs;
                            }
                            else if (!cnDate.cnSolarTerm.Equals(""))
                            {
                                label.text = cnDate.cnSolarTerm;
                            }
                            else
                            {
                                label.text = cnDate.cnStrDay;
                            }
                        }
                        if (selectIndex == -1 && _day == dayIndex && nextMonth == _month && nextYear == _year)
                        {
                            selectIndex = dayCount;
                        }
                        _update_flags(day, nextYear, nextMonth, dayIndex);
                        CalendarData cd = day.GetComponent <CalendarData>();
                        cd.Value = MyUtilTools.numToString(nextYear) + "-" + MyUtilTools.numToString(nextMonth) + "-" + MyUtilTools.numToString(dayIndex);
                        cd.Index = dayCount;
                        dayIndex++;
                        if (dayIndex > maxDays)
                        {//下一个月的天数
                            nextMonthStart = true;
                            dayIndex       = 1;
                            nextMonth++;
                            if (nextMonth > 12)
                            {
                                nextMonth = 1;
                                nextYear++;
                            }
                        }
                    }
                    dayCount++;
                }
            }
        }
        int        row    = selectIndex / 7;
        int        col    = selectIndex % 7;
        GameObject select = days_trans.FindChild("row" + row).FindChild("col" + col).gameObject;

        doSelect(select);
    }
Ejemplo n.º 9
0
    void initMessage(MainData.MessageBody message)
    {
        GameObject pref_obj    = message.type == 1 ? (message.sendId == MainData.instance.user.id ? pref_message_pic_detail_right : pref_message_pic_detail_left) : (message.sendId == MainData.instance.user.id ? pref_message_word_detail_right : pref_message_word_detail_left);
        GameObject message_obj = NGUITools.AddChild(messageDetailContainer.gameObject, pref_obj);

        message_obj.name = "message-" + message.id;
        Transform icon_tran = message_obj.transform.FindChild("icon");

        icon_tran.GetComponent <UISprite>().spriteName = message.sendFace;
        Transform time_tran = message_obj.transform.FindChild("time");

        time_tran.gameObject.SetActive(message.showTime == 1);
        if (message.showTime == 1)
        {
            UILabel         time_label = time_tran.GetComponent <UILabel>();
            System.DateTime dateTime   = System.DateTime.Parse(message.time);
            string          showStr    = null;
            //int days = System.DateTime.DaysInMonth(dateTime.Year, dateTime.Month);
            if (System.DateTime.Now.Year == dateTime.Year && System.DateTime.Now.Month == dateTime.Month && System.DateTime.Now.Day == dateTime.Day)
            {//同一天
                showStr = "今天" + MyUtilTools.numToString(dateTime.Hour) + ":" + MyUtilTools.numToString(dateTime.Minute);
            }
            else
            {
                showStr = dateTime.Year + "/" + MyUtilTools.numToString(dateTime.Month) + "/" + MyUtilTools.numToString(dateTime.Day) + " " + MyUtilTools.numToString(dateTime.Hour) + ":" + MyUtilTools.numToString(dateTime.Minute);
            }
            time_label.text = showStr;
            messageStarty  -= 70;
        }
        if (message.type == 0)
        {//文字类型
            Transform content_trans = message_obj.transform.FindChild("content");
            float     cx            = content_trans.localPosition.x;
            Transform rect_tran     = content_trans.FindChild("rect");
            UISprite  rect_sprite   = rect_tran.GetComponent <UISprite>();
            UILabel   content       = rect_tran.FindChild("value").GetComponent <UILabel>();
            content.width = 570;
            content.text  = message.content;
            int row    = MyUtilTools.computeRow(content);
            int height = row * 64;
            if (row == 1)
            {
                int width = (int)MyUtilTools.computeLen(content) + content.fontSize;
                rect_sprite.width = Mathf.Min(600, width);
                content.width     = rect_sprite.width - content.fontSize;
            }
            rect_sprite.height = height;
            content.height     = row * (content.fontSize + content.spacingX);
            float offx     = rect_sprite.width / 2 + 14;
            int   opration = cx > 0 ? -1 : 1;
            rect_tran.localPosition             = new Vector3(opration * offx, content.fontSize - height / 2 - 5, 0);
            message_obj.transform.localPosition = new Vector3(0, messageStarty, 0);
            messageStarty -= height + 10;
        }
        else //图片
        {
            UITexture pic_texture = message_obj.transform.FindChild("content").FindChild("rect").FindChild("value").GetComponent <UITexture>();
            JustRun.Instance.loadPic(message.content, pic_texture);
            message_obj.transform.localPosition = new Vector3(0, messageStarty, 0);
            messageStarty -= 590;
        }
    }