Exemplo n.º 1
0
 private GameObject GetPrefab(RavenhillViewType viewType)
 {
     if (cachedPrefabs.ContainsKey(viewType))
     {
         return(cachedPrefabs[viewType]);
     }
     else
     {
         string path = GetPath(viewType);
         if (!string.IsNullOrEmpty(path))
         {
             GameObject prefab = Resources.Load <GameObject>(path);
             if (prefab != null)
             {
                 cachedPrefabs[viewType] = prefab;
             }
             else
             {
                 throw new ResourceFailedLoadException(path);
             }
             return(prefab);
         }
         else
         {
             throw new UnityException($"Not founded path for view type: {viewService}");
         }
     }
 }
Exemplo n.º 2
0
        public override GameObject ShowView(RavenhillViewType type, object data = null)
        {
            GameObject resultObject = null;

            if (openedViews.ContainsKey(type))
            {
                GameObject existingViewObj = openedViews[type];
                if (existingViewObj)
                {
                    existingViewObj.GetComponentInChildren <RavenhillBaseView>()?.Setup(data);
                    resultObject = existingViewObj;
                }
                else
                {
                    openedViews.Remove(type);
                    resultObject = CreatePrefabAndAddToScreen(type, data);
                    openedViews.Add(type, resultObject);
                }
            }
            else
            {
                resultObject = CreatePrefabAndAddToScreen(type, data);
                openedViews.Add(type, resultObject);
            }

            RavenhillEvents.OnViewAdded(type);
            return(resultObject);
        }
Exemplo n.º 3
0
        public override void RemoveView(RavenhillViewType viewType)
        {
            if (openedViews.ContainsKey(viewType))
            {
                GameObject instance = openedViews[viewType];
                openedViews.Remove(viewType);

                if (instance)
                {
                    RavenhillBaseView baseView = instance.GetComponentInChildren <RavenhillBaseView>();
                    baseView?.OnViewWillBeClosed();

                    if (baseView)
                    {
                        baseView.FadeOut();
                    }
                    else
                    {
                        GameObject.Destroy(instance);
                    }
                    lastViewRemovedTime = Time.time;
                    RavenhillEvents.OnViewRemoved(viewType);
                }
            }
        }
Exemplo n.º 4
0
        private GameObject CreatePrefabAndAddToScreen(RavenhillViewType viewType, object data = null)
        {
            GameObject        prefab   = GetPrefab(viewType);
            GameObject        instance = GameObject.Instantiate <GameObject>(prefab);
            RavenhillBaseView baseView = instance.GetComponentInChildren <RavenhillBaseView>();

            baseView?.Setup(data);
            ICanvasSerive canvasService = engine.GetService <ICanvasSerive>();

            canvasService?.Add(instance.transform);
            SetSibling(baseView);
            return(instance);
        }
Exemplo n.º 5
0
 public override GameObject GetView(RavenhillViewType viewType)
 {
     return(openedViews.GetOrDefault(viewType));
 }
Exemplo n.º 6
0
 public override bool ExistView(RavenhillViewType viewType)
 {
     return(openedViews.ContainsKey(viewType));
 }
Exemplo n.º 7
0
        private System.Collections.IEnumerator CorRemoveView(RavenhillViewType viewType, float delay)
        {
            yield return(new WaitForSeconds(delay));

            RemoveView(viewType);
        }
Exemplo n.º 8
0
 public override void RemoveView(RavenhillViewType viewType, float delay)
 {
     engine.StartCoroutine(CorRemoveView(viewType, delay));
 }
Exemplo n.º 9
0
 public abstract void RemoveView(RavenhillViewType viewType);
Exemplo n.º 10
0
 public abstract void ShowViewWithDelay(RavenhillViewType viewType, float delay, object data = null);
Exemplo n.º 11
0
 private void OnViewRemoved(RavenhillViewType viewType)
 {
     viewRemovedLastTime = Time.time;
 }
Exemplo n.º 12
0
        private System.Collections.IEnumerator CorShowViewWithDelay(RavenhillViewType type, float delay, object data)
        {
            yield return(new WaitForSeconds(delay));

            ShowView(type, data);
        }
Exemplo n.º 13
0
 public override void ShowViewWithDelay(RavenhillViewType viewType, float delay, object data = null)
 {
     Debug.Log($"SHow view {viewType} with delay {delay}");
     engine.StartCoroutine(CorShowViewWithDelay(viewType, delay, data));
 }
Exemplo n.º 14
0
 public abstract GameObject GetView(RavenhillViewType viewType);
Exemplo n.º 15
0
 public abstract void RemoveView(RavenhillViewType viewType, float delay);
Exemplo n.º 16
0
 public abstract void ShowViewWithCondition(RavenhillViewType viewType, System.Func <bool> predicate, object data = null);
Exemplo n.º 17
0
 public string GetPath(RavenhillViewType viewType)
 {
     return(prefabPath.ContainsKey(viewType) ? prefabPath[viewType] : string.Empty);
 }
Exemplo n.º 18
0
 private void OnViewAdded(RavenhillViewType viewType)
 {
     isStopped = viewService.hasModals;
 }
Exemplo n.º 19
0
 public override void ShowViewWithCondition(RavenhillViewType viewType, Func <bool> predicate, object data = null)
 {
     engine.StartCoroutine(CorShowViewWithCondition(viewType, predicate, data));
 }
Exemplo n.º 20
0
 public abstract bool ExistView(RavenhillViewType viewType);
Exemplo n.º 21
0
 public static void OnViewRemoved(RavenhillViewType type)
 {
     ViewRemoved?.Invoke(type);
 }
Exemplo n.º 22
0
        private System.Collections.IEnumerator CorShowViewWithCondition(RavenhillViewType viewType, Func <bool> predicate, object data = null)
        {
            yield return(new WaitUntil(predicate));

            ShowView(viewType, data);
        }
Exemplo n.º 23
0
 private void OnViewRemoved(RavenhillViewType viewType)
 {
     lastViewRemoveTime = Time.time;
 }
Exemplo n.º 24
0
 public abstract GameObject ShowView(RavenhillViewType viewType, object data = null);