void Update() { if (_coolSec > 0) { coolText.text = GameText.Format("auto_back", endTime - UtilTools.GetServerTime()); _coolSec = endTime - UtilTools.GetServerTime(); if (_coolSec <= 0) { OnClickOKButton(null); } } }
private void Update() { if (textLabel == null) { return; } //倒计时表现 if (left_time == 0) { textLabel.text = ""; if (OnComplete != null) { OnComplete(gameObject); } return; } if (type == 0) { int nowTime = (int)UtilTools.GetServerTime(); left_time -= (nowTime - startTime); startTime = nowTime; textLabel.text = timeStr(left_time); if (left_time == 0) { textLabel.text = ""; if (OnComplete != null) { OnComplete(gameObject); } } } else if (type == 1) { int left = left_time - (int)UtilTools.GetServerTime(); textLabel.text = timeStr(left); if (left == 0) { textLabel.text = ""; if (OnComplete != null) { OnComplete(gameObject); } } } if (OnUpdate != null) { OnUpdate(); } }
//鱼已经老死了 public bool IsFishTimeOver(int idPath, int birthTime, float fSpeed) { int curTime = UtilTools.GetServerTime(); float fAge = curTime - birthTime; if (fAge < 0) { return(false); } if (dicPathTime.ContainsKey(idPath)) { if (dicPathTime[idPath] / fSpeed <= fAge) { return(true); } } return(false); }
private void Update() { if (textLabel == null) { return; } if (isTicket) { if (end_time == 0) { return; } int nowTime = isServerTime ? UtilTools.GetServerTime() : UtilTools.GetClientTime(); long lastTime = (long)end_time - (long)nowTime; if (lastTime <= 0) { textLabel.text = "0"; if (OnComplete != null) { OnComplete(gameObject); } } else { if (cooldownSound > 0 && lastTime <= cooldownSound && preTime != lastTime) { UtilTools.PlaySoundEffect("Sounds/RichCar/start", 1f); preTime = lastTime; } textLabel.text = lastTime.ToString();//isNoHour ? string.Format("{0:T}", ts).Substring(3) : string.Format("{0:T}", ts); if (OnUpdate != null) { OnUpdate(); } } return; } if (isCooldown) { //倒计时表现 if (end_time == 0) { return; } int nowTime = isServerTime ? UtilTools.GetServerTime() : UtilTools.GetClientTime(); long lastTime = (long)end_time - (long)nowTime; if (lastTime <= 0) { textLabel.text = isNoHour ? "00:00" : "00:00:00"; end_time = 0; if (OnComplete != null) { OnComplete(gameObject); } } else { if (cooldownSound > 0 && lastTime <= cooldownSound && preTime != lastTime) { UtilTools.PlaySoundEffect("Sounds/clock", 1f); preTime = lastTime; } TimeSpan ts = new TimeSpan(0, 0, (int)lastTime); textLabel.text = timeStr(ts);//isNoHour ? string.Format("{0:T}", ts).Substring(3) : string.Format("{0:T}", ts); if (OnUpdate != null) { OnUpdate(); } } } else { //正计时表现 if (start_time == 0) { return; } int nowTime = isServerTime ? UtilTools.GetServerTime() : UtilTools.GetClientTime(); long countTime = (long)nowTime - (long)start_time; if (countTime <= 0) { textLabel.text = isNoHour ? "00:00" : "00:00:00"; } else { TimeSpan ts = new TimeSpan(0, 0, (int)countTime); textLabel.text = timeStr(ts);//isNoHour ? string.Format("{0:T}", ts).Substring(3) : string.Format("{0:T}", ts); } } }
void OnEventSetText(EventMultiArgs args) { string text = args.GetArg <string>("text"); string color = args.GetArg <string>("color"); string alignment = args.GetArg <string>("alignment"); int callbackCount = args.GetArg <int>("callbackCount"); string okBtnName = args.GetArg <string>("okBtnName"); _coolSec = args.GetArg <int>("closeSecond"); bool isShowCloseBtn = args.GetArg <bool>("showClose"); string toShowText = "[" + color + "]" + text + "[-]"; UIWidget uiWidget = labelTipText.GetComponent <UIWidget>(); if (alignment == "Center") { uiWidget.pivot = UIWidget.Pivot.Top; } else if (alignment == "Left") { uiWidget.pivot = UIWidget.Pivot.TopLeft; } if (_coolSec > 0) { coolText.text = GameText.Format("auto_back", _coolSec); endTime = UtilTools.GetServerTime() + _coolSec; } labelTipText.text = toShowText; labelTipText.alignment = (labelTipText.printedSize.y > labelTipText.defaultFontSize + labelTipText.spacingY) ? NGUIText.Alignment.Left : NGUIText.Alignment.Automatic; if (alignment == "CenterAll") { uiWidget.pivot = UIWidget.Pivot.Top; labelTipText.alignment = NGUIText.Alignment.Automatic; } if (okBtnName != "") { oKButton.Find("Label").GetComponent <UILabel>().text = okBtnName; } if (callbackCount == 0) { cancelButton.gameObject.SetActive(false); } else { cancelButton.gameObject.SetActive(true); } closeButton.gameObject.SetActive(isShowCloseBtn); //if (title == "default") // title = GameText.GetStr("messageDialog_tip"); //labelTitleText.text = title; /* * if (controller.needCloseButton) * { * closeButton.gameObject.SetActive(true); * } * else * { * closeButton.gameObject.SetActive(false); * }*/ }
/// <summary> /// 设好结束时间点后,开始自动倒计时 /// </summary> /// <param name="endtime"></param> public void SetTime(int leftTime, int type = 0) { left_time = leftTime; startTime = (int)UtilTools.GetServerTime(); this.type = type; }