예제 #1
0
    //

    public static void GameFirstInit()
    {
        if (!isGameFirstInitDone)
        {
            isGameFirstInitDone = true;

            CustomInputManager.Init();
            AudioController.Init();
            VideoSettingsController.Init();

            GameSaveLoadController.LoadOptions();

            if (!GameSaveLoadController.optionsLoadWasOK)
            {
                GameSaveLoadController.SaveOptions();
            }
        }
    }
    public static void LoadOptions()
    {
        OptionsData data = new OptionsData();

        string filePath = GetOptionsPath();

        Stream stream = null;

        try
        {
            stream = File.Open(filePath, FileMode.Open);

            BinaryFormatter bformatter = new BinaryFormatter();
            bformatter.Binder = new VersionDeserializationBinder();
            data = (OptionsData)bformatter.Deserialize(stream);

            CustomInputManager.sensitivityX = data.controls_SensitivityX;
            CustomInputManager.sensitivityY = data.controls_SensitivityY;
            CustomInputManager.useMouseWheelToChangeWeapon = data.controls_UseMouseWheelToChangeWeapon;
            CustomInputManager.invertMouse = data.controls_InvertMouse;

            CustomInputManager.AssignKeyToKeyInfo(CustomInputManager.keys.Action, data.controls_Action_Primary, true);
            CustomInputManager.AssignKeyToKeyInfo(CustomInputManager.keys.Action, data.controls_Action_Secondary, false);

            CustomInputManager.AssignKeyToKeyInfo(CustomInputManager.keys.Aim, data.controls_Aim_Primary, true);
            CustomInputManager.AssignKeyToKeyInfo(CustomInputManager.keys.Aim, data.controls_Aim_Secondary, false);

            CustomInputManager.AssignKeyToKeyInfo(CustomInputManager.keys.ChangeGun, data.controls_ChangeGun_Primary, true);
            CustomInputManager.AssignKeyToKeyInfo(CustomInputManager.keys.ChangeGun, data.controls_ChangeGun_Secondary, false);

            CustomInputManager.AssignKeyToKeyInfo(CustomInputManager.keys.Crouch, data.controls_Crouch_Primary, true);
            CustomInputManager.AssignKeyToKeyInfo(CustomInputManager.keys.Crouch, data.controls_Crouch_Secondary, false);

            CustomInputManager.AssignKeyToKeyInfo(CustomInputManager.keys.Fire, data.controls_Fire_Primary, true);
            CustomInputManager.AssignKeyToKeyInfo(CustomInputManager.keys.Fire, data.controls_Fire_Secondary, false);

            CustomInputManager.AssignKeyToKeyInfo(CustomInputManager.keys.Grenade_SnipeTimeController, data.controls_Grenade_SnipeTimeController_Primary, true);
            CustomInputManager.AssignKeyToKeyInfo(CustomInputManager.keys.Grenade_SnipeTimeController, data.controls_Grenade_SnipeTimeController_Secondary, false);

            CustomInputManager.AssignKeyToKeyInfo(CustomInputManager.keys.Jump, data.controls_Jump_Primary, true);
            CustomInputManager.AssignKeyToKeyInfo(CustomInputManager.keys.Jump, data.controls_Jump_Secondary, false);

            CustomInputManager.AssignKeyToKeyInfo(CustomInputManager.keys.Melee, data.controls_Melee_Primary, true);
            CustomInputManager.AssignKeyToKeyInfo(CustomInputManager.keys.Melee, data.controls_Melee_Secondary, false);

            CustomInputManager.AssignKeyToKeyInfo(CustomInputManager.keys.Missions, data.controls_Missions_Primary, true);
            CustomInputManager.AssignKeyToKeyInfo(CustomInputManager.keys.Missions, data.controls_Missions_Secondary, false);

            CustomInputManager.AssignKeyToKeyInfo(CustomInputManager.keys.MoveBackward, data.controls_MoveBackward_Primary, true);
            CustomInputManager.AssignKeyToKeyInfo(CustomInputManager.keys.MoveBackward, data.controls_MoveBackward_Secondary, false);

            CustomInputManager.AssignKeyToKeyInfo(CustomInputManager.keys.MoveForward, data.controls_MoveForward_Primary, true);
            CustomInputManager.AssignKeyToKeyInfo(CustomInputManager.keys.MoveForward, data.controls_MoveForward_Secondary, false);

            CustomInputManager.AssignKeyToKeyInfo(CustomInputManager.keys.MoveLeft, data.controls_MoveLeft_Primary, true);
            CustomInputManager.AssignKeyToKeyInfo(CustomInputManager.keys.MoveLeft, data.controls_MoveLeft_Secondary, false);

            CustomInputManager.AssignKeyToKeyInfo(CustomInputManager.keys.MoveRight, data.controls_MoveRight_Primary, true);
            CustomInputManager.AssignKeyToKeyInfo(CustomInputManager.keys.MoveRight, data.controls_MoveRight_Secondary, false);

            CustomInputManager.AssignKeyToKeyInfo(CustomInputManager.keys.Reload, data.controls_Reload_Primary, true);
            CustomInputManager.AssignKeyToKeyInfo(CustomInputManager.keys.Reload, data.controls_Reload_Secondary, false);

            CustomInputManager.AssignKeyToKeyInfo(CustomInputManager.keys.Sprint_SnipeSteady, data.controls_Sprint_SnipeSteady_Primary, true);
            CustomInputManager.AssignKeyToKeyInfo(CustomInputManager.keys.Sprint_SnipeSteady, data.controls_Sprint_SnipeSteady_Secondary, false);

            //

            AudioController.SetVolume_General(data.audio_GeneralVolume);
            AudioController.SetVolume_Music(data.audio_MusicVolume);
            AudioController.SetVolume_SFX(data.audio_SFXVolume);
            AudioController.SetVolume_Voice(data.audio_VoiceVolume);

            //

            VideoSettingsController.SetResolution(data.video_ResolutionIndex, false);
            VideoSettingsController.Unapplied_SetIsVSyncOn(data.video_VSync);
            VideoSettingsController.SetBightness(data.video_Brightness);
            VideoSettingsController.SetLODBias(data.video_LODBias);

            VideoSettingsController.SetVideoSettingType(data.video_Type);
            VideoSettingsController.Unapplied_SetIsShadowOn(data.video_IsShadowOn);
            VideoSettingsController.Unapplied_SetShadowQuality(data.video_ShadowQual);
            //VideoSettingsController.SetShadowDistance(data.video_ShadowDistance);
            VideoSettingsController.Unapplied_SetTextureQuality(data.video_TextureQual);
            VideoSettingsController.SetUseSSAO(data.video_UseSSAO);
            VideoSettingsController.SetUseAnisotropic(data.video_UseAnisotropic);
            VideoSettingsController.SetUseBloom(data.video_UseBloom);

            VideoSettingsController.ApplyRelativeAppliableSettings();

            //

            optionsLoadWasOK = true;
        }
        catch
        {
            optionsLoadWasOK = false;

            //<Test>
            Debug.LogError("Loading options error!!!");
            //</Test>
        }
        finally
        {
            if (stream != null)
            {
                stream.Close();
            }
        }
    }