Beispiel #1
0
 private void addMoveCharacter(TimerFormat TimerFormat, ref List <string> moveCharacters)
 {
     if (0 >= TimerFormat.UpdateCdTime)
     {
         moveCharacters.Add(TimerFormat.Name);
     }
 }
Beispiel #2
0
    public void removeCharacterTimer(string name)
    {
        TimerFormat format = AllTimerCharacter.Find(x => x.Name.Equals(name));

        if (!string.IsNullOrEmpty(format.Name))
        {
            AllTimerCharacter.Remove(format);
        }
    }
    public static string GetTimerTo(TimeSpan timeSpan, bool withSign = true, TimerFormat format = TimerFormat.Default, string[] labels = null)
    {
        if (labels == null || labels.Length != 4)
        {
            labels = timerToStrings;
        }

        string timerDisplay = withSign && Mathf.Sign((int)timeSpan.TotalSeconds) >= 0 ? "- " : "";
        bool   writeD       = Mathf.FloorToInt((float)timeSpan.TotalDays) != 0;
        bool   writeH       = Mathf.FloorToInt((float)timeSpan.TotalHours) != 0;
        bool   writeM       = Mathf.FloorToInt((float)timeSpan.TotalMinutes) != 0;
        bool   writeS       = Mathf.FloorToInt((float)timeSpan.TotalSeconds) != 0;

        switch (format)
        {
        case TimerFormat.Default:
            if (writeD)
            {
                timerDisplay += Mathf.Abs(timeSpan.Days).ToString() + labels[0] + " : " + Mathf.Abs(timeSpan.Hours).ToString() + labels[1];
            }
            else if (writeH)
            {
                timerDisplay += Mathf.Abs(timeSpan.Hours).ToString() + labels[1] + " : " + Mathf.Abs(timeSpan.Minutes).ToString("00") + labels[2];
            }
            else if (writeM)
            {
                timerDisplay += Mathf.Abs(timeSpan.Minutes).ToString() + labels[2] + " : " + Mathf.Abs(timeSpan.Seconds).ToString("00") + labels[3];
            }
            else
            {
                timerDisplay += Mathf.Abs(timeSpan.Seconds).ToString() + labels[3];
            }
            break;

        case TimerFormat.Extended:
            timerDisplay +=
                (writeD ? (Mathf.Abs(timeSpan.Days).ToString() + labels[0] + " : ") : "") +
                (writeH ? (Mathf.Abs(timeSpan.Hours).ToString() + labels[1] + " : ") : "") +
                (writeM ? (Mathf.Abs(timeSpan.Minutes).ToString("00") + labels[2] + " : ") : "") +
                (!writeD ? (Mathf.Abs(timeSpan.Seconds).ToString("00") + labels[3]) : "");
            break;

        case TimerFormat.CompactMS:
            timerDisplay += Mathf.Abs(timeSpan.Minutes).ToString("00") + ":" + Mathf.Abs(timeSpan.Seconds).ToString("00");
            break;

        case TimerFormat.TotalHM:
            timerDisplay += Mathf.Abs((int)timeSpan.TotalHours).ToString("00") + labels[1].ToLower() + Mathf.Abs(timeSpan.Minutes).ToString("00") + labels[2].ToLower();
            break;
        }
        return(timerDisplay);
    }
Beispiel #4
0
 public void reflashCharacterTimer(string name)
 {
     for (int i = 0; i < AllTimerCharacter.Count; ++i)
     {
         if (AllTimerCharacter[i].Name.Equals(name))
         {
             TimerFormat format = AllTimerCharacter [i];
             format.UpdateCdTime   = format.OrginalCdTime;
             AllTimerCharacter [i] = format;
             break;
         }
     }
 }
