Options
All
  • Public
  • Public/Protected
  • All
Menu

The class reponsible for the maps of the engine.

Hierarchy

  • Map

Index

Constructors

Properties

Accessors

Methods

Constructors

  • new Map(game: any, data: any, name: any, key_name: any, physics_names: any, tileset_image_url: any, tileset_json_url: any, physics_jsons_url: any, lazy_load: any, collision_embedded: any, bgm_key: any, bgm_url: any, expected_party_level: any, background_key: any, show_map_name: any): Map
  • Parameters

    • game: any
    • data: any
    • name: any
    • key_name: any
    • physics_names: any
    • tileset_image_url: any
    • tileset_json_url: any
    • physics_jsons_url: any
    • lazy_load: any
    • collision_embedded: any
    • bgm_key: any
    • bgm_url: any
    • expected_party_level: any
    • background_key: any
    • show_map_name: any

    Returns Map

Properties

_active_filters: { color_blend: boolean; colorize: boolean; flame: boolean; gray: boolean; hue: boolean; levels: boolean; mode7: boolean; outline: boolean; pixel_shift: boolean; tint: boolean; watery: boolean }

Type declaration

  • color_blend: boolean
  • colorize: boolean
  • flame: boolean
  • gray: boolean
  • hue: boolean
  • levels: boolean
  • mode7: boolean
  • outline: boolean
  • pixel_shift: boolean
  • tint: boolean
  • watery: boolean
_background_key: string
_big_shapes_tiles: {}

Type declaration

  • [bounding_box_id: number]: {}
    • [collision_index: number]: Set<number>
_bodies_positions: {}

Type declaration

  • [bounding_box_id: number]: {}
_collision_layer: number
_collision_layers_number: number
_collision_sprite: Sprite
_colorize_filter: Colorize
_current_bounding_box_id: number
_encounter_cumulator: number
_events: {}

Type declaration

_generic_sprites: {}

Type declaration

  • [key_name: string]: Phaser.Sprite
_gray_filter: Gray
_interactable_objects: InteractableObjects[]
_interactable_objects_label_map: {}

Type declaration

_internal_map_objs_storage_keys: { interactable_objects: {}; npcs: {} }

Type declaration

_is_world_map: boolean
_key_name: string
_lazy_load: boolean
_map_name_window: Window
_mode7_filter: Mode7
_name: string
_npcs: NPC[]
_npcs_label_map: {}

Type declaration

  • [label: string]: NPC
_paused: boolean
_processed_polygons: {}

Type declaration

  • [bounding_box_id: number]: {}
    • [collision_layer: number]: { location_key?: number; polygon: number[][]; properties: any; sensor_active: boolean; sensor_active_original: boolean; split_polygon: boolean }[]
_retreat_data: { collision_layer: number; direction: directions; x: number; y: number }

Type declaration

  • collision_layer: number
  • direction: directions
  • x: number
  • y: number
_sand_collision_layer: number
_shapes: {}

Type declaration

  • [bounding_box_id: number]: {}
    • [collision_index: number]: {}
      • [location_key: number]: p2.Convex[]
_show_footsteps: boolean
_show_map_name: boolean
_sprite: Tilemap
assets_loaded: boolean
before_camera_fade_game_events: GameEvent[]
before_config_game_events: GameEvent[]
bgm_key: string
bgm_regions: { bgm_keys: string[]; rectangle: Rectangle; sound_objects: Sound[] }[]
bgm_url: string
bounding_boxes: { id: number; rect: Rectangle }[]
collision_embedded: boolean
data: GoldenSun
encounter_zones: { background_key: string; base_rate: number; parties: string[]; rectangle: Rectangle }[]
expected_party_level: number
filter_tween: { colorize: Tween; gray: Tween }

Generic tween object to be used to transition this map filters.

Type declaration

  • colorize: Tween
  • gray: Tween
game: Game
game_events: GameEvent[]
layer_changes: {}

