Exemple #1
0
        public virtual void CreateEffect(NpcAnimEffect effect)
        {
            GameObject obj = null;
            string     src = "";

            switch (effect)
            {
            case NpcAnimEffect.Attack_1_Start:
            case NpcAnimEffect.Attack_2_Start:
            case NpcAnimEffect.Attack_3_Start:
                src = curMsg.ecd.Start;
                if (!string.IsNullOrEmpty(src) && !(src == "[]"))
                {
                    obj = WarEffectLoader.Load(src);
                    obj = Instantiate(obj, cachedTran.position, cachedTran.rotation) as GameObject;
                    Destroy(obj, 2f);
                }
                break;

            case NpcAnimEffect.Attack_1:
            case NpcAnimEffect.Attack_2:
            case NpcAnimEffect.Attack_3:
                src = curMsg.ecd.Middle;
                if (!string.IsNullOrEmpty(src) && !(src == "[]"))
                {
                    obj = WarEffectLoader.Load(src);
                    obj = Instantiate(obj, attackPoint.position, cachedTran.rotation) as GameObject;
                    ClientFB fb = obj.GetComponent <ClientFB>();
                    if (fb != null)
                    {
                        fb.Init(curMsg);
                    }
                    else
                    {
                        Destroy(obj, 2f);
                    }
                }
                break;

            case NpcAnimEffect.Skill_1:
                break;

            case NpcAnimEffect.Skill_1_Start:
                src = curMsg.ecd.Start;
                if (!string.IsNullOrEmpty(src) && src != "[]")
                {
                    obj = WarEffectLoader.Load(src);
                    obj = Instantiate(obj, cachedTran.position, cachedTran.rotation) as GameObject;
                    Destroy(obj, 5f);
                }
                break;

            case NpcAnimEffect.Skill_2:
                break;

            case NpcAnimEffect.Skill_2_Start:
                src = curMsg.ecd.Start;
                if (!string.IsNullOrEmpty(src) && src != "[]")
                {
                    obj = WarEffectLoader.Load(src);
                    obj = Instantiate(obj, cachedTran.position, cachedTran.rotation) as GameObject;
                    Destroy(obj, 5f);
                }
                break;

            case NpcAnimEffect.Skill_3:
                break;

            case NpcAnimEffect.Skill_3_Start:
                src = curMsg.ecd.Start;
                if (!string.IsNullOrEmpty(src) && src != "[]")
                {
                    obj = WarEffectLoader.Load(src);
                    obj = Instantiate(obj, cachedTran.position, cachedTran.rotation) as GameObject;
                    Destroy(obj, 5f);
                }
                break;

            case NpcAnimEffect.Skill_4:
                break;

            case NpcAnimEffect.Skill_4_Start:
                break;
            }
        }
        public override void CreateEffect(NpcAnimEffect effect)
        {
            GameObject obj = null;
            string     src = "";

            switch (effect)
            {
            case NpcAnimEffect.Skill_1:
                src = curMsg.ecd.Middle;
                if (!string.IsNullOrEmpty(src) && src != "[]")
                {
                    obj = WarEffectLoader.Load(src);
                    if (obj != null)
                    {
                        obj = Instantiate(obj, attackPoint.position, cachedTran.rotation) as GameObject;
                        SkillEffectBase seb = obj.GetComponent <SkillEffectBase>();
                        if (seb != null)
                        {
                            seb.LifeTime(1f);
                            seb.EmitEffect(null, null, false);
                        }
                        else
                        {
                            Destroy(seb, 1f);
                        }
                    }
                }
                break;

            case NpcAnimEffect.Skill_2:
                src = curMsg.ecd.Middle;
                if (!string.IsNullOrEmpty(src) && src != "[]")
                {
                    obj = WarEffectLoader.Load(src);
                    if (obj != null)
                    {
                        Vector3   pos = Vector3.zero;
                        ClientNPC npc = cliMgr.npcMgr.GetNpc(curMsg.targetId);
                        if (npc != null)
                        {
                            pos = npc.CachedTran.position;
                        }
                        else
                        {
                            pos = cachedTran.position + cachedTran.rotation * Vector3.forward * 5f;
                        }
                        obj = Instantiate(obj, pos, cachedTran.rotation) as GameObject;
                        Destroy(obj, 3f);
                    }
                }
                break;

            case NpcAnimEffect.Skill_3:
                src = curMsg.ecd.Middle;
                if (!string.IsNullOrEmpty(src) && src != "[]")
                {
                    obj = WarEffectLoader.Load(src);
                    if (obj != null)
                    {
                        obj = Instantiate(obj, cachedTran.position, cachedTran.rotation) as GameObject;
                        if (obj != null)
                        {
                            ClientNPC       npc = cliMgr.npcMgr.GetNpc(curMsg.targetId);
                            SkillEffectBase seb = obj.GetComponent <SkillEffectBase>();
                            if (npc != null && seb != null)
                            {
                                Vector3 dir = npc.transform.position;
                                dir.y = cachedTran.position.y;
                                dir   = dir - cachedTran.position;
                                Quaternion rot = Quaternion.LookRotation(dir, Vector3.up);
                                obj.transform.rotation = rot;
                                seb.EmitEffect(cachedNpc, npc, false);
                            }
                            Destroy(obj, 0.2f);
                        }
                    }
                }
                break;

            default:
                base.CreateEffect(effect);
                break;
            }
        }