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

static private BuildSyncPropertyMessage ( EntityInfo obj ) : Msg_RC_SyncProperty
obj EntityInfo
Результат GameFrameworkMessage.Msg_RC_SyncProperty
        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
        private void TickProperty()
        {
            for (LinkedListNode <EntityInfo> linkNode = EntityManager.Entities.FirstNode; null != linkNode; linkNode = linkNode.Next)
            {
                EntityInfo info = linkNode.Value;
                if (!info.IsDead() && info.PropertyChanged)
                {
                    info.PropertyChanged = false;

                    Msg_RC_SyncProperty builder = DataSyncUtility.BuildSyncPropertyMessage(info);
                    NotifyAllUser(RoomMessageDefine.Msg_RC_SyncProperty, builder);
                }
            }
        }
Пример #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);
                        }
                    }
                }
            }
        }
Пример #6
0
        private void TickEntities()
        {
            m_DeletedEntities.Clear();
            for (LinkedListNode <EntityInfo> linkNode = m_EntityMgr.Entities.FirstNode; null != linkNode; linkNode = linkNode.Next)
            {
                EntityInfo info = linkNode.Value;
                info.RetireAttackerInfos(60000);
                if (info.LevelChanged || info.GetSkillStateInfo().BuffChanged)
                {
                    AttrCalculator.Calc(info);
                    info.LevelChanged = false;
                    info.GetSkillStateInfo().BuffChanged = false;
                }
                if (info.IsBorning)
                {
                    if (info.BornTime <= 0)
                    {
                        SkillInfo skillInfo = info.GetSkillStateInfo().GetSkillInfoById(info.BornSkillId);
                        if (info.BornSkillId > 0 && null != skillInfo)
                        {
                            info.BornTime = TimeUtility.GetLocalMilliseconds();
                        }
                        else
                        {
                            info.IsBorning = false;
                            info.BornTime  = 0;
                            info.SetAIEnable(true);
                            info.RemoveState(CharacterPropertyEnum.x3009_无敌);
                        }
                    }
                    else if (info.BornTime + info.BornTimeout < TimeUtility.GetLocalMilliseconds())
                    {
                        info.IsBorning = false;
                        info.BornTime  = 0;
                        info.SetAIEnable(true);
                        info.RemoveState(CharacterPropertyEnum.x3009_无敌);
                    }
                }
                if (info.IsDead() && !info.NeedDelete)
                {
                    if (info.DeadTime <= 0)
                    {
                        CalcKillIncome(info);
                        //发送npc死亡消息
                        Msg_RC_NpcDead npcDeadBuilder = new Msg_RC_NpcDead();
                        npcDeadBuilder.npc_id = info.GetId();
                        NotifyAllUser(RoomMessageDefine.Msg_RC_NpcDead, npcDeadBuilder);

                        SkillInfo skillInfo = info.GetSkillStateInfo().GetSkillInfoById(info.DeadSkillId);
                        if (info.DeadSkillId > 0 && null != skillInfo)
                        {
                            info.DeadTime = TimeUtility.GetLocalMilliseconds();
                            OnEntityKilled(info);
                        }
                        else
                        {
                            if (null == info.CustomData as User)
                            {
                                info.DeadTime   = 0;
                                info.NeedDelete = true;
                                OnEntityKilled(info);
                            }
                            else
                            {
                                info.DeadTime = TimeUtility.GetLocalMilliseconds();
                            }
                        }
                    }
                    else
                    {
                        if (null == info.CustomData as User && info.DeadTime + info.DeadTimeout < TimeUtility.GetLocalMilliseconds())
                        {
                            info.DeadTime   = 0;
                            info.NeedDelete = true;

                            //重新发送npc死亡消息
                            Msg_RC_NpcDead npcDeadBuilder = new Msg_RC_NpcDead();
                            npcDeadBuilder.npc_id = info.GetId();
                            NotifyAllUser(RoomMessageDefine.Msg_RC_NpcDead, npcDeadBuilder);
                        }
                        else if (null != info.CustomData as User && info.DeadTime + info.ReliveTimeout < TimeUtility.GetLocalMilliseconds())
                        {
                            info.DeadTime = 0;
                            info.Hp       = info.HpMax;
                            info.Energy   = info.EnergyMax;

                            Msg_RC_SyncProperty npcProp = DataSyncUtility.BuildSyncPropertyMessage(info);
                            NotifyAllUser(RoomMessageDefine.Msg_RC_SyncProperty, npcProp);
                        }
                    }
                }
                if (info.NeedDelete)
                {
                    m_DeletedEntities.Add(info);
                }
            }
            if (m_DeletedEntities.Count > 0)
            {
                int enemyCt  = 0;
                int friendCt = 0;
                Msg_RC_DestroyNpc destroyNpcBuilder = new Msg_RC_DestroyNpc();
                for (int i = 0; i < m_DeletedEntities.Count; ++i)
                {
                    EntityInfo ni = m_DeletedEntities[i];
                    if (CharacterRelation.RELATION_ENEMY == EntityInfo.GetRelation((int)CampIdEnum.Blue, ni.GetCampId()))
                    {
                        ++enemyCt;
                    }
                    else if (CharacterRelation.RELATION_FRIEND == EntityInfo.GetRelation((int)CampIdEnum.Blue, ni.GetCampId()))
                    {
                        ++friendCt;
                    }
                    //发送npc消失消息
                    destroyNpcBuilder.npc_id = ni.GetId();
                    NotifyAllUser(RoomMessageDefine.Msg_RC_DestroyNpc, destroyNpcBuilder);
                    DestroyEntity(ni);
                }
                TryAllKilledOrAllDied(enemyCt > 0, friendCt > 0);
            }
            m_EntityMgr.ExecuteDelayAdd();
        }