//设备打开消息
    public void SendDeviceStatus(int status, UInt16 stationIndex, DeviceType deviceType, int deviceId)
    {
        if (m_stationModule == null)
        {
            return;
        }
        List <PlayerActor> u3dPlayerActorList = new List <PlayerActor>();

        m_stationModule.GetU3DPlayerActors(stationIndex, ref u3dPlayerActorList);
        if (u3dPlayerActorList != null && u3dPlayerActorList.Count > 0)
        {
            for (int i = 0; i < u3dPlayerActorList.Count; i++)
            {
                Agent        agent        = u3dPlayerActorList[i].Agent;
                DeviceAction deviceAction = new DeviceAction()
                {
                    m_deviceId     = deviceId,
                    m_deviceType   = (int)deviceType,
                    m_stationIndex = stationIndex,
                    m_deviceStatus = (byte)status,
                };
                byte[] bytes  = deviceAction.Packet2Bytes();
                UInt16 sendId = TDFramework.SingletonMgr.GameGlobalInfo.ServerInfo.Id;
                UInt16 u3dId  = 0;
                UInt16 msgLen = (UInt16)bytes.Length;
                Packet packet = new Packet(sendId, u3dId, TDFramework.SingletonMgr.MessageIDMgr.DeviceActionMessageId, msgLen, bytes);
                agent.SendPacket(packet.Packet2Bytes());
            }
        }
        u3dPlayerActorList = null;
    }
Exemple #2
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());
            }
        }
    }