Type declaration

  • [layer_name: string]: { layer_blend?: PIXI.blendModes; layer_offset?: { x: number; y: number }; opacity?: number; visibility?: boolean }
    • Optional layer_blend?: PIXI.blendModes
    • Optional layer_offset?: { x: number; y: number }
      • x: number
      • y: number
    • Optional opacity?: number
    • Optional visibility?: boolean
other_game_events: GameEvent[]
physics_jsons_url: string
physics_names: string
polygons_processed: Set<number>
sprites_sort_paused: boolean

If true, sprites in middlelayer_group won't be sorted.

tileset_image_url: string
tileset_json_url: string
CAMERA_ROTATION_STEP: 0.003 = 0.003
MAX_CAMERA_ROTATION: 0.035 = 0.035

Accessors

  • get active_filters(): { color_blend: boolean; colorize: boolean; flame: boolean; gray: boolean; hue: boolean; levels: boolean; mode7: boolean; outline: boolean; pixel_shift: boolean; tint: boolean; watery: boolean }
  • An object containing which filters are active in this char.

    Returns { color_blend: boolean; colorize: boolean; flame: boolean; gray: boolean; hue: boolean; levels: boolean; mode7: boolean; outline: boolean; pixel_shift: boolean; tint: boolean; watery: boolean }

    • color_blend: boolean
    • colorize: boolean
    • flame: boolean
    • gray: boolean
    • hue: boolean
    • levels: boolean
    • mode7: boolean
    • outline: boolean
    • pixel_shift: boolean
    • tint: boolean
    • watery: boolean
  • get background_key(): string
  • The battle background key of this map.

    Returns string

  • get body(): Body
  • Gets the map collision body for current collision layer.

    Returns Body

  • get collision_layer(): number
  • The current active collision layer.

    Returns number

  • get collision_layers_number(): number
  • The number of collision layers of this map.

    Returns number

  • get collision_sprite(): Sprite
  • The sprite without texture just responsible to enable the map collision body.

    Returns Sprite

  • get colorize_filter(): Colorize
  • The Phaser.Filter object responsible for this map texture color control.

    Returns Colorize

  • get current_bounding_box_id(): number
  • Gets the current bounding box object ID.

    Returns number

  • get encounter_cumulator(): number
  • Gets the enemy party encounter cumulator value.

    Returns number

  • get events(): {}
  • get generic_sprites(): {}
  • An object of generic sprites that can be created by Game Events.

    Returns {}

    • [key_name: string]: Phaser.Sprite
  • get gray_filter(): Gray
  • The Phaser.Filter object responsible for this map saturation control.

    Returns Gray

  • get interactable_objects_label_map(): {}
  • get internal_map_objs_storage_keys(): { interactable_objects: {}; npcs: {} }
  • get is_world_map(): boolean
  • Whether this map is world map or not.

    Returns boolean

  • get key_name(): string
  • get layers(): any[]
  • get lazy_load(): boolean
  • Whether this map will load its assets only when the hero reaches it.

    Returns boolean

  • get mode7_filter(): Mode7
  • The Phaser.Filter object responsible for this map mode7.

    Returns Mode7

  • get name(): string
  • get npcs(): NPC[]
  • get npcs_label_map(): {}
  • The object that holds the NPCs of this map that have a label.

    Returns {}

    • [label: string]: NPC
  • get paused(): boolean
  • Whether the map is paused or not.

    Returns boolean

  • get retreat_data(): { collision_layer: number; direction: directions; x: number; y: number }
  • Gets Retreat psynergy info. Returns the x and y tile posoition to retreat and the destination collision index and direction.

    Returns { collision_layer: number; direction: directions; x: number; y: number }

    • collision_layer: number
    • direction: directions
    • x: number
    • y: number
  • get sand_collision_layer(): number
  • Gets the collision layer index that sand psynergy will use.

    Returns number

  • get show_footsteps(): boolean
  • Whether this map has chars footprint system enabled.

    Returns boolean

  • get show_map_name(): boolean
  • Whether this map will show its name on teleport.

    Returns boolean

  • get sprite(): Tilemap
  • get tile_height(): any
  • get tile_width(): any

