BuildCreateNpcMessage() статический приватный Метод

static private BuildCreateNpcMessage ( EntityInfo npc, int rate = -1 ) : Msg_RC_CreateNpc
npc EntityInfo
rate int
Результат GameFrameworkMessage.Msg_RC_CreateNpc
        public void ReloadObjects()
        {
            if (m_PreparedReloadMonsterCount > 0)
            {
                for (int i = 0; i < m_PreparedReloadMonsterCount; ++i)
                {
                    TableConfig.LevelMonster monster = m_PreparedReloadMonsters[i];
                    if (null != monster)
                    {
                        int        campId = monster.camp;
                        int        unitId = campId * 10000 + i;
                        int        objId  = CreateEntity(unitId, monster.x, 0.0f, monster.y, monster.dir, campId, monster.actorID, monster.aiLogic, monster.aiParams.ToArray());
                        EntityInfo npc    = GetEntityById(objId);
                        if (null != npc)
                        {
                            npc.IsPassive        = monster.passive;
                            npc.LevelMonsterData = monster;
                            npc.Level            = monster.level;

                            Msg_RC_CreateNpc msg = DataSyncUtility.BuildCreateNpcMessage(npc);
                            NotifyAllUser(RoomMessageDefine.Msg_RC_CreateNpc, msg);

                            Msg_RC_SyncProperty msg2 = DataSyncUtility.BuildSyncPropertyMessage(npc);
                            NotifyAllUser(RoomMessageDefine.Msg_RC_SyncProperty, msg2);
                        }
                    }
                }
                m_PreparedReloadMonsterCount = 0;
            }
            while (m_ReloadMonstersQueue.Count > 0 && m_PreparedReloadMonsterCount < c_MaxReloadMonsterNum)
            {
                m_PreparedReloadMonsters[m_PreparedReloadMonsterCount++] = m_ReloadMonstersQueue.Dequeue();
            }
        }
Пример #2
0
 private void SyncUserObjectToOtherUsers(User user)
 {
     if (null != user)
     {
         EntityInfo          userInfo    = user.Info;
         Msg_RC_CreateNpc    bder        = DataSyncUtility.BuildCreateNpcMessage(userInfo);
         Msg_RC_SyncProperty msg         = DataSyncUtility.BuildSyncPropertyMessage(userInfo);
         RoomUserManager     roomUserMgr = GetRoomUserManager();
         if (null != userInfo && null != roomUserMgr && null != roomUserMgr.ActiveScene)
         {
             for (LinkedListNode <EntityInfo> linkNode = EntityManager.Entities.FirstNode; null != linkNode; linkNode = linkNode.Next)
             {
                 EntityInfo npc = linkNode.Value;
                 if (null != npc && npc != userInfo)
                 {
                     User other = npc.CustomData as User;
                     if (null != other)
                     {
                         other.SendMessage(RoomMessageDefine.Msg_RC_CreateNpc, bder);
                         other.SendMessage(RoomMessageDefine.Msg_RC_SyncProperty, msg);
                     }
                 }
             }
         }
     }
 }
Пример #3
0
 public void SyncForNewObserver(Observer observer)
 {
     if (null != observer)
     {
         RoomUserManager roomUserMgr = GetRoomUserManager();
         if (null != roomUserMgr && null != roomUserMgr.ActiveScene)
         {
             //同步场景数据给观察者
             for (LinkedListNode <EntityInfo> linkNode = EntityManager.Entities.FirstValue; null != linkNode; linkNode = linkNode.Next)
             {
                 EntityInfo npc = linkNode.Value;
                 if (null != npc)
                 {
                     Msg_RC_CreateNpc bder = DataSyncUtility.BuildCreateNpcMessage(npc);
                     observer.SendMessage(RoomMessageDefine.Msg_RC_CreateNpc, bder);
                 }
             }
         }
     }
 }
Пример #4
0
        internal void ReloadObjects()
        {
            if (m_PreparedReloadMonsterCount > 0)
            {
                for (int i = 0; i < m_PreparedReloadMonsterCount; ++i)
                {
                    TableConfig.LevelMonster monster = m_PreparedReloadMonsters[i];
                    if (null != monster)
                    {
                        int campId = monster.camp;
                        TableConfig.Actor actor = TableConfig.ActorProvider.Instance.GetActor(monster.actorID);
                        if (null != actor)
                        {
                            int        unitId = campId * 10000 + i;
                            EntityInfo npc    = EntityManager.AddEntity(unitId, campId, actor, (int)AiStateLogicId.Entity_General);
                            if (null != npc)
                            {
                                npc.IsPassive        = monster.passive;
                                npc.LevelMonsterData = monster;
                                npc.SetLevel(monster.level);
                                npc.GetMovementStateInfo().SetPosition2D(monster.x, monster.y);
                                npc.GetMovementStateInfo().SetFaceDir(monster.dir);

                                Msg_RC_CreateNpc msg = DataSyncUtility.BuildCreateNpcMessage(npc);
                                NotifyAllUser(RoomMessageDefine.Msg_RC_CreateNpc, msg);

                                Msg_RC_SyncProperty msg2 = DataSyncUtility.BuildSyncPropertyMessage(npc);
                                NotifyAllUser(RoomMessageDefine.Msg_RC_SyncProperty, msg2);
                            }
                        }
                    }
                }
                m_PreparedReloadMonsterCount = 0;
            }
            while (m_ReloadMonstersQueue.Count > 0 && m_PreparedReloadMonsterCount < c_MaxReloadMonsterNum)
            {
                m_PreparedReloadMonsters[m_PreparedReloadMonsterCount++] = m_ReloadMonstersQueue.Dequeue();
            }
        }
Пример #5
0
        private void SyncSceneObjectsToUser(User user)
        {
            if (null != user)
            {
                EntityInfo      userInfo    = user.Info;
                RoomUserManager roomUserMgr = GetRoomUserManager();
                if (null != userInfo && null != roomUserMgr && null != roomUserMgr.ActiveScene)
                {
                    for (LinkedListNode <EntityInfo> linkNode = EntityManager.Entities.FirstNode; null != linkNode; linkNode = linkNode.Next)
                    {
                        EntityInfo npc = linkNode.Value;
                        if (null != npc)
                        {
                            Msg_RC_CreateNpc bder = DataSyncUtility.BuildCreateNpcMessage(npc);
                            user.SendMessage(RoomMessageDefine.Msg_RC_CreateNpc, bder);

                            Msg_RC_SyncProperty msg = DataSyncUtility.BuildSyncPropertyMessage(npc);
                            user.SendMessage(RoomMessageDefine.Msg_RC_SyncProperty, msg);
                        }
                    }
                }
            }
        }