private void SynRemoveUnits() { while (removes.GetCount() > 0) { Unit unit = removes.take(); int id = unit.Id; if (units.ContainsKey(id)) { units.Remove(id); } //TODO 在unity中移除单元 } }
private void SynAddUnits() { while (adds.GetCount() > 0) { common.game.battle.engine.unit.Unit engineUnit = adds.take(); int unitCid = engineUnit.Cid; string modelprefabDir = "scenes/Boy@skin"; GameObject modelprefab = Resources.Load <GameObject>(modelprefabDir); common.game.battle.engine.Vector3 position = engineUnit.Position; GameObject model = GameObject.Instantiate(modelprefab, new Vector3(position.X, position.Y, position.Z), new Quaternion(0, 0, 0, 1)); Unit unit = new Unit(engineUnit, model); units.Add(engineUnit.Id, unit); if (engineUnit.IsControl) { contrller = unit; } } }
public void run() { while (true) { try { Packet packet = packetList.take(); EthernetPacket packet_eth = (EthernetPacket)packet; EthernetHeader head_eth = packet_eth.getHeader(); IpV4Packet ipV4Packet = null; if (ppp) { ipV4Packet = getIpV4Packet_pppoe(packet_eth); } else { if (packet_eth.getPayload() instanceof IpV4Packet) { ipV4Packet = (IpV4Packet)packet_eth.getPayload(); } } if (ipV4Packet != null) { IpV4Header ipV4Header = ipV4Packet.getHeader(); if (ipV4Packet.getPayload() instanceof TcpPacket) { TcpPacket tcpPacket = (TcpPacket)ipV4Packet.getPayload(); TcpHeader tcpHeader = tcpPacket.getHeader(); if (client) { TCPTun conn = tcpManager.getTcpConnection_Client(ipV4Header.getSrcAddr().getHostAddress(), tcpHeader.getSrcPort().value(), tcpHeader.getDstPort().value()); if (conn != null) { conn.process_client(capEnv, packet, head_eth, ipV4Header, tcpPacket, false); } } else { TCPTun conn = null; conn = tcpManager.getTcpConnection_Server(ipV4Header.getSrcAddr().getHostAddress(), tcpHeader.getSrcPort().value()); if ( tcpHeader.getDstPort().value() == listenPort) { if (tcpHeader.getSyn() && !tcpHeader.getAck() && conn == null) { conn = new TCPTun(capEnv, ipV4Header.getSrcAddr(), tcpHeader.getSrcPort().value()); tcpManager.addConnection_Server(conn); } conn = tcpManager.getTcpConnection_Server(ipV4Header.getSrcAddr().getHostAddress(), tcpHeader.getSrcPort().value()); if (conn != null) { conn.process_server(packet, head_eth, ipV4Header, tcpPacket, true); } } } } else if (packet_eth.getPayload() instanceof IllegalPacket) { MLog.println("IllegalPacket!!!"); } } } catch (InterruptedException e) {