Beispiel #5
0
    public void addCharacterTimer(string name, float CdTime)
    {
        TimerFormat oldFormat = AllTimerCharacter.Find(x => x.Name.Equals(name));

        if (oldFormat.Name == null)
        {
            TimerFormat newTimer = new TimerFormat();
            newTimer.Name          = name;
            newTimer.UpdateCdTime  = CdTime;
            newTimer.OrginalCdTime = CdTime;
            AllTimerCharacter.Add(newTimer);
            updateMoveTimeChacracter();
        }
    }
Beispiel #6
0
 /// <summary>
 /// 具体什么时间执行
 /// </summary>
 /// <param name="action">动作</param>
 /// <param name="HHmm">时分</param>
 /// <param name="degree">次数</param>
 /// <param name="format">时间单位</param>
 public void Start(Action action, string HHmm, int degree = 0, TimerFormat format = TimerFormat.Day)
 {
     Stop();
     this.degree = degree;
     this.format = format;
     if (timer.IsNull())
     {
         exec           = action;
         hhmm           = HHmm;
         timer          = new System.Timers.Timer(1000 * 60);
         timer.Elapsed += new System.Timers.ElapsedEventHandler(timer2_Elapsed);
         timer.Enabled  = true;
         timer.Start();
     }
 }
Beispiel #7
0
    // Use this for initialization
    void Start()
    {
        //operate = false;
        sound = this.GetComponent <SoundEffect>();
        timerLowerLimit.second = 0.0f;
        UpdateTimerRect();

        switch (this.tag)       //configuration,cos i want to reuse this script as game clock
        {
        default:
            break;

        case "Alarm":
            previoustimer.second = timer.second = 10.0f;
            timerformat          = TimerFormat.MIN_SEC;
            timerstate           = TimerState.countdown;

            timerRect = new Rect(Screen.width * 0.01f, Screen.height * 0.01f, timerWidth, timerHeight);
            break;

        case "Game Session":
            timerRect = new Rect(Screen.width - timerWidth, Screen.height * 0.01f, timerWidth, timerHeight);

            previoustimer.second = timer.second = 0.0f;

            timerUpperLimit.minute = 99.0f;                    //some ridiculous time
            timerUpperLimit.second = 59.0f;

            timerformat = TimerFormat.MIN_SEC;
            timerstate  = TimerState.countup;

            SetOperate(true);
            break;
        }

        skin = (GUISkin)Resources.Load("Skins/UI");
    }
Beispiel #8
0
 /// <summary>
 /// 具体什么时间执行
 /// </summary>
 /// <param name="action">动作</param>
 /// <param name="HHmm">时分</param>
 /// <param name="degree">次数</param>
 /// <param name="format">时间单位</param>
 public void Start(Action action, string HHmm, int degree = 0, TimerFormat format = TimerFormat.Day) {
     Stop();
     this.degree = degree;
     this.format = format;
     if (timer.IsNull()) {
         exec = action;
         hhmm = HHmm;
         timer = new System.Timers.Timer(1000 * 60);
         timer.Elapsed += new System.Timers.ElapsedEventHandler(timer2_Elapsed);
         timer.Enabled = true;
         timer.Start();
     }
 }
Beispiel #9
0
 /// Constructor acceptiong format and output destination
 public Timer(TimerFormat type, string outTo)
     : this()
 {
     Format = type;
     OutTo = outTo;
 }
 public static string GetTimerTo(float countDown, bool withSign = true, TimerFormat format = TimerFormat.Default, string[] labels = null)
 {
     return(GetTimerTo(new TimeSpan(0, 0, 0, (int)countDown), withSign, format, labels));
 }
 public static string GetTimerTo(DateTime t, bool withSign = true, TimerFormat format = TimerFormat.Default, string[] labels = null)
 {
     return(GetTimerTo(t - DateTime.Now, withSign, format, labels));
 }
Beispiel #12
0
 /// Default constructor
 public Timer()
 {
     Format = TimerFormat.TimeSpan;
 }
Beispiel #13
0
 /// Constructor acceptiong format and output destination
 public Timer(TimerFormat type, string outTo) : this()
 {
     Format = type;
     OutTo  = outTo;
 }