Пример #1
0
        public BindEffectInfo InitBindEffectInfo(string effect, DBBuffSev.BindPos bind_pos, bool follow_target, float scale, bool auto_scale, int maxCount)
        {
            float          scale_auto       = auto_scale ? mOwner.Radius / GlobalConst.StandardRadius : 1.0f;
            BindEffectInfo bind_effect_info = new BindEffectInfo(effect, bind_pos, follow_target, scale * scale_auto, maxCount);

            bind_effect_info.mInitFunc = x => BindEffect(x, bind_effect_info);

            return(bind_effect_info);
        }
Пример #2
0
        /// <summary>
        /// 重新绑定特效(角色上下马使用)
        /// </summary>
        public void ResetAllEffectObj()
        {
            List <uint> reset_effect_buffIdArray = new List <uint>();

            foreach (var item in mEffectObjs)
            {
                if (item.Value.IsDestroy == false && item.Value.mEffectObject != null)
                {
                    reset_effect_buffIdArray.Add(item.Key);
                }
            }

            for (int index = 0; index < reset_effect_buffIdArray.Count; ++index)
            {
                uint buff_id = reset_effect_buffIdArray[index];

                BindEffectInfo info = mEffectObjs[buff_id];
                DestroyEffectObj(buff_id);
                BindEffectInfo new_effect = mOwner.InitBindEffectInfo(info.mEffectResPath, info.BindPos, info.FollowTarget, info.mScale, false, info.MaxCount);

                new_effect.CreateInstance();
                mEffectObjs.Add(buff_id, new_effect);
            }
        }
Пример #3
0
        /// <summary>
        /// 增加buff的特效
        /// </summary>
        public void AddEffectObj(DBBuffSev.DBBuffInfo buff_info)
        {
            if (buff_info == null)
            {
                return;
            }

            if (mEffectObjs.ContainsKey(buff_info.buff_id))
            {
                return;
            }

            if (buff_info.effect_file == string.Empty)
            {
                return;
            }

            int effect_max_count = GameConstHelper.GetInt("GAME_BUFF_EFFECT_MAX_COUNT");

            if (effect_max_count == 0)
            {
                effect_max_count = 5;
            }

            bool can_show = true;

            if (buff_info.other_hide) // 其他玩家需要隐藏的特效
            {
                can_show = !ShieldManager.Instance.IsHideBuffEffect(mOwner);
            }

            if (can_show && buff_info.force_show == false)// 需要通过顶替规则进行显示的特效
            {
                // 统计当前可能被顶替的特效数量
                int  current_count     = 0;
                uint low_priority_buff = 0;
                uint low_priority      = uint.MaxValue;
                bool del_low_priority  = false;
                foreach (uint id in mEffectObjs.Keys)
                {
                    DBBuffSev.DBBuffInfo t_buff_info = DBBuffSev.GetInstance().GetBuffInfo(id);
                    if (t_buff_info.force_show == false)
                    {
                        if (buff_info.priority > t_buff_info.priority) //可顶替
                        {
                            if (low_priority > t_buff_info.priority)   // 寻找最低优先级的特效
                            {
                                low_priority      = t_buff_info.priority;
                                low_priority_buff = id;
                            }
                        }

                        current_count++;
                    }

                    if (current_count >= effect_max_count)
                    {
                        del_low_priority = true;
                    }
                }

                if (del_low_priority)
                {
                    if (low_priority_buff != 0)
                    {
                        DestroyEffectObj(low_priority_buff);
                    }
                    else
                    {
                        can_show = false;
                    }
                }
            }

            if (can_show)
            {
                BindEffectInfo new_effect = mOwner.InitBindEffectInfo(buff_info.effect_file, buff_info.bind_pos, buff_info.follow_target, buff_info.scale, buff_info.auto_scale, buff_info.max_count);

                new_effect.CreateInstance();
                mEffectObjs.Add(buff_info.buff_id, new_effect);
            }
        }
Пример #4
0
        // ------------------------------------------------
        // 组件的类型定义
        // ------------------------------------------------


        // ------------------------------------------------
        // 组件的变量定义
        // ------------------------------------------------

        // ------------------------------------------------
        // 组件的内部方法
        // ------------------------------------------------
        void BindEffect(GameObject effect_object, BindEffectInfo bind_effect)
        {
            if (effect_object == null)
            {
                return;
            }

            if (mOwner != null && mOwner.ActorTrans != null && bind_effect != null && !bind_effect.IsDestroy && !mOwner.IsDestroy)
            {
                // 特效的加载是异步的,有可能设置角色Visible属性的时候,特效的可见性没有进行设置
                if (mOwner.mVisibleCtrl != null && mOwner.mVisibleCtrl.VisibleMode != EVisibleMode.Visible)
                {
                    Renderer[] rds = effect_object.GetComponentsInChildren <Renderer>(true);
                    foreach (Renderer rd in rds)
                    {
                        rd.enabled = false;
                    }
                }

                Transform effect_trans = effect_object.transform;
                Transform root_trans   = mOwner.ActorTrans.Find(AvatarCtrl.ROOT_NODE); //特效需要挂接到玩家模型身上
                if (root_trans == null)
                {
                    root_trans = mOwner.ActorTrans;
                }

                // 根据目标的buff,如果找不到挂点,则将特效销毁
                if (root_trans == null && bind_effect.FollowTarget)
                {
                    GameObject.Destroy(effect_object);
                    return;
                }

                effect_trans.parent = root_trans;

                Vector3 offset   = Vector3.zero;
                var     bind_pos = bind_effect.BindPos;
                if (bind_pos == DBBuffSev.BindPos.BP_Body)
                {
                    offset.y = mOwner.CharacterHeight * 0.75f;
                }
                else if (bind_pos == DBBuffSev.BindPos.BP_Head)
                {
                    offset.y = mOwner.CharacterHeight;
                }

                effect_trans.localRotation = Quaternion.identity;
                effect_trans.localPosition = offset;

                // 如果不根据目标,则设置父节点为空
                if (!bind_effect.FollowTarget)
                {
                    effect_trans.parent = null;
                }

                bind_effect.mEffectObject = effect_object;

                ParticleControl particle_control = effect_object.GetComponent <ParticleControl>();
                if (particle_control == null)
                {
                    particle_control = effect_object.AddComponent <ParticleControl>();
                }
                particle_control.Scale = bind_effect.mScale;

                // 设置层级
                xc.ui.ugui.UIHelper.SetLayer(effect_object.transform, mOwner.GetModelLayer());
            }
            else
            {
                GameObject.Destroy(effect_object);
            }
        }