Methods

  • add_generic_sprite(key_name: string, misc_sprite_key: string, x: number, y: number, group: Group, options?: { action?: string; alpha?: number; anchor_x?: number; anchor_y?: number; animation?: string; collision_layer?: number; frame?: string; frame_rate?: number; loop?: boolean; play?: boolean; rotation?: number; scale_x?: number; scale_y?: number; send_to_back?: boolean }): Sprite
  • Adds a generic sprite to this map.

    Parameters

    • key_name: string

      the generic sprite key name.

    • misc_sprite_key: string
    • x: number

      the x position in px.

    • y: number

      the y position in px.

    • group: Group

      the Phaser.Group to be in.

    • Optional options: { action?: string; alpha?: number; anchor_x?: number; anchor_y?: number; animation?: string; collision_layer?: number; frame?: string; frame_rate?: number; loop?: boolean; play?: boolean; rotation?: number; scale_x?: number; scale_y?: number; send_to_back?: boolean }

      some options.

      • Optional action?: string

        The animation action key.

      • Optional alpha?: number

        The sprite alpha value.

      • Optional anchor_x?: number

        The sprite ancho x value.

      • Optional anchor_y?: number

        The sprite ancho y value.

      • Optional animation?: string

        The animation key.

      • Optional collision_layer?: number

        The collision layer that the sprite will be. Important when sorting sprites.

      • Optional frame?: string

        The frame key name to be set for this sprite.

      • Optional frame_rate?: number

        The frame rate of the animation.

      • Optional loop?: boolean

        Whether the animation will loop.

      • Optional play?: boolean

        If true, an animation of this sprite will be started.

      • Optional rotation?: number

        The sprite rotation value.

      • Optional scale_x?: number

        The sprite scale x value.

      • Optional scale_y?: number

        The sprite scale y value.

      • Optional send_to_back?: boolean

        If true, the sprite will be sorted under NPC layers.

    Returns Sprite

    returns the generated sprite.

  • bgm_region_check(): void
  • Update function to check whether BGMs should be played if the hero is inside the specified regions.

    Returns void

  • Checks whether a NPC or Interactable object has its body on map.

    Parameters

    Returns boolean

    whether the body is in the map or not.

  • change_camera_bounds(): void
  • Updates camera bounds to fit current portion of the map.

    Returns void

  • config_all_bodies(collision_layer: number): void
  • Configs map, npc and interactable objects collision bodies.

    Parameters

    • collision_layer: number

      the collsion layer index.

    Returns void

  • config_body(collision_layer: number): void
  • Creates and setups the map collision bodies. Collision bodies for maps may come from physics json file or object layers from a Tiled map.

    Parameters

    • collision_layer: number

      the collsion layer index.

    Returns void

  • config_interactable_object(): void
  • Initializes all the interactable objects of this map.

    Returns void

  • config_layers(reorganize?: boolean): void
  • Creates, initializes and organize the map layers sprites.

    Parameters

    • reorganize: boolean = false

      if true, it will only reorganize the layers. It's expected that the layers were already created.

    Returns void

  • config_npc(): void
  • config_single_npc(npc: NPC, map_index: number, custom_pos?: { x?: number; y?: number }): void
  • Initializes a single NPC in this map.

    Parameters

    • npc: NPC

      the npc to be initialized.

    • map_index: number

      the map unique index of this interactable object.

    • Optional custom_pos: { x?: number; y?: number }

      an initial custom position for this npc in px.

      • Optional x?: number
      • Optional y?: number

    Returns void

  • config_world_map(): void
  • Initializes some world map custom features of this map in the case it's a world map.

    Returns void

  • create_interactable_object(property_key: string, raw_property: string, map_index: number): void
  • Creates an interactable object.

    Parameters

    • property_key: string

      the property name.

    • raw_property: string

      the properties of this interactable object still not parsed.

    • map_index: number

      the map unique index of this interactable object.

    Returns void

    returns the created interactable object.

  • create_npc(property_key: string, properties: any, not_parsed?: boolean, map_index: number): NPC
  • Creates a NPC.

    Parameters

    • property_key: string

      the property name.

    • properties: any

      the properties of this NPC, parsed or not.

    • not_parsed: boolean = true

      whether the properties are parsed or not.

    • map_index: number

      the map unique index of this NPC.

    Returns NPC

    returns the created npc.

  • create_tile_event(property_key: string, raw_property: string): void
  • Creates a tile event.

    Parameters

    • property_key: string

      the property name.

    • raw_property: string

      the properties of this event still not parsed.

    Returns void

    returns the created event.

  • Fires this map game events.

    Parameters

    • map_event_type: map_game_event_types = map_game_event_types.REGULAR

      the set type of map events that will be fired.

    Returns void

  • get_current_tile(controllable_char: ControllableChar, layer?: any[]): Tile | Tile[]
  • Get the tiles that a ControllableChar is over.

    Parameters

    • controllable_char: ControllableChar

      the ControllableChar.

    • Optional layer: any[]

      if this is not specified, it's returned all tiles for the char position.

    Returns Tile | Tile[]

    returns a tile object: Phaser.Tile or Phaser.Tile[] if multiple layers.

  • get_current_zones(): Set<{ background_key: string; base_rate: number; parties: string[]; rectangle: Rectangle }>
  • Gets the zones that the hero is in. Zones are only available if hero is moving.

    Returns Set<{ background_key: string; base_rate: number; parties: string[]; rectangle: Rectangle }>

    a Set of zones.

  • get_djinn_on_world_map(djinn_key: string): (() => void)
  • Creates a NPC representing the djinn to be gotten and a game event to get this djinn.

    Parameters

    • djinn_key: string

      the djinn key to be gotten.

    Returns (() => void)

    return the fire event function of the DjinnEvent instance created in this function.

      • (): void
      • Returns void

  • get_layer(name: string): any
  • Get a specific layer.

    Parameters

    • name: string

      the layer name.

    Returns any

    return the layer.

  • get_tile_bodies(tile_x_pos: number, tile_y_pos: number, collision_layer?: number): (InteractableObjects | NPC)[]
  • Checks if a given tile position has IOs or NPCs, if yes return a list of them.

    Parameters

    • tile_x_pos: number

      the x tile position.

    • tile_y_pos: number

      the y tile position.

    • Optional collision_layer: number

      the collision layer of tile. If not passed, gets the current one.

    Returns (InteractableObjects | NPC)[]

    Returns a list of NPCs and IOs based on constraints given.

  • has_event(event_id: number): boolean
  • Checks whether this map has the given tile event placed somewhere.

    Parameters

    • event_id: number

      the id of the tile event.

    Returns boolean

    whether the given tile event is on the map.

  • Initializes game events of this map.

    Parameters

    • events: string

      list of input events before parse.

    • event_type: map_game_event_types = map_game_event_types.REGULAR

      the type of game event that's being intialized.

    • Optional property_key: string

      the property key name in case of "options_list" game event type.

    Returns void

  • initialize_internal_storage_key(internal_map_objs_storage_keys: { interactable_objects: {}; npcs: {} }): void
  • initialize_map_name_window(): void
  • Initializes the window that shows the map name when entering on it.

    Returns void

  • is_tile_blocked(tile_x_pos: number, tile_y_pos: number, collision_layer?: number, also_check_npc_io?: boolean): boolean
  • Checks if a given tile position is blocked by a collision object.

    Parameters

    • tile_x_pos: number

      the x tile position.

    • tile_y_pos: number

      the y tile position.

    • Optional collision_layer: number

      the collision layer of tile. If not passed, gets the current one.

    • also_check_npc_io: boolean = false

      if true, will also check for NPCs and IOs.

    Returns boolean

    Returns whether the given position is blocked or not.

  • load_map_assets(force_load: boolean, on_complete?: (() => void)): void
  • Loads the map assets like tileset and background music.

    Parameters

    • force_load: boolean

      if true, forces the loading process to start.

    • Optional on_complete: (() => void)

      on load complete callback.

        • (): void
        • Returns void

    Returns void

  • manage_filter(filter: Filter, set: boolean, layer?: string): void
  • Sets or unsets a Phaser.Filter in this map.

    Parameters

    • filter: Filter

      the filter you want to set.

    • set: boolean

      whether it's to set or unset the filter.

    • Optional layer: string

      specify a layer if you want that this filter management should be only for the given layer.

    Returns void

  • mount_map(collision_layer: number, encounter_cumulator: number, hero_dest: { x: number; y: number }, retreat_data?: { collision_layer: number; direction: directions; x: number; y: number }): Promise<Map>
  • This is the main function of this class. It mounts the map.

    Parameters

    • collision_layer: number

      the initial collision layer.

    • encounter_cumulator: number

      the initial encounter cumulator. If not passed, it's reset.

    • hero_dest: { x: number; y: number }

      an object that holds the x and y tile positions that the hero will be.

      • x: number
      • y: number
    • Optional retreat_data: { collision_layer: number; direction: directions; x: number; y: number }

      retreat data that can be propagated from previous map if it has the same key name.

      • collision_layer: number
      • direction: directions
      • x: number
      • y: number

    Returns Promise<Map>

    returns the mounted map.

  • parse_over_prop(property_value: any): number
  • Parses the over property of a given layer.

    Parameters

    • property_value: any

      the over property value.

    Returns number

    returns -1 if under the hero or the threshold collision layer to be under.

  • pause(): { previously_inactive_io: Set<number>; previously_inactive_npc: Set<number>; previously_not_visible_layers: Set<number> }
  • Pauses map activity, like collisions, npc and interactable objects animation etc.

    Returns { previously_inactive_io: Set<number>; previously_inactive_npc: Set<number>; previously_not_visible_layers: Set<number> }

    return the current map state.

    • previously_inactive_io: Set<number>
    • previously_inactive_npc: Set<number>
    • previously_not_visible_layers: Set<number>
  • pre_processor_polygons(): void
  • Pre processor the map collision polygons in order to limit their size to a tile size.

    Returns void

  • process_tiled_layers(): void
  • Processes Tiled layers to check whether they have configs related to collision, encounter zones and bounding boxes.

    Returns void

  • remove_body_tile(instance: InteractableObjects | NPC, x_tile?: number, y_tile?: number, collision_layer?: number): void
  • Removes a NPC or an IO collision track from this map.

    Parameters

    • instance: InteractableObjects | NPC

      the NPC or IO instance.

    • Optional x_tile: number

      the x tile position.

    • Optional y_tile: number

      the y tile position.

    • Optional collision_layer: number

      the collision index.

    Returns void

  • remove_event(location_key: number, event_id: number): boolean
  • Removes a tile event in a custom location.

    Parameters

    • location_key: number

      the LocationKey of the event.

    • event_id: number

      the id of the event.

    Returns boolean

    returns true if the event was removed.

  • remove_generic_sprite(key_name: string): boolean
  • Removes a generic sprite from this map.

    Parameters

    • key_name: string

      the generic sprite key name.

    Returns boolean

    return true if the sprite was removed.

  • remove_npc(npc: NPC, unset?: boolean): void
  • Removes a NPC from this map.

    Parameters

    • npc: NPC

      the npc to be removed.

    • unset: boolean = true

      if true, will also unset the npc.

    Returns void

  • resume(previous_state?: { previously_inactive_io: Set<number>; previously_inactive_npc: Set<number>; previously_not_visible_layers: Set<number> }): void
  • Resumes map activity, like collisions, npc and interactable objects animation etc.

    Parameters

    • Optional previous_state: { previously_inactive_io: Set<number>; previously_inactive_npc: Set<number>; previously_not_visible_layers: Set<number> }

      the map state when it was paused.

      • previously_inactive_io: Set<number>
      • previously_inactive_npc: Set<number>
      • previously_not_visible_layers: Set<number>

    Returns void

  • set_collision_in_tile(tile_x_pos: number, tile_y_pos: number, collide: boolean, collision_layer?: number): void
  • Sets whether a tile should collide or not. Only works if there's at least on collision body in the given tile position.

    Parameters

    • tile_x_pos: number

      the x tile position.

    • tile_y_pos: number

      the y tile position.

    • collide: boolean

      whether it should collide or not.

    • Optional collision_layer: number

      the collision layer of tile. If not passed, gets the current one.

    Returns void

  • set_internal_storage_key(is_npc: boolean, property: "anchor" | "position" | "position_px" | "scale" | "base_collision_layer" | "enable" | "active" | "visible" | "entangled_by_bush" | "action" | "animation" | "affected_by_reveal" | "movement_type" | "move_freely_in_event" | "interaction_pattern", storage_key: string, obj_index: number): void
  • Sets a storage key identifier for a NPC or Interactable Object in order to hold values internally if this map is unmounted.

    Parameters

    • is_npc: boolean

      is true, will set the key for a NPC, otherwise for an Interactable Object.

    • property: "anchor" | "position" | "position_px" | "scale" | "base_collision_layer" | "enable" | "active" | "visible" | "entangled_by_bush" | "action" | "animation" | "affected_by_reveal" | "movement_type" | "move_freely_in_event" | "interaction_pattern"

      the storage key type.

    • storage_key: string

      the storage key.

    • obj_index: number

      the NPC or Interactable Object index in this map.

    Returns void

  • set_map_bounds(tile_x_pos: number, tile_y_pos: number, apply_on_camera_view?: boolean): void
  • Checks what is the suitable bounding box for the given position. If no bounding box found, will fit map bounds to world size.

    Parameters

    • tile_x_pos: number

      the x tile position.

    • tile_y_pos: number

      the y tile position.

    • apply_on_camera_view: boolean = true

      if true, will apply the bounds to camera.

    Returns void

  • sort_sprites(): void
  • Sorts the sprites in the GoldenSun.middlelayer_group by y position and base_collision_layer properties. After this first sort, send_to_front [boolean], sort_function [callable], send_to_back [boolean] and sort_function_end [callable] Phaser.DisplayObject properties are checked in this order.

    Returns void

  • start_battle_encounter(zone_base_rate: number): boolean
  • Calculates whether it's time to start a random battle.

    Parameters

    • zone_base_rate: number

      the encounter finding rate of the current battle zone.

    Returns boolean

    returns true if it's time to start a random battle.

  • unset_all_filters(): void
  • unset_map(): void
  • update(): void
  • update_body_tile(old_x: number, old_y: number, new_x: number, new_y: number, old_col_index: number, new_col_index: number, instance: InteractableObjects | NPC): void
  • Updates the new position of an IO or NPC in this map structure.

    Parameters

    • old_x: number

      the old x tile position.

    • old_y: number

      the old y tile position.

    • new_x: number

      the new x tile position.

    • new_y: number

      the new y tile position.

    • old_col_index: number

      the old collision index.

    • new_col_index: number

      the new collision index.

    • instance: InteractableObjects | NPC

      the NPC or IO instance.

    Returns void

  • update_map_rotation(): void
  • If it's a world map, rotates the map on hero movement start.

    Returns void

  • zone_check(): void
  • Checks whether it's time to start a random battle.

    Returns void

Generated using TypeDoc