Esempio n. 1
0
    public static void Tick(float dt)
    {
        if (_AllCreatedList == null || _AllCreatedList.Count <= 0)
        {
            return;
        }
        //float t = Time.time;
        for (int i = 0; i < _AllCreatedList.Count; i++)
        {
            UISfxBehaviour uib = _AllCreatedList[i];
            if (uib == null)
            {
                _AllCreatedList.RemoveAt(i);
                i -= 1;
            }
            else
            {
                if (!uib._IsPlaying && !uib._IsLoading)
                {
                    uib.TimeToBeDestroy -= dt;
                    if (uib.TimeToBeDestroy < 0)
                    {
                        GameObject.Destroy(uib.gameObject);
                    }
                }
            }
        }

        CheckPrefabCached(dt);
    }
Esempio n. 2
0
    public static void Stop(string fxPath, GameObject target)
    {
        if (string.IsNullOrEmpty(fxPath))
        {
            return;
        }

        for (int i = 0; i < _AllCreatedList.Count; i++)
        {
            UISfxBehaviour item = _AllCreatedList[i];
            if (item != null && item.Target == target && item.FxPath == fxPath)
            {
                item.StopPlay();
            }
        }
    }
Esempio n. 3
0
 public static bool IsPlaying(string fxPath, GameObject target, GameObject hook_point)
 {
     if (string.IsNullOrEmpty(fxPath) || target == null)
     {
         return(false);
     }
     UISfxBehaviour [] sfxs = hook_point.GetComponentsInChildren <UISfxBehaviour>();
     for (int i = 0; i < sfxs.Length; i++)
     {
         UISfxBehaviour item = sfxs[i];
         if (item.Target == target && item.FxPath == fxPath && item._IsPlaying)
         {
             return(true);
         }
     }
     return(false);
 }
Esempio n. 4
0
    public static GameObject PlayFx(Transform hook, Transform anchor, GameObject clipper, string fx_path, float life_time, bool is_ui, int order_offset = 0)
    {
        if (!is_ui)
        {
#if ART_USE && UNITY_EDITOR
            GameObject obj = UnityEditor.AssetDatabase.LoadAssetAtPath(fx_path, typeof(GameObject)) as GameObject;
            if (obj != null)
            {
                obj = Object.Instantiate <GameObject>(obj);
                Transform t = obj.transform;
                t.SetParent(hook, false);
                obj.SetActive(true);
                Util.SetLayerRecursively(obj, LayerMask.NameToLayer("UIScene"));

                //re-position
                if (anchor != null && anchor != hook)
                {
                    t.position = anchor.position;
                }

                if (life_time < 0.0001f)
                {
                    FxDuration fxd = obj.GetComponent <FxDuration>();
                    if (fxd != null)
                    {
                        life_time = fxd.duration;
                    }
                }

                Object.Destroy(obj, life_time > 0.0001f ? life_time : 5);

                Debug.Log("PlayFx " + hook.name + ", " + fx_path + ", " + life_time);
            }
            return(obj);
#else
            //Debug.Log("TODO: PlayFx");
        #if IN_GAME
            int    fxId  = 0;
            CFxOne fxOne = CFxCacheMan.Instance.RequestFxOne(fx_path, -1, out fxId);
            if (fxOne != null)
            {
                Transform  t_fx = fxOne.transform;
                GameObject g_fx = fxOne.gameObject;
                t_fx.SetParent(hook, false);

                //re-position
                if (anchor != null && anchor != hook)
                {
                    t_fx.position = anchor.position;
                }

                //g_fx.SetActive(true);
                Util.SetLayerRecursively(g_fx, LayerMask.NameToLayer("UIScene"));

                fxOne.Play(life_time);
                return(fxOne.gameObject);
            }

            return(null);
#else
            return(null);
#endif
#endif
        }
        else
        {
            return(UISfxBehaviour.Play(fx_path, anchor.gameObject, hook.gameObject, clipper, life_time, 20, order_offset));
        }
    }
