Exemple #1
0
    static int Stop(IntPtr L)
    {
        LuaScriptMgr.CheckArgsCount(L, 1);
        CFxOne obj = (CFxOne)LuaScriptMgr.GetUnityObjectSelf(L, 1, "CFxOne");

        obj.Stop();
        return(0);
    }
Exemple #2
0
    public void Apply(bool show, GameObject target, float distance, float targetId)
    {
        if (show)
        {
            if (target == null)
            {
                return;
            }

            FollowTarget = target;
            Distance     = distance;
            _TargetId    = targetId;
            var capsuleCollider = target.GetComponentInChildren <CapsuleCollider>();
            if (capsuleCollider != null)
            {
                var height = capsuleCollider.height / 2;
                _Radius   = capsuleCollider.radius;
                _Offset.y = height;
            }
            else
            {
                HobaDebuger.LogWarningFormat("EffectiveModel does not have CapsuleCollider: {0}", target.gameObject.name);
                var height = 1;
                _Offset.y = height;
            }
            if (_FxOneComp != null)
            {
                _FxOneComp.Play(-1);
            }
        }
        else
        {
            if (_FxOneComp != null)
            {
                _FxOneComp.Stop();
            }
            FollowTarget = null;
            Distance     = 0;
        }
    }
Exemple #3
0
    public CFxOne RequestFxOne(string fxName, int priority, out int fxId)
    {
        // 超出上限,先关掉优先级最低的
        #region 存量检查
        if (_ActiveFxs.Count >= _MaxActiveFxCount)
        {
            int maxPriority = -1;
            int realCount   = 0;
            for (int i = 0; i < _ActiveFxs.Count; ++i)
            {
                CFxOne fx = _ActiveFxs[i];

                //-1 常驻 不参与计算
                if (fx.Priority != -1)
                {
                    if (fx.Priority > maxPriority)
                    {
                        maxPriority = fx.Priority;
                    }

                    ++realCount;
                }
            }

            if (realCount > _MaxActiveFxCount)
            {
                if (priority >= maxPriority)
                {
                    fxId = 0;
                    return(null);
                }

                // 关闭一个最低优先级的特效
                for (int i = 0; i < _ActiveFxs.Count; ++i)
                {
                    CFxOne fx1 = _ActiveFxs[i];
                    if (fx1.Priority == maxPriority)
                    {
                        fx1.Stop();
                        _ActiveFxs.Remove(fx1);
                        break;
                    }
                }
            }
        }

        #endregion

        // 检查资源缓存池
        CFxCache fxcache = null;
        #region FxAssetCache_Area
        if (!_FxAssetCaches.TryGetValue(fxName, out fxcache))
        {
            fxcache = new CFxCache();
            fxcache.Init(fxName);
            _FxAssetCaches[fxName] = fxcache;
        }
        #endregion

        CFxOne fxone = GetEmptyFxOne();
        #region GetFxOne_Area
        fxone.IsCached = true;
        fxone.ID       = NewID();
        //fxone.DontUseL3 = dontUseL3;
        var fxoneTrans = fxone.transform;
        fxoneTrans.parent        = _ActiveFxsRootTrans;
        fxoneTrans.localPosition = Vector3.zero;
        fxoneTrans.localScale    = Vector3.one;
        fxoneTrans.rotation      = Quaternion.identity;

#if UNITY_EDITOR
        fxone.Name = fxName;
#endif

        fxone.Priority = priority;
        _ActiveFxs.Add(fxone);
        #endregion

        fxId = fxone.ID;

        if (!fxcache.Touch(fxone))
        {
            RecycleFx(fxone);
            return(null);
        }

        return(fxone);
    }