Ejemplo n.º 1
0
 public static void WaitSeconds(Action action, float seconds)
 {
     if (action == null)
     {
         return;
     }
     _instance.StartCoroutine(WaitRoutine(action, seconds));
 }
Ejemplo n.º 2
0
 /// <summary>
 /// 加载
 /// </summary>
 /// <param name="proxy"></param>
 public virtual void Load(AssetDataProxy proxy)
 {
     if (m_queueLoading != null)
     {
         m_queueLoading.Enqueue(proxy);
     }
     CoroutineUtil.StartCoroutine(OnLoading());
 }
Ejemplo n.º 3
0
 public void Start(float pDelay, float pInterval, int pCount, Action pCallback)
 {
     _delay    = pDelay;
     _interval = pInterval;
     _callback = pCallback;
     _count    = pCount;
     _started  = true;
     CoroutineUtil.StartCoroutine(Delay());
 }
Ejemplo n.º 4
0
 static void Add(IEnumerator value)
 {
     if (value == null)
     {
         return;
     }
     _routines.Add(value);
     _instance.StartCoroutine(value);
 }
Ejemplo n.º 5
0
 public override void Start()
 {
     _navMeshAgent.enabled          = true;
     _navMeshAgent.speed            = _walker.Speed;
     _navMeshAgent.stoppingDistance = _walker.GetStopDistance();
     _isStarted = true;
     if (MoveStartEvent != null)
     {
         MoveStartEvent();
     }
     _navMeshAgent.nextPosition           = _walker.GetPosition();
     _agentObject.transform.localPosition = _walker.GetPosition();
     _navMeshAgent.SetDestination(_targetPosition);
     CoroutineUtil.StartCoroutine(NextFrameStartCheck());
 }
Ejemplo n.º 6
0
 /// <summary>
 /// 从SceneInfo配置中加载一个场景,这个场景一定是Unity场景
 /// 所有场景都以异步形式加载
 /// </summary>
 /// <param name="pSceneInfoID"></param>
 public void LoadScene(int pSceneID)
 {
     _sceneInfo = DataConfigManager.GetInstance().GetConfigData <SceneInfo>(DataConfigDefine.SceneInfo, pSceneID);
     if (_sceneInfo != null)
     {
         if (_asyncOperation != null)
         {
             CoroutineUtil.StopCoroutine(StartLoadSceneAsync());
             TimeManager.GetInstance().UpdateEvent -= Update;
         }
         TimeManager.GetInstance().UpdateEvent += Update;
         CoroutineUtil.StartCoroutine(StartLoadSceneAsync());
     }
     else
     {
         LogManager.Error("Load scene data is null:" + pSceneID);
     }
 }
Ejemplo n.º 7
0
 public ResourceLoader(string pPath, Type pType = null, ResouceLoadedCompleteHandler pHandler = null,
                       params object[] pParams)
 {
     _path    = pPath;
     _handler = pHandler;
     _params  = pParams;
     _type    = pType == null ? typeof(GameObject) : pType;
     if (string.IsNullOrEmpty(_path))
     {
         if (pHandler != null)
         {
             pHandler(null, pParams);
         }
     }
     else
     {
         _resourceRequest = Resources.LoadAsync(_path, _type);
         CoroutineUtil.StartCoroutine(CheckHasDone());
     }
 }
Ejemplo n.º 8
0
        IEnumerator Delay()
        {
            yield return(new WaitForSeconds(_delay));

            CoroutineUtil.StartCoroutine(CountDown());
        }
