コード例 #1
0
        public MapDataProvider LoadSceneConfig(int id, string rootPath)
        {
            MapDataProvider  provider = null;
            Data_SceneConfig sceneCfg = m_SceneConfigMgr.GetDataById(id);

            if (null != sceneCfg)
            {
                provider = new MapDataProvider();
                provider.CollectData(DataMap_Type.DT_Unit, rootPath + sceneCfg.m_UnitFile, "UnitInfo");
                provider.CollectData(DataMap_Type.DT_SceneLogic, rootPath + sceneCfg.m_SceneLogicFile, "SceneLogic");
            }
            return(provider);
        }
コード例 #2
0
        private StoryInstanceInfo NewStoryInstance(int storyId, bool logIfNotFound)
        {
            StoryInstanceInfo instInfo = GetUnusedStoryInstanceInfoFromPool(storyId);

            if (null == instInfo)
            {
                int sceneResId       = m_CurScene.SceneResId;
                Data_SceneConfig cfg = SceneConfigProvider.Instance.GetSceneConfigById(sceneResId);
                if (null != cfg)
                {
                    int      ct       = cfg.m_StoryDslFile.Count;
                    string[] filePath = new string[ct];
                    for (int i = 0; i < ct; i++)
                    {
                        filePath[i] = HomePath.GetAbsolutePath(FilePathDefine_Server.C_RootPath + cfg.m_StoryDslFile[i]);
                    }
                    StoryConfigManager.Instance.LoadStoryIfNotExist(storyId, sceneResId, filePath);
                    StoryInstance inst = StoryConfigManager.Instance.NewStoryInstance(storyId, sceneResId);

                    if (inst == null)
                    {
                        if (logIfNotFound)
                        {
                            LogSystem.Error("Can't load story config, story:{0} scene:{1} !", storyId, sceneResId);
                        }
                        return(null);
                    }
                    StoryInstanceInfo res = new StoryInstanceInfo();
                    res.m_StoryId       = storyId;
                    res.m_StoryInstance = inst;
                    res.m_IsUsed        = true;

                    AddStoryInstanceInfoToPool(storyId, res);
                    return(res);
                }
                else
                {
                    if (logIfNotFound)
                    {
                        LogSystem.Error("Can't find story config, story:{0} scene:{1} !", storyId, sceneResId);
                    }
                    return(null);
                }
            }
            else
            {
                instInfo.m_IsUsed = true;
                return(instInfo);
            }
        }
コード例 #3
0
        public bool ChangeNextScene(int sceneId)
        {
            GfxSystem.PublishGfxEvent("ge_load_ui_in_game", "ui", sceneId);

            /*==========================
             * 登录场景Loading的ID为6
             * 游戏结束时跳回该场景
             */
            if (sceneId == 6)
            {
                UserInfo user = GetPlayerSelf();
                if (null != user)
                {
                    EntityManager.Instance.DestroyUserView(user.GetId());
                    DestroyCharacterById(user.GetId());
                }
                if (null != m_CurScene)
                {
                    /*
                     * if (m_CurScene.ResId == sceneId) {
                     * return true;
                     * }
                     */
                    m_CurScene.Release();
                    m_CurScene = null;
                }
                Data_SceneConfig sceneConfig = SceneConfigProvider.Instance.GetSceneConfigById(sceneId);
                GfxSystem.LoadScene(sceneConfig.m_ClientSceneFile, OnLoadFinish);
                return(true);
            }
            //==============================

            //GfxSystem.PublishGfxEvent("ge_load_ui_in_game", "ui", sceneId);

            if (null != m_CurScene)
            {
                /*
                 * if (m_CurScene.ResId == sceneId) {
                 * return true;
                 * }
                 */
                m_CurScene.Release();
                m_CurScene = null;
            }
            m_CurScene = new SceneResource();
            if (null != m_CurScene)
            {
                m_CurScene.Init(sceneId);
                if (null != m_CurScene.SceneConfig)
                {
                    Data_SceneConfig scene_config = SceneConfigProvider.Instance.GetSceneConfigById(m_CurScene.ResId);
                    m_SpatialSystem.Init(FilePathDefine_Client.C_RootPath + scene_config.m_BlockInfoFile, scene_config.m_ReachableSet);
                    m_SpatialSystem.LoadPatch(FilePathDefine_Client.C_RootPath + scene_config.m_BlockInfoFile + ".patch");
                    m_SpatialSystem.LoadObstacle(FilePathDefine_Client.C_RootPath + scene_config.m_ObstacleFile, 1 / scene_config.m_TiledDataScale);

                    LogSystem.Debug("init SpatialSystem:{0}", FilePathDefine_Client.C_RootPath + scene_config.m_BlockInfoFile);
                    LogSystem.Debug("GameSystem.ChangeNextScene:{0}", m_CurScene.ResId);
                    if (sceneId == 6)
                    {
                        UserInfo user = GetPlayerSelf();
                        if (null != user)
                        {
                            EntityManager.Instance.DestroyUserView(user.GetId());
                            DestroyCharacterById(user.GetId());
                        }
                    }
                    return(true);
                }
            }


            return(false);
        }
