void _Packet(ScMazePlayerState p) { bool isSelfStateChange = false; bool isRefreshState = false; for (int i = 0; i < p.state.Length; i++) { isRefreshState = false; PMazePlayerState playerState = p.state[i]; Dictionary <EnumLabyrinthArea, List <PMazePlayer> > .Enumerator e = areaPlayerDic.GetEnumerator(); while (e.MoveNext()) { List <PMazePlayer> player = e.Current.Value; for (int j = 0; j < player.Count; j++) { if (modulePlayer.roleInfo.roleId == playerState.roleId) { isSelfStateChange = true; labyrinthSelfInfo.mazeState = (byte)playerState.state; } if (player[j].roleId == playerState.roleId) { player[j].mazeState = (byte)playerState.state; Logger.LogDetail("{0} 的状态修改成 {1}", player[j].roleName, GetLabyPlayerAllStateStr(player[j].mazeState)); isRefreshState = true; break; } } //如果修改了玩家的信息了,就停止while循环 if (isRefreshState) { break; } } } //如果自己的状态改变 if (isSelfStateChange) { DispatchModuleEvent(EventRefreshSelf, labyrinthSelfInfo); } DispatchModuleEvent(EventRefreshPlayers, areaPlayerDic); DispatchModuleEvent(EventPlayerStateChange, p); }
private void OnPlayerStateChange(ScMazePlayerState p) { if (p == null) { return; } foreach (var item in p.state) { var lc = m_players.Find(o => o.roleInfo != null && o.roleInfo.roleId == item.roleId); if (lc) { lc.roleInfo.mazeState = (byte)item.state; lc.playerType = moduleLabyrinth.GetLabyrinthCreatureType(item.roleId, (byte)item.state); } } }