public void CreateHero(IpcCreateHeroMsg msg) { int len = msg.npclist.Length; for (int i = 0; i < len; i++) { CrtHero hero = msg.npclist[i]; ClientNPC npc = Npcloader.Load(hero.npcID, hero.uniqueId, (CAMP)hero.camp, WarPoint); if (npc == null) { ConsoleEx.DebugWarning("Create npc fail!!!!!!!!! id:: " + hero.npcID); continue; } warMgr.clientTeam.filterNpc(hero, npc); npc.transform.localPosition = new Vector3(hero.pos.x, hero.pos.y, hero.pos.z); npc.transform.localScale = Vector3.one; npc.transform.localEulerAngles = new Vector3(hero.rotation.x, hero.rotation.y, hero.rotation.z); } warMgr.SwitchHero(warMgr.clientTeam.activeNpc); warMgr.CreateHeroFinished(); }
/// <summary> /// 创建Hero /// </summary> public void CtorHero(IpcCreateHeroMsg msg) { ConsoleEx.DebugLog(war.Side.ToString() + " Sub Received : CtorHero.", ConsoleEx.YELLOW); if (CreatHero != null) { AsyncTask.QueueOnMainThread( () => { CreatHero(msg); } ); } }
//创建敌我双方的队伍 public void CreateHero() { List <ServerLifeNpc> FirstSide = null, SecondSide = null; List <CrtHero> heroList = new List <CrtHero>(); WarCamp wc = WarCamp.FirstCamp; CreateOneSideHero(wc, out FirstSide, heroList); Charactors.SetHeroList(wc, FirstSide); wc = WarCamp.SecondCamp; CreateOneSideHero(wc, out SecondSide, heroList); Charactors.SetHeroList(wc, SecondSide); //send create hero msg IpcCreateHeroMsg msg = new IpcCreateHeroMsg(); msg.npclist = heroList.ToArray(); msg.op = OP.CtorHero; WarSMgr.realServer.proxyCli.CtorHero(msg); }
/// <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; } } }
/// <summary> /// 创建英雄 /// </summary> public void CtorHero(IpcCreateHeroMsg msg) { publisher.send(msg); }