Ejemplo n.º 9
0
        /// <summary>
        /// 进入下载状态
        /// </summary>
        /// <returns></returns>
        protected override IEnumerator OnLoading()
        {
            AssetDataProxy proxy = GetLoadProxy();

            if (proxy == null)
            {
                yield break;
            }

            // 正在加载
            if (proxy.Data.IsLoading)
            {
                while (!proxy.IsAbort && proxy.Data.IsLoading)
                {
                    yield return(1);
                }
                if (proxy.IsAbort)
                {
                    yield break;
                }

                proxy.AssetComplete();
                yield break;
            }

            // 排队等待
            while (!HasAccess && !proxy.IsAbort)
            {
                yield return(1);
            }
            if (proxy.IsAbort)
            {
                yield break;
            }

            // 再次检测
            if (proxy.Data.IsLoading)
            {
                while (!proxy.IsAbort && proxy.Data.IsLoading)
                {
                    yield return(1);
                }
                if (proxy.IsAbort)
                {
                    yield break;
                }

                proxy.AssetComplete();
                yield break;
            }

            // 加载完成
            if (proxy.Data.IsLoaded)
            {
                proxy.AssetComplete();
                yield break;
            }

            // 开始加载
            IncreaseLoadingWork();
            CoroutineUtil.StartCoroutine(OnDownload(proxy));
            DecreaseLoadingWork();

            proxy.AssetComplete();
        }
Ejemplo n.º 10
0
        public void PointToTarget(RectTransform pTarget, PointerAlignment pAlignment, float pOffset = 0, bool pPostValidate = true)
        {
            mRectPointer.SetActive(true);

            mRectPointer.position = pTarget.position;
            var targetPivot = pTarget.pivot;
            var x           = mRectPointer.anchoredPosition.x - pTarget.rect.width * targetPivot.x + pTarget.rect.width / 2f;
            var y           = mRectPointer.anchoredPosition.y - pTarget.rect.height * targetPivot.y + pTarget.rect.height / 2f;

            mRectPointer.anchoredPosition = new Vector2(x, y);

            var targetBounds = pTarget.Bounds();
            var arrowBounds  = mRectPointer.Bounds();
            var arrowPos     = mRectPointer.anchoredPosition;

            switch (pAlignment)
            {
            case PointerAlignment.TopLeft:
                arrowPos.y = arrowPos.y + targetBounds.size.y / 2 + arrowBounds.size.y / 2 + pOffset;
                arrowPos.x = arrowPos.x - targetBounds.size.x / 2 - arrowBounds.size.x / 2 - pOffset;
                mRectPointer.eulerAngles = (new Vector3(0, 0, 45));
                break;

            case PointerAlignment.Top:
                arrowPos.y = arrowPos.y + targetBounds.size.y / 2 + arrowBounds.size.y / 2 + pOffset;
                mRectPointer.eulerAngles = (new Vector3(0, 0, 0));
                break;

            case PointerAlignment.TopRight:
                arrowPos.y = arrowPos.y + targetBounds.size.y / 2 + arrowBounds.size.y / 2 + pOffset;
                arrowPos.x = arrowPos.x + targetBounds.size.x / 2 + arrowBounds.size.x / 2 + pOffset;
                mRectPointer.eulerAngles = (new Vector3(0, 0, -45));
                break;

            case PointerAlignment.Left:
                arrowPos.x = arrowPos.x - targetBounds.size.x / 2 - arrowBounds.size.x / 2 + pOffset;
                mRectPointer.eulerAngles = (new Vector3(0, 0, 90));
                break;

            case PointerAlignment.Center:
                break;

            case PointerAlignment.Right:
                arrowPos.x = arrowPos.x + targetBounds.size.x / 2 + arrowBounds.size.x / 2 + pOffset;
                mRectPointer.eulerAngles = (new Vector3(0, 0, -90));
                break;

            case PointerAlignment.BotLeft:
                arrowPos.y = arrowPos.y - targetBounds.size.y / 2 - arrowBounds.size.y / 2 - pOffset;
                arrowPos.x = arrowPos.x - targetBounds.size.x / 2 - arrowBounds.size.x / 2 - pOffset;
                mRectPointer.eulerAngles = (new Vector3(0, 0, -235));
                break;

            case PointerAlignment.Bot:
                arrowPos.y = arrowPos.y - targetBounds.size.y / 2 - arrowBounds.size.y / 2 - pOffset;
                mRectPointer.eulerAngles = (new Vector3(0, 0, 180));
                break;

            case PointerAlignment.BotRight:
                arrowPos.y = arrowPos.y - targetBounds.size.y / 2 - arrowBounds.size.y / 2 - pOffset;
                arrowPos.x = arrowPos.x + targetBounds.size.x / 2 + arrowBounds.size.x / 2 + pOffset;
                mRectPointer.eulerAngles = (new Vector3(0, 0, 235));
                break;
            }

            mRectPointer.anchoredPosition = arrowPos;
            enabled = true;

            if (pPostValidate)
            {
                CoroutineUtil.StartCoroutine(IEPostValidatingPointer(pTarget, pAlignment, pOffset));
            }
        }
