コード例 #1
0
ファイル: RingTaskWnd.cs プロジェクト: atom-chen/tianyu
 /// <summary>
 /// 倒计时自动接取环式任务
 /// </summary>
 void CountDown()
 {
     if (time != null)
     {
         time.GetComponent <UILabel>().text = "3";
     }
     if (time != null)
     {
         time.StartIntervalTimer(3);
         if (autoFilish != null && !autoFilish.activeSelf)
         {
             autoFilish.SetActive(true);
         }
         time.onTimeOut = (x) =>
         {
             autoFilish.SetActive(false);
             TaskInfo info = GameCenter.taskMng.GetCurRingTask;
             if (info.TaskState == TaskStateType.UnTake)
             {
                 GameCenter.taskMng.C2S_AskAcceptRingTask();
             }
             else if (info.TaskState == TaskStateType.Finished)
             {
                 FinishTask(btnFinishTask.gameObject);
                 //Invoke("FinishTask", 0.5f);
             }
             else if (info.TaskState == TaskStateType.Process)
             {
                 GameCenter.taskMng.GoTraceTask(info);
                 if (GameCenter.uIMng.CurOpenType == GUIType.RINGTASK)
                 {
                     GameCenter.uIMng.SwitchToUI(GUIType.NONE);
                 }
             }
         };
     }
 }
コード例 #2
0
    public void AddTimer(string timerID, Transform objectToFollow, Vector3?offset = null)
    {
        UITimer timer = null;

        if (!_timersDict.ContainsKey(timerID))
        {
            timer = Instantiate(_timerPrefab).GetComponent <UITimer>();
            timer.transform.SetParent(transform, true);
            timer.transform.localScale    = Vector3.one;
            timer.transform.localRotation = Quaternion.identity;
            _timersDict.Add(timerID, timer);
        }
        else
        {
            timer = _timersDict[timerID];
        }

        if (timer != null)
        {
            if (offset.HasValue)
            {
                timer.transform.localPosition = offset.Value;
            }

            timer.SetTimer(timerID);
            UIWorldPositioner worldPos = timer.GetComponent <UIWorldPositioner>();
            if (worldPos != null)
            {
                worldPos.ObjectToFollow = objectToFollow;

                if (offset.HasValue)
                {
                    worldPos.Offset = offset.Value;
                }
            }
        }
    }