示例#1
0
        private void LoadObjects()
        {
            m_SceneState = SceneState.Running;
            LogSys.Log(LOG_TYPE.DEBUG, "Scene {0} start Running.", m_SceneResId);
            // TODO: m_GameStartTime should be set when game of this scene
            // is really started
            m_GameTime.Start();
            m_SceneContext.StartTime = m_GameTime.StartTime;
            Room room = GetRoom();

            if (null != room && null != m_MapData)
            {
                MyDictionary <int, object> units = m_MapData.m_UnitMgr.GetData();
                foreach (Data_Unit unit in units.Values)
                {
                    if (null != unit && unit.m_IsEnable)
                    {
                        NpcInfo npc = m_NpcMgr.AddNpc(unit);
                        if (null != npc)
                        {
                            if (room.RoomUsers.Count() > 0)
                            {
                                npc.OwnerId = room.RoomUsers[0].RoleId;
                                LogSystem.Debug("User {0} is responsible for npc {1}", npc.OwnerId, npc.GetId());
                            }
                            else
                            {
                                LogSystem.Warn("No User is responsible for npc");
                            }
                        }
                    }
                }

                MyDictionary <int, object> slogics = m_MapData.m_SceneLogicMgr.GetData();
                foreach (SceneLogicConfig sc in slogics.Values)
                {
                    if (null != sc && sc.m_IsServer)
                    {
                        m_SceneLogicInfoMgr.AddSceneLogicInfo(sc.GetId(), sc);
                    }
                }

                foreach (User us in room.RoomUsers)
                {
                    UserInfo  info = us.Info;
                    Data_Unit unit = m_MapData.ExtractData(DataMap_Type.DT_Unit, info.GetUnitId()) as Data_Unit;
                    if (null != unit)
                    {
                        info.GetMovementStateInfo().SetPosition(unit.m_Pos);
                        info.GetMovementStateInfo().SetFaceDir(unit.m_RotAngle);
                        info.RevivePoint = unit.m_Pos;
                    }
                }
            }
        }
示例#2
0
        internal static void Execute(object msg, User user)
        {
            Msg_CRC_Create enter_msg = msg as Msg_CRC_Create;

            if (enter_msg == null)
            {
                return;
            }
            LogSys.Log(LOG_TYPE.DEBUG, "user {0}({1}) enter.", user.RoleId, user.GetKey());
            user.UserControlState = (int)UserControlState.User;
            user.IsEntered        = true;

            Room room = user.OwnRoom;

            if (null != room)
            {
                Scene scene = room.GetActiveScene();
                if (null != scene)
                {
                    UserInfo userInfo = user.Info;
                    if (null != userInfo)
                    {
                        userInfo.GetXSoulInfo().GetAllXSoulPartData().Clear();
                        foreach (var pair in user.XSouls.GetAllXSoulPartData())
                        {
                            userInfo.GetXSoulInfo().SetXSoulPartData(pair.Key, pair.Value);
                        }
                        foreach (var pair in userInfo.GetXSoulInfo().GetAllXSoulPartData())
                        {
                            XSoulPartInfo part_info = pair.Value;
                            foreach (int impactid in part_info.GetActiveImpacts())
                            {
                                //LogSys.Log(LOG_TYPE.DEBUG, "---add xsoul impact to self: " + impactid);
                                ImpactSystem.Instance.SendImpactToCharacter(userInfo, impactid, userInfo.GetId(),
                                                                            -1, -1, userInfo.GetMovementStateInfo().GetPosition3D(),
                                                                            userInfo.GetMovementStateInfo().GetFaceDir());
                            }
                        }
                        if (scene.SceneState == SceneState.Running)
                        {
                            Data_Unit unit = scene.MapData.ExtractData(DataMap_Type.DT_Unit, userInfo.GetUnitId()) as Data_Unit;
                            if (null != unit)
                            {
                                userInfo.GetMovementStateInfo().SetPosition(unit.m_Pos);
                                userInfo.GetMovementStateInfo().SetFaceDir(unit.m_RotAngle);
                                userInfo.RevivePoint = unit.m_Pos;
                            }
                            scene.SyncForNewUser(user);
                        }
                    }
                }
            }
        }