Ejemplo n.º 11
0
        public void MessageToTarget(RectTransform pTarget, string pMessage, PointerAlignment pAlignment, Vector2 pSize, float pOffset = 30, bool pPostValidate = true)
        {
            mRectMessage.SetActive(true);
            mTxtMessage.text       = pMessage;
            mRectMessage.sizeDelta = pSize;

            if (pTarget == null)
            {
                mRectMessage.anchoredPosition = Vector2.zero;
            }
            else
            {
                mRectMessage.position = pTarget.position;
                var targetPivot = pTarget.pivot;
                var x           = mRectMessage.anchoredPosition.x - pTarget.rect.width * targetPivot.x + pTarget.rect.width / 2f;
                var y           = mRectMessage.anchoredPosition.y - pTarget.rect.height * targetPivot.y + pTarget.rect.height / 2f;
                mRectMessage.anchoredPosition = new Vector2(x, y);

                var targetBounds  = pTarget.Bounds();
                var boxBounds     = mRectMessage.Bounds();
                var messageBoxPos = mRectMessage.anchoredPosition;

                switch (pAlignment)
                {
                case PointerAlignment.TopLeft:
                    messageBoxPos.y = messageBoxPos.y + targetBounds.size.y / 2 + boxBounds.size.y / 2 + pOffset;
                    messageBoxPos.x = messageBoxPos.x - targetBounds.size.x / 2 - boxBounds.size.x / 2 - pOffset;
                    break;

                case PointerAlignment.Top:
                    messageBoxPos.y = messageBoxPos.y + targetBounds.size.y / 2 + boxBounds.size.y / 2 + pOffset;
                    break;

                case PointerAlignment.TopRight:
                    messageBoxPos.y = messageBoxPos.y + targetBounds.size.y / 2 + boxBounds.size.y / 2 + pOffset;
                    messageBoxPos.x = messageBoxPos.x + targetBounds.size.x / 2 + boxBounds.size.x / 2 + pOffset;
                    break;

                case PointerAlignment.Left:
                    messageBoxPos.x = messageBoxPos.x - targetBounds.size.x / 2 - boxBounds.size.x / 2 - pOffset;
                    break;

                case PointerAlignment.Center:
                    break;

                case PointerAlignment.Right:
                    messageBoxPos.x = messageBoxPos.x + targetBounds.size.x / 2 + boxBounds.size.x / 2 + pOffset;
                    break;

                case PointerAlignment.BotLeft:
                    messageBoxPos.y = messageBoxPos.y - targetBounds.size.y / 2 - boxBounds.size.y / 2 - pOffset;
                    messageBoxPos.x = messageBoxPos.x - targetBounds.size.x / 2 - boxBounds.size.x / 2 - pOffset;
                    break;

                case PointerAlignment.Bot:
                    messageBoxPos.y = messageBoxPos.y - targetBounds.size.y / 2 - boxBounds.size.y / 2 - pOffset;
                    break;

                case PointerAlignment.BotRight:
                    messageBoxPos.y = messageBoxPos.y - targetBounds.size.y / 2 - boxBounds.size.y / 2 - pOffset;
                    messageBoxPos.x = messageBoxPos.x + targetBounds.size.x / 2 + boxBounds.size.x / 2 + pOffset;
                    break;
                }
                mRectMessage.anchoredPosition = messageBoxPos;
            }
            enabled = true;

            if (pPostValidate)
            {
                CoroutineUtil.StartCoroutine(IEPostValidatingMessage(pTarget, pMessage, pAlignment, pSize, pOffset));
            }
        }
Ejemplo n.º 12
0
 public Coroutine CreateAC(string path, string[] depends, CollectComplete collector)
 {
     return(CoroutineUtil.StartCoroutine(CreateACCoroutine(path, depends, collector)));
 }