Esempio n. 5
0
    void Update()
    {
        if (!_IsInited)
        {
            return;
        }

#if ONGUI_DEBUG
        /*
         * if (Main.HostPalyer != null)
         * {
         *  Vector3 polyPickExt = new Vector3(1, 256, 1);
         *
         *  //Vector3 pos = new Vector3(6.78f, 28.74f, 50.72f);
         *  Vector3 pos = Main.HostPalyer.transform.position;
         *  //Vector3 target = new Vector3(6.78f, 28.74f, 47.72f);        //干尸
         *  //Vector3 target = new Vector3(-21.85f, 27.31f, 38.80f);
         *  //Vector3 target = new Vector3(77.5f, 46.0f, -69.3f);         //110地图某点
         *  //Vector3 target = pos + new Vector3(1, 2, 3);           //110二层楼高点
         *
         *  Vector3 target = new Vector3(142.47f, 24.04f, -127.85f);
         *
         *  Vector3 nearest = target;
         *  _IsValidStart = NavMeshManager.Instance.IsValidPositionStrict(pos);
         *
         *  _IsValidEnd = NavMeshManager.Instance.IsValidPositionStrict(target);
         *
         *  _IsConnected = PathFindingManager.Instance.IsConnected(pos, target);
         *
         *  _CanNavigateTo = PathFindingManager.Instance.CanNavigateTo(pos, target, polyPickExt);
         *
         *  _IsCollideByObstacle = PathFindingManager.Instance.IsCollideWithBlockable(pos, target);
         *
         *  //_FindFirstConnectedPoint = PathFindingManager.Instance.FindFirstConnectedPoint(pos, target, polyPickExt, 1.0f, out _FirstConnectedPoint);
         * }
         * */
#endif
        try
        {
            float dt = Time.deltaTime;

            _TimerList.Tick(true);

            Main.Tick(dt);
            InputManager.Instance.Tick(dt);
            CLogicObjectMan <ObjectBehaviour> .Instance.Tick(dt);

            CLogicObjectMan <EntityEffectComponent> .Instance.Tick(dt);

            LuaScriptMgr.Instance.Tick(dt);
            CGameSession.Instance().Tick(dt);
            UISfxBehaviour.Tick(dt);
            CFxCacheMan.Instance.Tick(dt);
            DynamicEffectManager.Instance.Tick(dt);

            //_SoundMan.Tick(dt);
            VideoManager.Tick(dt);

            CDebugUIMan.Instance.Tick(dt);
        }
        catch (LuaScriptException e)
        {
            HobaDebuger.LogErrorFormat("LuaScriptException: {0}", e.Message);
        }
        catch (Exception e)
        {
            HobaDebuger.LogErrorFormat("{0}\n{1}", e.Message, e.StackTrace);
        }
    }
Esempio n. 6
0
    public static GameObject Play(string fxPath, GameObject target, GameObject hook_point, GameObject clipper = null, float duration = -1, float secondsStayInCache = 20f, int orderOffset = 1
#if IN_GAME
                                  , LuaInterface.LuaFunction luaCall = null
#endif
                                  )
    {
        if (string.IsNullOrEmpty(fxPath) || target == null)
        {
            return(null);
        }

        UISfxBehaviour sfx = _AllCreatedList.Find(item => { return(item.Target == target && item.FxPath == fxPath); });

        if (sfx == null)
        {
            GameObject sfx_obj = new GameObject("FXObj");
            sfx = sfx_obj.AddComponent <UISfxBehaviour>();
            _AllCreatedList.Add(sfx);
        }

        if (sfx == null)
        {
            return(null);
        }

        sfx.SetData(fxPath, target, hook_point, duration, secondsStayInCache, orderOffset);
        sfx.SetClipRect(clipper);
        if (luaCall != null)
        {
#if IN_GAME
            sfx.SetOnLoadCallBack(luaCall);
#endif
        }

        if (sfx._FxObject == null)
        {
            if (!sfx._IsLoading)
            {
                PrefabCacheData sfx_pf;
                if (_PrefabCache.TryGetValue(fxPath, out sfx_pf))
                {
                    sfx.OnPrefabLoaded(sfx_pf.Obj as GameObject);
                }
                else
                {
                    sfx._IsLoading = true;
#if IN_GAME
                    Action <UnityEngine.Object> callback = (asset) =>
                    {
                        if (sfx != null)
                        {
                            sfx.OnPrefabLoaded(asset);
                        }
                    };
                    CAssetBundleManager.AsyncLoadResource(fxPath, callback, false, "sfx");
#elif UNITY_EDITOR && ART_USE
                    GameObject prefab = UnityEditor.AssetDatabase.LoadAssetAtPath(fxPath, typeof(GameObject)) as GameObject;
                    if (!_PrefabCache.ContainsKey(fxPath))
                    {
                        _PrefabCache.Add(fxPath, prefab as GameObject);
                    }
                    //DoPlay(fxPath, sfx_pf, sfx_obj);
                    sfx.OnPrefabLoaded(prefab);
#endif
                }
            }
        }
        else
        {
            sfx.RestartPlay();
        }

        return(sfx.gameObject);
    }