Esempio n. 1
0
 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;
                     }
                 }
             }
         }
     }
 }
Esempio n. 2
0
        public virtual void OnNewUIStateReceived(WarTarAnimParam param)
        {
            if (param != null)
            {
                if (param.OP == EffectOp.ExchangeNpcAttri || param.OP == EffectOp.Injury)
                {
                    return;
                }

                SelfDescribed sd = param.described;
                if (sd != null && sd.target == cachedNpc.UniqueID && sd.srcEnd != null)
                {
                    EndResult     src    = sd.srcEnd;
                    int           srcId  = sd.src;
                    int           target = sd.target;
                    int           action = src.param2;
                    int           op     = src.param3;
                    NpcEffectInfo info   = new NpcEffectInfo()
                    {
                        ClientID  = DeviceInfo.GUID,
                        from      = srcId,
                        to        = target,
                        hitAction = action,
                        Op        = op,
                    };
                    animMsg.nextAnim = WarMsg_Type.OnEffect.ToString();
                    animMsg.uniqueId = cachedNpc.UniqueID;
                    animMsg.data     = JSON.Instance.ToJSON(info);

                    if (serMgr != null)
                    {
                        serMgr.realServer.proxyCli.NPCAnim(animMsg);
                    }
                }
            }
        }