Exemplo n.º 1
0
    /// <summary>
    /// 实例化链接特效
    /// </summary>
    /// <param name="effectName">要实例化的特效名称</param>
    public void InstanceEffect_Link(string effectName, ObjectCreature pCaster, Vector3 pos, List <ObjectCreature> info, float lifetime = 0f)
    {
        EffectLink _effect = GetFreeEffectLink(effectName);

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

            GameObject _obj = Instantiate(_AssetRes, pos, 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.SetCasterObj(pCaster);
            _newEffect.SetEffectName(effectName);
            _newEffect.SetObjList(info);
            if (lifetime > 0f)
            {
                _newEffect.SetLiftTime(lifetime);
            }
            m_EffectLinkList.Add(_newEffect);
        }
    }
Exemplo n.º 2
0
    private void AddEffectLinkBranch(EffectLinkBranch go, GameObject target)
    {
        EffectLinkBranch linkBranch;

        if (mLinks.Count == 0)
        {
            linkBranch             = gameObject.AddComponent <EffectLinkBranch>();
            linkBranch.destoryTime = destoryTime;
            linkBranch.Init(mCurSkillNode, mHitTargetCs.gameObject, attackerTrans, null);
            mAllMonsters.Add(mHitTargetCs.gameObject);
        }
        else
        {
            linkBranch = NGUITools.AddChild(transform.parent.gameObject, go.gameObject).GetComponent <EffectLinkBranch>();
            EffectLink link = linkBranch.GetComponent <EffectLink>();
            Destroy(link);
            linkBranch.destoryTime = destoryTime;
            linkBranch.Init(mCurSkillNode, target, go.mHitTargetCs.transform, null);
            mAllMonsters.Add(target);
        }
        linkBranch.mNextLink    = GetNextLink;
        linkBranch.mLastDestory = DestoryMe;
        mLinks.Add(linkBranch);
    }