public override void OnAwake() { npc = GetComponent <ServerLifeNpc>(); pathFind = npc.pathFinding; param = new WarMsgParam(); tempList = new List <ServerLifeNpc>(); sortList = new SortedList <int, ServerLifeNpc>(); targets = new List <ServerLifeNpc> (); mTrans = npc.transform; animMsg = new IpcNpcAnimMsg(); }
//npc动画 public void NPCAnim(IpcNpcAnimMsg msg) { //ConsoleEx.DebugLog(war.Side.ToString() + " Sub Received : NPCAnim.", ConsoleEx.YELLOW); AsyncTask.QueueOnMainThread( () => { WarMsgParam param = new WarMsgParam(); param.cmdType = (WarMsg_Type)Enum.Parse(typeof(WarMsg_Type), msg.nextAnim); if (!string.IsNullOrEmpty(msg.data)) { param.param = msg.data; } WarClientManager mgr = WarClientManager.Instance; if (mgr != null) { mgr.npcMgr.SendMessageAsync(msg.uniqueId, msg.uniqueId, param); } }); }
public override void Awake() { base.Awake(); warServerMgr = WarServerManager.Instance; npcMgr = warServerMgr.npcMgr; chaPool = warServerMgr.realServer.monitor.CharactorPool; animMsg = new IpcNpcAnimMsg(); hpMsg = new IpcNpcHpMsg(); skMsg = new IpcSkillMsg(); animState = gameObject.AddComponent <ServerNpcAnimState>(); if (animState != null) { broadcast = animState.OnNewStateReceived; animState.cachedNpc = this; } }
/// <summary> /// 所有消息的处理地方 /// </summary> /// <param name="msg">Message.</param> void HandleIpcMsg(IpcMsg msg) { if (msg != null) { switch (msg.op) { case OP.CtorMap: IpcCreateMapMsg ctor = msg as IpcCreateMapMsg; MapInfo amap = new MapInfo() { ID = ctor.MapId, type = (ConfigType)Enum.ToObject(typeof(ConfigType), ctor.MapType), }; CtorEnv(amap); break; case OP.CtorNpc: IpcCreateNpcMsg ctorNpc = msg as IpcCreateNpcMsg; CtorNpc(ctorNpc); break; case OP.CtorHero: IpcCreateHeroMsg crtHero = msg as IpcCreateHeroMsg; CtorHero(crtHero); break; case OP.NpcMove: IpcNpcMoveMsg moveMsg = msg as IpcNpcMoveMsg; NPCMove(moveMsg); break; case OP.NpcHp: IpcNpcHpMsg hpMsg = msg as IpcNpcHpMsg; NPChp(hpMsg); break; case OP.NpcAnim: IpcNpcAnimMsg animMsg = msg as IpcNpcAnimMsg; NPCAnim(animMsg); break; case OP.NpcStatus: IpcNpcStatusMsg statusMsg = msg as IpcNpcStatusMsg; NPCStatus(statusMsg); break; case OP.ServerReady: IpcServerReadyMsg SerInfo = msg as IpcServerReadyMsg; ServerInfo server = new ServerInfo(SerInfo); ServerReady(server); break; case OP.AsyncClient: IpcSyncClientMsg Sync = msg as IpcSyncClientMsg; SyncClient(Sync); break; case OP.EnterWar: IpcEnterWar enter = msg as IpcEnterWar; ServerInfo aserver = new ServerInfo() { ServerName = enter.ServerName, ServerID = enter.ServerID, }; MapInfo map = new MapInfo() { ID = enter.MapId, type = (ConfigType)Enum.ToObject(typeof(ConfigType), enter.MapType), }; EnterWar(aserver, map); break; case OP.ServerQuit: IpcServerQuitMsg quit = msg as IpcServerQuitMsg; ServerQuit(quit.ServerID); break; case OP.DestroyNpc: IpcDestroyNpcMsg des = msg as IpcDestroyNpcMsg; NpcDestroy(des); break; case OP.SkillCD: IpcSkillMsg skMsg = msg as IpcSkillMsg; NpcSkillCD(skMsg); break; } } }
//npc动画 public void NPCAnim(IpcNpcAnimMsg msg) { publisher.send(msg); }
void Awake() { animMsg = new IpcNpcAnimMsg(); }