Ejemplo n.º 1
0
    //发送Npc位置信息
    public void SendNpcPosition(float posX, float posY, float posZ,
                                float angleX, float angleY, float angleZ,
                                int npcId, int npcType, UInt16 stationIndex, UInt16 stationClientType)
    {
        if (m_stationModule == null || m_networkModule == null)
        {
            return;
        }
        List <PlayerActor> u3dPlayerActorList = null;

        m_stationModule.GetU3DPlayerActors(stationIndex, ref u3dPlayerActorList);
        if (u3dPlayerActorList == null || u3dPlayerActorList.Count == 0)
        {
            return;
        }
        PlayerActor stationPlayerActor = null;

        for (int k = 0; k < u3dPlayerActorList.Count; k++)
        {
            stationPlayerActor = m_networkModule.GetStationPlayerActorAboutU3DPlayerActor(u3dPlayerActorList[k],
                                                                                          stationIndex, stationClientType);
            if (stationPlayerActor != null)
            {
                Agent       agent  = stationPlayerActor.Agent;
                NpcPosition npcPos = new NpcPosition()
                {
                    m_posX              = posX,
                    m_posY              = posY,
                    m_posZ              = posZ,
                    m_angleX            = angleX,
                    m_angleY            = angleY,
                    m_angleZ            = angleZ,
                    m_npcId             = npcId,
                    m_npcType           = npcType,
                    m_stationIndex      = stationIndex,
                    m_stationClientType = stationClientType,
                };
                byte[] bytes  = npcPos.Packet2Bytes();
                UInt16 sendId = TDFramework.SingletonMgr.GameGlobalInfo.ServerInfo.Id;
                UInt16 u3dId  = 0;
                UInt16 msgLen = (UInt16)bytes.Length;
                Packet packet = new Packet(sendId, u3dId, SingletonMgr.MessageIDMgr.NpcPositionMessageID, msgLen, bytes);
                agent.SendPacket(packet.Packet2Bytes());
            }
        }
    }