예제 #1
0
    /** 设置配置 */
    public virtual void initSceneID(int id)
    {
        _config      = SceneConfig.get(id);
        _mapConfig   = SceneMapConfig.get(_config.mapID);
        _placeConfig = ScenePlaceConfig.getSync(id);

        //绑定驱动类型
        if (_config.instanceType == SceneInstanceType.ClientDriveSinglePlayerBattle)
        {
            driveType = SceneDriveType.ClientDriveAll;
        }
        else
        {
            driveType = CommonSetting.sceneDriveType;
        }

        originPos.setByIArr(_mapConfig.origin);
        sizePos.setByIArr(_mapConfig.size);
        endPos.x = originPos.x + sizePos.x;
        endPos.y = originPos.y + sizePos.y;
        endPos.z = originPos.z + sizePos.z;

        method.onSetConfig();

        preInit();
    }
예제 #2
0
    /** 请求进入场景 */
    public void applyEnterScene(int id, int lineID, int posID)
    {
        if (_isSwitching)
        {
            return;
        }

        SceneConfig config = SceneConfig.get(id);

        if (!GameC.player.role.checkRoleConditions(config.enterConditions, true))
        {
            Ctrl.warnLog("场景进入条件未达成");
            return;
        }

        //客户端单人副本
        if (config.instanceType == SceneInstanceType.ClientDriveSinglePlayerBattle)
        {
            preEnterScene(id, -1);
        }
        else
        {
            if (!BaseC.constlist.sceneInstance_canClientApplyEnter(config.instanceType))
            {
                Ctrl.warnLog("申请进入场景时,不可进入的场景");
                return;
            }

            ApplyEnterSceneRequest.create(id, lineID, posID).send();
        }
    }
예제 #3
0
    /** 重新加载配置 */
    public void onReloadConfig()
    {
        int id = _config.id;

        _config      = SceneConfig.get(id);
        _placeConfig = ScenePlaceConfig.get(id);

        Unit[] values;
        Unit   v;

        for (int i = (values = _units.getValues()).Length - 1; i >= 0; --i)
        {
            if ((v = values[i]) != null)
            {
                v.onReloadConfig();
            }
        }
    }
예제 #4
0
    /** 重新加载配置 */
    private void reloadConfig()
    {
        long now = Ctrl.getTimer();

        BaseC.config.loadSyncForEditorAll();

        long now2 = Ctrl.getTimer();

        Ctrl.print("editor加载配置All完成,耗时:", now2 - now);

        int i = 0;

        _sceneList     = new SList <SceneConfig>();
        _sceneListStrs = new string[SceneConfig.getDic().size()];

        SceneConfig.getDic().getSortedKeyList().forEach(k =>
        {
            SceneConfig config = SceneConfig.get(k);
            _sceneList.add(config);
            _sceneListStrs[i++] = config.id + ":" + config.name;
        });

        i                = 0;
        _monsterList     = new SList <MonsterConfig>();
        _monsterListStrs = new string[MonsterConfig.getDic().size()];

        MonsterConfig.getDic().getSortedKeyList().forEach(k =>
        {
            MonsterConfig config = MonsterConfig.get(k);
            _monsterList.add(config);
            _monsterListStrs[i++] = config.id + ":" + config.name;
        });

        i = 0;
        _operationList     = new SList <OperationConfig>();
        _operationListStrs = new string[OperationConfig.getDic().size()];

        OperationConfig.getDic().getSortedKeyList().forEach(k =>
        {
            OperationConfig config = OperationConfig.get(k);
            _operationList.add(config);
            _operationListStrs[i++] = config.id + ":" + config.name;
        });
    }
예제 #5
0
    protected void loadSceneResourceOver()
    {
        //客户端单人副本
        if (SceneConfig.get(_preSceneID).instanceType == SceneInstanceType.ClientDriveSinglePlayerBattle)
        {
            toEnterClientScene();
        }
        else
        {
            if (CommonSetting.useSceneServer)
            {
                Ctrl.print("A3");

                //推送到服务器
                PreEnterSceneReadyForSceneRequest.create().send();
            }
            else
            {
                //推送到服务器
                PreEnterSceneReadyRequest.create().send();
            }
        }
    }
예제 #6
0
    /** 预备进入场景(来自服务器推送) */
    public void preEnterScene(int sceneID, int lineID)
    {
        _preSceneID       = sceneID;
        _preLineID        = lineID;
        _createdNextScene = false;
        _preInfo          = null;
        _isSwitching      = true;
        _isSwitchCross    = false;

        SceneConfig nextConfig = SceneConfig.get(sceneID);

        _switchType = nextConfig.switchType;

        if (_scene != null)
        {
            //是否跳过加载资源
            if (isSkipLoadSource(nextConfig))
            {
                _isSwitchCross = true;
            }
        }

        removeNowScene();
    }
예제 #7
0
    protected void removeNowSceneOver()
    {
        onRemoveNowSceneOver();

        clearNowScene(!_isSwitchCross);

        //有下个场景
        if (_preSceneID > 0)
        {
            //创建场景
            //客户端场景不做池了

            SceneConfig config = SceneConfig.get(_preSceneID);

            _scene = GameC.factory.createScene();
            _scene.setType(config.type);
            _scene.construct();

            //初始化场景ID
            _scene.initSceneID(_preSceneID);

            //设置预进入数据
            if (_preInfo != null)
            {
                _scene.setPreInfo(_preInfo);
            }

            //标记创建了下个场景
            _createdNextScene = true;

            if (_isSwitchCross)
            {
                // loadSceneResourceOver();
            }
            else
            {
                _scene.load.startLoad(loadSceneResourceOver);
            }

            //客户端单人副本
            if (config.instanceType == SceneInstanceType.ClientDriveSinglePlayerBattle)
            {
                //有进出逻辑
                if (_scene.inout != null)
                {
                    ScenePreInfoData preInfo = toCreateScenePreInfoData();
                    _scene.inout.beforePreEnter();
                    _scene.inout.makePreInfo(preInfo);
                    preEnterSceneNext(preInfo);
                }
                //没有进出逻辑
                else
                {
                    preEnterSceneNext(null);
                }
            }
        }
        else
        {
            leaveSceneOver();
        }
    }