SHARE
TWEET

Untitled

a guest Nov 10th, 2019 121 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # ===================================================================
  2. #
  3. #   Script: GameManager
  4. #
  5. #   $$COPYRIGHT$$
  6. #
  7. # ===================================================================
  8. class GameManager
  9.     ###*
  10.     * Manages all general things around the game like holding the game settings,
  11.     * manages the save/load of a game, etc.
  12.     *
  13.     * @module gs
  14.     * @class GameManager
  15.     * @memberof gs
  16.     * @constructor
  17.     ###
  18.     constructor: ->
  19.         ###*
  20.         * The current scene data.
  21.         * @property sceneData
  22.         * @type Object
  23.         ###
  24.         @sceneData = {}
  25.  
  26.         ###*
  27.         * The scene viewport containing all visual objects which are part of the scene and influenced
  28.         * by the in-game camera.
  29.         * @property sceneViewport
  30.         * @type gs.Object_Viewport
  31.         ###
  32.         @sceneViewport = null
  33.  
  34.         ###*
  35.         * The list of common events.
  36.         * @property commonEvents
  37.         * @type gs.Object_CommonEvent[]
  38.         ###
  39.         @commonEvents = []
  40.  
  41.         ###*
  42.         * Indicates if the GameManager is initialized.
  43.         * @property commonEvents
  44.         * @type gs.Object_CommonEvent[]
  45.         ###
  46.         @initialized = no
  47.  
  48.         ###*
  49.         * Temporary game settings.
  50.         * @property tempSettings
  51.         * @type Object
  52.         ###
  53.         @tempSettings = skip: false, skipTime: 5, loadMenuAccess: true, menuAccess: true, backlogAccess: true, saveMenuAccess: true, messageFading: { animation: { type: 1 }, duration: 15, easing: null }
  54.  
  55.         ###*
  56.         * Temporary game fields.
  57.         * @property tempFields
  58.         * @type Object
  59.         ###
  60.         @tempFields = null
  61.  
  62.         ###*
  63.         * Stores default values for backgrounds, pictures, etc.
  64.         * @property defaults
  65.         * @type Object
  66.         ###
  67.         @defaults = {
  68.             background: { "duration": 30, "origin": 0, "zOrder": 0, "loopVertical": 0, "loopHorizontal": 0, "easing": { "type": 0, "inOut": 1 }, "animation": { "type": 1, "movement": 0, "mask": { "graphic": null, "vague": 30 } }, "motionBlur": { "enabled": 0, "delay": 2, "opacity": 100, "dissolveSpeed": 3 } },
  69.             picture: { "appearDuration": 30, "disappearDuration": 30, "origin": 1, "zOrder": 0, "appearEasing": { "type": 0, "inOut": 1 }, "disappearEasing": { "type": 0, "inOut": 1 }, "appearAnimation": { "type": 1, "movement": 0, "mask": { "graphic": null, "vague": 30 } }, "disappearAnimation": { "type": 1, "movement": 0, "mask": { "graphic": null, "vague": 30 } }, "motionBlur": { "enabled": 0, "delay": 2, "opacity": 100, "dissolveSpeed": 3 } },
  70.             character: { "expressionDuration": 0, "appearDuration": 40, "disappearDuration": 40, "origin": 1, "zOrder": 0, "appearEasing": { "type": 2, "inOut": 2 }, "disappearEasing": { "type": 1, "inOut": 1 }, "appearAnimation": { "type": 1, "movement": 0, "mask": { "graphic": null, "vague": 30 } }, "disappearAnimation": { "type": 1, "movement": 0, "mask": { "graphic": null, "vague": 30 } }, "motionBlur": { "enabled": 0, "delay": 2, "opacity": 100, "dissolveSpeed": 3 }, "changeAnimation": { "type": 1, "movement": 0, "fading": 0, "mask": { "graphic": null, "vague": 30 } }, "changeEasing": { "type": 2, "inOut": 2 } },
  71.             text: { "appearDuration": 30, "disappearDuration": 30, "positionOrigin": 0, "origin": 0, "zOrder": 0, "appearEasing": { "type": 0, "inOut": 1 }, "disappearEasing": { "type": 0, "inOut": 1 }, "appearAnimation": { "type": 1, "movement": 0, "mask": { "graphic": null, "vague": 30 } }, "disappearAnimation": { "type": 1, "movement": 0, "mask": { "graphic": null, "vague": 30 } }, "motionBlur": { "enabled": 0, "delay": 2, "opacity": 100, "dissolveSpeed": 3 } },
  72.             video: { "appearDuration": 30, "disappearDuration": 30, "origin": 0, "zOrder": 0, "appearEasing": { "type": 0, "inOut": 1 }, "disappearEasing": { "type": 0, "inOut": 1 }, "appearAnimation": { "type": 1, "movement": 0, "mask": { "graphic": null, "vague": 30 } }, "disappearAnimation": { "type": 1, "movement": 0, "mask": { "graphic": null, "vague": 30 } }, "motionBlur": { "enabled": 0, "delay": 2, "opacity": 100, "dissolveSpeed": 3 } },
  73.             live2d: { "motionFadeInTime": 1000, "appearDuration": 30, "disappearDuration": 30, "zOrder": 0, "appearEasing": { "type": 0, "inOut": 1 }, "disappearEasing": { "type": 0, "inOut": 1 }, "appearAnimation": { "type": 1, "movement": 0, "mask": { "graphic": null, "vague": 30 } }, "disappearAnimation": { "type": 1, "movement": 0, "mask": { "graphic": null, "vague": 30 } } },
  74.             messageBox: { "appearDuration": 30, "disappearDuration": 30, "zOrder": 0, "appearEasing": { "type": 0, "inOut": 1 }, "disappearEasing": { "type": 0, "inOut": 1 }, "appearAnimation": { "type": 0, "movement": 3, "mask": { "graphic": null, "vague": 30 } }, "disappearAnimation": { "type": 0, "movement": 3, "mask": { "graphic": null, "vague": 30 } } },
  75.             audio: { "musicFadeInDuration": 0, "musicFadeOutDuration": 0, "musicVolume": 100, "musicPlaybackRate": 100, "soundVolume": 100, "soundPlaybackRate": 100, "voiceVolume": 100, "voicePlaybackRate": 100 }
  76.         }
  77.  
  78.         ###*
  79.         * The game's backlog.
  80.         * @property backlog
  81.         * @type Object[]
  82.         ###
  83.         @backlog = []
  84.  
  85.         ###*
  86.         * Character parameters by character ID.
  87.         * @property characterParams
  88.         * @type Object[]
  89.         ###
  90.         @characterParams = []
  91.  
  92.         ###*
  93.         * The game's chapter
  94.         * @property chapters
  95.         * @type gs.Document[]
  96.         ###
  97.         @chapters = []
  98.  
  99.         ###*
  100.         * The game's current displayed messages. Especially in NVL mode the messages
  101.         * of the current page are stored here.
  102.         * @property messages
  103.         * @type Object[]
  104.         ###
  105.         @messages = []
  106.  
  107.         ###*
  108.         * Count of save slots. Default is 100.
  109.         * @property saveSlotCount
  110.         * @type number
  111.         ###
  112.         @saveSlotCount = 100
  113.  
  114.         ###*
  115.         * The index of save games. Contains the header-info for each save game slot.
  116.         * @property saveGameSlots
  117.         * @type Object[]
  118.         ###
  119.         @saveGameSlots = []
  120.  
  121.         ###*
  122.         * Stores global data like the state of persistent game variables.
  123.         * @property globalData
  124.         * @type Object
  125.         ###
  126.         @globalData = null
  127.  
  128.         ###*
  129.         * Indicates if the game runs in editor's live-preview.
  130.         * @property inLivePreview
  131.         * @type Object
  132.         ###
  133.         @inLivePreview = no
  134.  
  135.  
  136.     ###*
  137.     * Initializes the GameManager, should be called before the actual game starts.
  138.     *
  139.     * @method initialize
  140.     ###
  141.     initialize: ->
  142.         @initialized = yes
  143.         @inLivePreview = $PARAMS.preview?
  144.         @saveSlotCount = RecordManager.system.saveSlotCount || 100
  145.         @tempFields = new gs.GameTemp()
  146.         window.$tempFields = @tempFields
  147.  
  148.         @createSaveGameIndex()
  149.         @variableStore = new gs.VariableStore()
  150.         DataManager.getDocumentsByType("persistent_variables")
  151.         @variableStore.setupDomains(DataManager.getDocumentsByType("global_variables").select (v) -> v.items.domain||"")
  152.         @variableStore.persistentNumbersByDomain = @globalData.persistentNumbers ? @variableStore.persistentNumbersByDomain
  153.         @variableStore.persistentBooleansByDomain = @globalData.persistentBooleans ? @variableStore.persistentBooleansByDomain
  154.         @variableStore.persistentStringsByDomain = @globalData.persistentStrings ? @variableStore.persistentStringsByDomain
  155.         @variableStore.persistentListsByDomain = @globalData.persistentLists ? @variableStore.persistentListsByDomain
  156.  
  157.         @sceneViewport = new gs.Object_Viewport(new Viewport(0, 0, Graphics.width, Graphics.height, Graphics.viewport))
  158.         for character in RecordManager.charactersArray
  159.             if character?
  160.                 @characterParams[character.index] = {}
  161.                 if character.params?
  162.                     for param in character.params
  163.                         @characterParams[character.index][param.name] = param.value
  164.  
  165.  
  166.         @setupCommonEvents()
  167.  
  168.         for i in [0...RecordManager.characters]
  169.             @settings.voicesPerCharacter[i] = 100
  170.  
  171.         @chapters = DataManager.getDocumentsByType("vn.chapter")
  172.         @chapters.sort (a, b) ->
  173.             if a.items.order > b.items.order
  174.                 return 1
  175.             else if a.items.order < b.items.order
  176.                 return -1
  177.             else
  178.                 return 0
  179.  
  180.     ###*
  181.     * Sets up common events.
  182.     *
  183.     * @method setupCommonEvents
  184.     ###
  185.     setupCommonEvents: ->
  186.         for event in @commonEvents
  187.             event?.dispose()
  188.  
  189.         @commonEvents = []
  190.         for event in RecordManager.commonEvents
  191.             object = new gs.Object_CommonEvent()
  192.             object.record = event
  193.             object.rid = event.index
  194.             @commonEvents[event.index] = object
  195.             @commonEvents.push(object)
  196.  
  197.     ###*
  198.     * Preloads resources for common events with auto-preload option enabled.
  199.     *
  200.     * @method preloadCommonEvents
  201.     ###
  202.     preloadCommonEvents: ->
  203.         for event in RecordManager.commonEvents
  204.             continue if not event
  205.             if event.startCondition == 1 and event.autoPreload
  206.                 gs.ResourceLoader.loadEventCommandsGraphics(event.commands)
  207.  
  208.     ###*
  209.     * Sets up cursor depending on system settings.
  210.     *
  211.     * @method setupCursor
  212.     ###
  213.     setupCursor: ->
  214.         if RecordManager.system.cursor?.name
  215.             bitmap = ResourceManager.getBitmap("Graphics/Pictures/#{RecordManager.system.cursor.name}")
  216.             Graphics.setCursorBitmap(bitmap, RecordManager.system.cursor.hx, RecordManager.system.cursor.hy)
  217.         else
  218.             Graphics.setCursorBitmap(null)
  219.  
  220.     ###*
  221.     * Disposes the GameManager. Should be called before quit the game.
  222.     *
  223.     * @method dispose
  224.     ###
  225.     dispose: ->
  226.  
  227.     ###*
  228.     * Quits the game. The implementation depends on the platform. So for example on mobile
  229.     * devices this method has no effect.
  230.     *
  231.     * @method exit
  232.     ###
  233.     exit: -> Application.exit()
  234.  
  235.     ###*
  236.     * Resets the GameManager by disposing and re-initializing it.
  237.     *
  238.     * @method reset
  239.     ###
  240.     reset: ->
  241.         @initialized = no
  242.         @interpreter = null
  243.         @dispose()
  244.         @initialize()
  245.  
  246.     ###*
  247.     * Starts a new game.
  248.     *
  249.     * @method newGame
  250.     ###
  251.     newGame: ->
  252.         @messages = []
  253.         @variableStore.clearAllGlobalVariables()
  254.         @variableStore.clearAllLocalVariables()
  255.         @tempSettings.skip = no
  256.         @tempFields.clear()
  257.         @tempFields.inGame = yes
  258.         @setupCommonEvents()
  259.         @tempSettings.menuAccess = yes
  260.         @tempSettings.saveMenuAccess = yes
  261.         @tempSettings.loadMenuAccess = yes
  262.         @tempSettings.backlogAccess = yes
  263.  
  264.  
  265.     ###*
  266.     * Exists the game and resets the GameManager which is important before going back to
  267.     * the main menu or title screen.
  268.     *
  269.     * @method exitGame
  270.     ###
  271.     exitGame: ->
  272.         @tempFields.inGame = no
  273.         @tempFields.isExitingGame = yes
  274.  
  275.     ###*
  276.     * Updates the GameManager. Should be called once per frame.
  277.     *
  278.     * @method update
  279.     ###
  280.     update: ->
  281.  
  282.     ###*
  283.     * Creates the index of all save-games. Should be called whenever a new save game
  284.     * is created.
  285.     *
  286.     * @method createSaveGameIndex
  287.     * @protected
  288.     ###
  289.     createSaveGameIndex: ->
  290.         @saveGameSlots = []
  291.         for i in [0...@saveSlotCount]
  292.             if GameStorage.exists("SaveGame_#{i}_Header")
  293.                 header = GameStorage.getObject("SaveGame_#{i}_Header")
  294.                 chapter = DataManager.getDocument(header.chapterUid)
  295.                 scene = DataManager.getDocumentSummary(header.sceneUid)
  296.                 image = header.image
  297.             else
  298.                 header = null
  299.                 chaper = null
  300.                 scene = null
  301.  
  302.             if chapter? and scene? and !@inLivePreview
  303.                 @saveGameSlots.push({
  304.                     date: header.date,
  305.                     chapter: chapter.items.name || "DELETED"
  306.                     scene: scene.items.name || "DELETED",
  307.                     image: image #chapter.items.commands[0].params.saveGameGraphic?.name
  308.                 })
  309.             else
  310.                 @saveGameSlots.push({ "date": "", "chapter": "", "scene": "", "image": null })
  311.  
  312.         return @saveGameSlots
  313.  
  314.     ###*
  315.     * Resets the game's settings to its default values.
  316.     *
  317.     * @method resetSettings
  318.     ###
  319.     resetSettings: ->
  320.         @settings = { version: 342, renderer: 0, filter: 1, confirmation: yes, adjustAspectRatio: no, allowSkip: yes, allowSkipUnreadMessages: yes,  allowVideoSkip: yes, skipVoiceOnAction: yes, allowChoiceSkip: no, voicesByCharacter: [], timeMessageToVoice: true,  "autoMessage": { enabled: false, time: 0, waitForVoice: yes, stopOnAction: no },  "voiceEnabled": true, "bgmEnabled": true, "soundEnabled": true, "voiceVolume": 100, "bgmVolume": 100, "seVolume": 100, "messageSpeed": 4, "fullScreen": no, "aspectRatio": 0 }
  321.         @saveGameSlots = []
  322.         for i in [0...@saveSlotCount]
  323.             GameStorage.remove("SaveGame_#{i}_Header")
  324.             GameStorage.remove("SaveGame_#{i}")
  325.  
  326.             @saveGameSlots.push({ "date": "", "chapter": "", "scene": "", "thumb": "" })
  327.  
  328.         GameStorage.setObject("settings", @settings)
  329.  
  330.  
  331.  
  332.     ###*
  333.     * Saves current game settings.
  334.     *
  335.     * @method saveSettings
  336.     ###
  337.     saveSettings: ->
  338.         GameStorage.setObject("settings", @settings)
  339.  
  340.     ###*
  341.     * Saves current global data.
  342.     *
  343.     * @method saveGlobalData
  344.     ###
  345.     saveGlobalData: ->
  346.         @globalData.persistentNumbers = @variableStore.persistentNumbersByDomain
  347.         @globalData.persistentLists = @variableStore.persistentListsByDomain
  348.         @globalData.persistentBooleans = @variableStore.persistentBooleansByDomain
  349.         @globalData.persistentStrings = @variableStore.persistentStringsByDomain
  350.         GameStorage.setObject("globalData", @globalData)
  351.  
  352.     ###*
  353.     * Resets current global data. All stored data about read messages, persistent variables and
  354.     * CG gallery will be deleted.
  355.     *
  356.     * @method resetGlobalData
  357.     ###
  358.     resetGlobalData: ->
  359.         version = @globalData?.version
  360.         data = @globalData
  361.  
  362.         @globalData = {
  363.             messages: {}, cgGallery: {}, version: 342,
  364.             persistentNumbers: { "0": [], "com.degica.vnm.default": [] },
  365.             persistentStrings: { "0": [], "com.degica.vnm.default": [] },
  366.             persistentBooleans: { "0": [], "com.degica.vnm.default": [] },
  367.             persistentLists: { "0": [], "com.degica.vnm.default": [] }
  368.         }
  369.  
  370.         for cg, i in RecordManager.cgGalleryArray
  371.             if cg?
  372.                 @globalData.cgGallery[cg.index] = { unlocked: no }
  373.  
  374.         GameStorage.setObject("globalData", @globalData)
  375.  
  376.         @migrateGlobalData(data, version+1, @globalData.version)
  377.  
  378.     migrateGlobalData: (data, from, to) ->
  379.         for i in [from..to]
  380.             if this["migrateGlobalData#{i}"]?
  381.                 this["migrateGlobalData#{i}"](data)
  382.  
  383.     migrateGlobalData342: (data) ->
  384.         if data?
  385.             @globalData.persistentNumbers[0] = data.persistentNumbers[0] || []
  386.             @globalData.persistentStrings[0] = data.persistentStrings[0] || []
  387.             @globalData.persistentBooleans[0] = data.persistentBooleans[0] || []
  388.             @globalData.persistentLists[0] = data.persistentLists[0] || []
  389.             @globalData.persistentNumbers["com.degica.vnm.default"] = data.persistentNumbers[0] || []
  390.             @globalData.persistentStrings["com.degica.vnm.default"] = data.persistentStrings[0] || []
  391.             @globalData.persistentBooleans["com.degica.vnm.default"] = data.persistentBooleans[0] || []
  392.             @globalData.persistentLists["com.degica.vnm.default"] = data.persistentLists[0] || []
  393.  
  394.     readSaveGame: (saveGame) ->
  395.     writeSaveGame: (saveGame) ->
  396.  
  397.     prepareSaveGame: (snapshot) ->
  398.         if snapshot
  399.             snapshot = ResourceManager.getCustomBitmap("$snapshot")
  400.             snapshot?.dispose()
  401.             ResourceManager.setCustomBitmap("$snapshot", Graphics.snapshot())
  402.  
  403.         context = new gs.ObjectCodecContext()
  404.         context.decodedObjectStore.push(Graphics.viewport)
  405.         context.decodedObjectStore.push(@scene)
  406.         context.decodedObjectStore.push(@scene.behavior)
  407.  
  408.         messageBoxIds = ["messageBox", "nvlMessageBox", "messageMenu"];
  409.         messageIds = ["gameMessage_message", "nvlGameMessage_message"];
  410.         messageBoxes = messageBoxIds.where((id) =>  @scene.behavior.objectManager.objectById(id) != null).select((id) => @scene.behavior.objectManager.objectById(id))
  411.         messages = messageIds.select (id) => @scene.behavior.objectManager.objectById(id)
  412.  
  413.         sceneData = {}
  414.         saveGame = {}
  415.         saveGame.encodedObjectStore = null
  416.         saveGame.sceneUid = @scene.sceneDocument.uid
  417.         saveGame.data = {
  418.             resourceContext: @scene.behavior.resourceContext.toDataBundle(),
  419.             currentCharacter: @scene.currentCharacter,
  420.             characterParams: @characterParams,
  421.             frameCount: Graphics.frameCount,
  422.             tempFields: @tempFields,
  423.             viewport: @scene.viewport,
  424.             characters: @scene.characters,
  425.             characterNames: RecordManager.charactersArray.select((c) -> { name: c.name, index: c.index }),
  426.             backgrounds: @scene.backgrounds,
  427.             pictures: @scene.pictureContainer.subObjectsByDomain,
  428.             texts: @scene.textContainer.subObjectsByDomain,
  429.             videos: @scene.videoContainer.subObjectsByDomain,
  430.             viewports: @scene.viewportContainer.subObjects,
  431.             commonEvents: @scene.commonEventContainer.subObjects,
  432.             hotspots: @scene.hotspotContainer.subObjectsByDomain,
  433.             interpreter: @scene.interpreter,
  434.             choices: @scene.choices,
  435.             messageBoxes: messageBoxes.filter((mb) -> mb? ).map((mb, i) => { visible: mb.visible, id: mb.id, message: messages[i] }),
  436.             backlog: @backlog,
  437.             variableStore: @variableStore,
  438.             defaults: @defaults,
  439.             transitionData: SceneManager.transitionData,
  440.             audio: { audioBuffers: AudioManager.audioBuffers, audioBuffersByLayer: AudioManager.audioBuffersByLayer, audioLayers: AudioManager.audioLayers, soundReferences: AudioManager.soundReferences },
  441.             messageAreas: @scene.messageAreaContainer.subObjectsByDomain
  442.         }
  443.  
  444.         saveGame.data = gs.ObjectCodec.encode(saveGame.data, context)
  445.         saveGame.encodedObjectStore = context.encodedObjectStore
  446.  
  447.         @saveGame = saveGame
  448.  
  449.     createSaveGameSlot: (header) ->
  450.         slot = {
  451.             "date": new Date().toDateString(),
  452.             "chapter": @scene.chapter.items.name,
  453.             "scene": @scene.sceneDocument.items.name,
  454.             "image": header.image
  455.         }
  456.  
  457.         return slot;
  458.  
  459.     createSaveGameHeader: (thumbWidth, thumbHeight) ->
  460.         thumbImage = @createSaveGameThumbImage(thumbWidth, thumbHeight)
  461.  
  462.         header = {
  463.             "date": new Date().toDateString(),
  464.             "chapterUid": @scene.chapter.uid,
  465.             "sceneUid": @scene.sceneDocument.uid,
  466.             "image": thumbImage?.image.toDataURL()
  467.         }
  468.  
  469.         thumbImage?.dispose()
  470.  
  471.         return header
  472.  
  473.     createSaveGameThumbImage: (width, height) ->
  474.         snapshot = ResourceManager.getBitmap("$snapshot")
  475.         thumbImage = null
  476.  
  477.         if snapshot and snapshot.loaded
  478.             if width and height
  479.                 thumbImage = new Bitmap(width, height)
  480.             else
  481.                 thumbImage = new Bitmap(Graphics.width / 8, Graphics.height / 8)
  482.             thumbImage.stretchBlt(new Rect(0, 0, thumbImage.width, thumbImage.height), snapshot, new Rect(0, 0, snapshot.width, snapshot.height))
  483.  
  484.         return thumbImage
  485.  
  486.     storeSaveGame: (name, saveGame, header) ->
  487.         if header
  488.             GameStorage.setData("#{name}_Header", JSON.stringify(header))
  489.  
  490.         GameStorage.setData(name, JSON.stringify(saveGame))
  491.  
  492.     ###*
  493.     * Saves the current game at the specified slot.
  494.     *
  495.     * @method save
  496.     * @param {number} slot - The slot where the game should be saved at.
  497.     * @param {number} thumbWidth - The width for the snapshot-thumb. You can specify <b>null</b> or 0 to use an auto calculated width.
  498.     * @param {number} thumbHeight - The height for the snapshot-thumb. You can specify <b>null</b> or 0 to use an auto calculated height.
  499.     ###
  500.     save: (slot, thumbWidth, thumbHeight) ->
  501.         if @saveGame
  502.             header = @createSaveGameHeader(thumbWidth, thumbHeight)
  503.             @saveGameSlots[slot] = @createSaveGameSlot(header)
  504.             @storeSaveGame("SaveGame_#{slot}", @saveGame, header)
  505.             @sceneData = {}
  506.  
  507.             return @saveGame
  508.  
  509.     restore: (saveGame) ->
  510.         @backlog = saveGame.data.backlog
  511.         @defaults = saveGame.data.defaults
  512.         @variableStore.restore(saveGame.data.variableStore)
  513.         @sceneData = saveGame.data
  514.         @saveGame = null
  515.         @loadedSaveGame = null
  516.         @tempFields = saveGame.data.tempFields
  517.         @characterParams = saveGame.data.characterParams
  518.         window.$tempFields = @tempFields
  519.         window.$dataFields.backlog = @backlog
  520.  
  521.  
  522.     prepareLoadGame: ->
  523.         AudioManager.stopAllMusic(30)
  524.  
  525.     ###*
  526.     * Loads the game from the specified save game slot. This method triggers
  527.     * a automatic scene change.
  528.     *
  529.     * @method load
  530.     * @param {number} slot - The slot where the game should be loaded from.
  531.     ###
  532.     load: (slot) ->
  533.         return if !@saveGameSlots[slot] or @saveGameSlots[slot].date.trim().length == 0
  534.  
  535.         @prepareLoadGame()
  536.         @loadedSaveGame = @loadSaveGame("SaveGame_#{slot}")
  537.  
  538.  
  539.         gs.Audio.reset()
  540.         gs.GlobalEventManager.clear()
  541.         SceneManager.switchTo(new vn.Object_Scene())
  542.         SceneManager.clear()
  543.  
  544.  
  545.     loadSaveGame: (name) -> JSON.parse(GameStorage.getData(name))
  546.  
  547.  
  548.     ###*
  549.     * Gets the save game data for a specified slot.
  550.     *
  551.     * @method getSaveGame
  552.     * @param {number} slot - The slot to get the save data from.
  553.     * @return {Object} The save game data.
  554.     ###
  555.     getSaveGame: (slot) -> JSON.parse(GameStorage.getData("SaveGame_#{slot}"))
  556.  
  557. window.GameManager = new GameManager()
  558. gs.GameManager = window.GameManager
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top