コード例 #4
0
        private void TickRecover()
        {
            float            hp_coefficient = 1.0f;
            float            mp_coefficient = 1.0f;
            Data_SceneConfig scene_data     = SceneConfigProvider.Instance.GetSceneConfigById(m_SceneResId);

            if (null != scene_data)
            {
                hp_coefficient = scene_data.m_RecoverHpCoefficient;
                mp_coefficient = scene_data.m_RecoverMpCoefficient;
            }
            for (LinkedListNode <UserInfo> linkNode = UserManager.Users.FirstValue; null != linkNode; linkNode = linkNode.Next)
            {
                UserInfo info = linkNode.Value;
                if (!info.IsDead())
                {
                    float hpRecover = info.GetActualProperty().HpRecover *hp_coefficient;
                    float epRecover = info.GetActualProperty().EnergyRecover *mp_coefficient;
                    if (hpRecover > 0.0001)
                    {
                        if (info.Hp + (int)hpRecover >= info.GetActualProperty().HpMax)
                        {
                            info.SetHp(Operate_Type.OT_Absolute, (int)info.GetActualProperty().HpMax);
                        }
                        else
                        {
                            info.SetHp(Operate_Type.OT_Relative, (int)hpRecover);
                        }
                    }
                    if (epRecover > 0.0001)
                    {
                        if (info.Energy + (int)epRecover >= info.GetActualProperty().EnergyMax)
                        {
                            info.SetEnergy(Operate_Type.OT_Absolute, (int)info.GetActualProperty().EnergyMax);
                        }
                        else
                        {
                            info.SetEnergy(Operate_Type.OT_Relative, (int)epRecover);
                        }
                    }
                    if (hpRecover > 0.0001 || epRecover > 0.0001)
                    {
                        Msg_RC_SyncProperty builder = DataSyncUtility.BuildSyncPropertyMessage(info);
                        NotifyAreaUser(info, builder, false);
                    }
                }
            }
            for (LinkedListNode <NpcInfo> linkNode = NpcManager.Npcs.FirstValue; null != linkNode; linkNode = linkNode.Next)
            {
                NpcInfo info = linkNode.Value;
                if (!info.IsDead())
                {
                    float hpRecover = info.GetActualProperty().HpRecover;
                    float npRecover = info.GetActualProperty().EnergyRecover;
                    if (hpRecover > 0.0001)
                    {
                        if (info.Hp + (int)hpRecover >= info.GetActualProperty().HpMax)
                        {
                            info.SetHp(Operate_Type.OT_Absolute, (int)info.GetActualProperty().HpMax);
                        }
                        else
                        {
                            info.SetHp(Operate_Type.OT_Relative, (int)hpRecover);
                        }
                    }
                    if (npRecover > 0.0001)
                    {
                        if (info.Energy + (int)npRecover >= info.GetActualProperty().EnergyMax)
                        {
                            info.SetEnergy(Operate_Type.OT_Absolute, (int)info.GetActualProperty().EnergyMax);
                        }
                        else
                        {
                            info.SetEnergy(Operate_Type.OT_Relative, (int)npRecover);
                        }
                    }
                    if (hpRecover > 0.0001 || npRecover > 0.0001)
                    {
                        Msg_RC_SyncProperty builder = DataSyncUtility.BuildSyncPropertyMessage(info);
                        NotifyAreaUser(info, builder, false);
                    }
                }
            }
        }