예제 #1
0
    /// <summary>
    /// 实例化一个静态effect
    /// </summary>
    /// <param name="effectName">要实例化的特效名称</param>
    /// <param name="parent">实例化特效依附的父类挂点</param>
    /// <param name="lifetime">是否重置指定的生存时间,默认为特效对象上的Light组件获得</param>
    /// <param name="isAttach">是否需要依附,默认不依附任何挂点</param>
    public void InstanceEffect_Static(string effectName, ObjectCreature pCaster, Transform parent, float lifetime = 0f, bool isAttach = false)
    {
        EffectStatic _effect = GetFreeEffectStatic(effectName);

        if (_effect != null && _effect.GetGameObject() != null)
        {
            GameObject obj = _effect.GetGameObject();
            obj.transform.position = parent.position;
            obj.transform.rotation = parent.transform.rotation;
            _effect.SetCasterObj(pCaster);
            if (isAttach)
            {
                obj.transform.parent = parent;
            }
            _effect.ResetTime();
            _effect.SetActivation(true);
        }
        else
        {
            GameObject _AssetRes = AssetLoader.Inst.GetAssetRes(effectName);
            if (_AssetRes == null)
            {
                LogManager.LogError("!!!!Error:InstanceEffect_Static() effectRes is null!The effectName:" + effectName + "GameObject is:" + pCaster.GetGameObject() + "effect location:" + parent.name);
                return;
            }

            EffectStatic _newEffect = new EffectStatic();

            GameObject _obj = Instantiate(_AssetRes, parent.position, parent.transform.rotation) as GameObject;
            if (pCaster is ObjectMonster)
            {
                float _scale = ((ObjectMonster)pCaster).GetMonsterRow().getMonsterEnlarge();
                _obj.transform.localScale = new UnityEngine.Vector3(_scale, _scale, _scale);
            }
            GameUtils.AttachParticleCS(_obj.transform);
            if (isAttach)
            {
                _obj.transform.parent = parent;
            }
            _newEffect.SetGameObject(_obj);
            _newEffect.SetCasterObj(pCaster);
            _newEffect.SetEffectName(effectName);
            //if (lifetime > 0f)
            //{
            //    _newEffect.SetLiftTime(lifetime);
            //}

            m_EffectStaticList.Add(_newEffect);
        }
    }
예제 #2
0
    /// <summary>
    /// 在指定坐标实例化一个存在指定生存时间的静态特效
    /// </summary>
    /// <param name="effectName"></param>
    /// <param name="parent">坐标</param>
    /// <param name="lifetime">生存时间</param>
    /// <param name="_SpellInfo"></param>
    public void InstanceEffect_Static(string effectName, ObjectCreature pCaster, Vector3 parent, float lifetime, SpellInfo _SpellInfo)
    {
        EffectStatic _effect = GetFreeEffectStatic(effectName);

        if (_effect != null && _effect.GetGameObject() != null)
        {
            GameObject obj = _effect.GetGameObject();
            obj.transform.position = parent;
            _effect.SetCasterObj(pCaster);
            _effect.ResetTime();
            _effect.SetActivation(true);
        }
        else
        {
            GameObject _AssetRes = AssetLoader.Inst.GetAssetRes(effectName);
            if (_AssetRes == null)
            {
                return;
            }

            EffectStatic _newEffect = new EffectStatic();

            GameObject _obj = Instantiate(_AssetRes, parent, Quaternion.identity) as GameObject;
            if (pCaster is ObjectMonster)
            {
                float _scale = ((ObjectMonster)pCaster).GetMonsterRow().getMonsterEnlarge();
                _obj.transform.localScale = new UnityEngine.Vector3(_scale, _scale, _scale);
            }
            GameUtils.AttachParticleCS(_obj.transform);
            _newEffect.SetGameObject(_obj);
            _newEffect.SetLiftTime(lifetime);
            _newEffect.SetCasterObj(pCaster);
            _newEffect.SetEffectName(effectName);
            m_EffectStaticList.Add(_newEffect);
        }
        //技能震动
        FightEditorContrler.GetInstantiate().SkillShake(_SpellInfo.GetSpellRow().getVibrationScreen(), EM_SPELL_SHAKE_TYPE.EM_SPELL_SHAKE_TYPE_RELEASE);
    }