public virtual void On_Effect(WarMsgParam param) { if (param != null) { string m_str = param.param as string; NpcEffectInfo info = JSON.Instance.ToObject <NpcEffectInfo>(m_str); if (info != null && info.to == cachedNpc.UniqueID) { Effect3DModelConfigData ecd = Core.Data.getIModelConfig <Effect3DModel>().get(info.hitAction); if (ecd != null) { GameObject obj = null; string key = info.from + "_" + ecd.Start; Debug.Log(key, gameObject); if (info.Op == 0) { obj = WarEffectLoader.Load(ecd.Start); if (obj != null) { obj = Instantiate(obj, cachedTran.position, cachedTran.rotation) as GameObject; obj.transform.parent = cachedTran; SkillEffectBase seb = obj.GetComponent <SkillEffectBase>(); ClientNPC srcNpc = cliMgr.npcMgr.GetNpc(info.from); if (seb != null) { seb.EmitEffect(srcNpc, cachedNpc, false); } if (!uiEffectCache.ContainsKey(key)) { uiEffectCache.Add(key, obj); } } else { Debug.Log(string.Format("Fail to load effect obj with name:{0} from:{1} shootAction:{2}", ecd.Start, info.from)); } } else { if (uiEffectCache.TryGetValue(key, out obj)) { uiEffectCache.Remove(key); Destroy(obj); obj = null; } } } } } }
public virtual void OnNpcStatus(WarMsgParam param) { if (param != null) { string m_str = param.param as string; NpcStatusInfo info = JSON.Instance.ToObject <NpcStatusInfo>(m_str); if (info != null) { List <StatusInfoItem> list = info.items; if (list != null) { GameObject obj = null; foreach (StatusInfoItem si in list) { if (!statusCache.TryGetValue(si.status, out obj)) { obj = ClientNpcAnimState.getStatusObj(si.status); if (obj != null) { obj = Instantiate(obj) as GameObject; if (obj != null) { SkillEffectBase seb = obj.GetComponent <SkillEffectBase>(); if (seb != null) { seb.EmitEffect(null, cachedNpc, true); } } statusCache.Add(si.status, obj); } } obj.SetActive(si.isAdd); } } } } }
public EffectedStruct(SkillEffectBase targetEffect, float inputTime) { this.targetEffect = targetEffect; this.inputTime = inputTime; }
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; } }