Options
All
  • Public
  • Public/Protected
  • All
Menu

Defines and manages the usage of field psynergy. Classes that inherit this one, are expected to at least:

  • call FieldAbilities.set_bootstrap_method on construction;
  • call FieldAbilities.close_field_psynergy_window in an appropriate time.
  • call FieldAbilities.stop_casting and FieldAbilities.return_to_idle_anim possibly on cast finish.
  • implement FieldAbilities.update abstract method, even if empty.

This class already do initial checks, search for target, init casting aura and colorize the map automatically.

Hierarchy

Index

Constructors

  • new FieldAbilities(game: Game, data: GoldenSun, ability_key_name: string, action_key_name: string, need_target: boolean, colorize_map?: boolean, target_max_range?: number | ((target: InteractableObjects | NPC) => number), field_color?: number, field_intensity?: number, works_on_disabled_target?: boolean, target_found_extra_check?: ((target: InteractableObjects | NPC) => boolean), ask_before_cast?: boolean, target_is_npc?: boolean, map_colors_sequence?: boolean, is_custom_psynergy?: boolean): FieldAbilities
  • FieldAbilities Ctor.

    Parameters

    • game: Game

      The Phaser.Game object.

    • data: GoldenSun

      The GoldenSun object.

    • ability_key_name: string

      The ability key_name.

    • action_key_name: string

      The action that the char will assume when casting this ability.

    • need_target: boolean

      Whether this ability need a target or not.

    • Optional colorize_map: boolean

      Whether this ability will tint the map when casting.

    • Optional target_max_range: number | ((target: InteractableObjects | NPC) => number)

      If this ability need a target, the max distance range from the caster to find a target. This can also be a function that receives a target candidate, this function must return a range.

    • Optional field_color: number

      A custom color to tint the map.

    • Optional field_intensity: number

      A custom intensity of a color when tinting the map.

    • Optional works_on_disabled_target: boolean

      Only for IO targets. If true, this field ability also works for disabled targets.

    • Optional target_found_extra_check: ((target: InteractableObjects | NPC) => boolean)

      A function that receives a target. This called before casting. Execute some custom extra checks. If this funuction returns true, the char will cast this abiliy.

    • Optional ask_before_cast: boolean

      If true, it opens an YesNo menu asking if the char really wants to cast this ability.

    • Optional target_is_npc: boolean

      If true, the target is a NPC instead of an IO.

    • Optional map_colors_sequence: boolean

      If true, the map will be tinted sequentially with random colors.

    • Optional is_custom_psynergy: boolean

      Set this to true, if it's a custom psynergy.

    Returns FieldAbilities

Properties

ability_key_name: string
action_key_name: string
ask_before_cast: boolean
ask_before_cast_yes_no_menu: YesNoMenu
bootstrap_method: Function
cast_direction: number

The direction that the controllable char is casting thie psynergy.

cast_finisher: Function
caster: MainChar

The main char that it casting the psynergy.

colorize_map: boolean
controllable_char: ControllableChar

The controllable char that's casting this psynergy.

data: GoldenSun

The GoldenSun object.

extra_cast_check: (() => boolean)

Type declaration

    • (): boolean
    • Returns boolean

field_color: number
field_intensity: number
field_psynergy_window: FieldPsynergyWindow
game: Game

The Phaser.Game object.

is_custom_psynergy: boolean
map_colors_sequence: boolean
need_target: boolean
previous_collision_status: { char: boolean; target?: boolean }

Type declaration

  • char: boolean
  • Optional target?: boolean
reset_map: (() => void)

Type declaration

    • (): void
    • Resets the map to default colors.

      Returns void

stop_casting: ((reset_casting_psy_flag?: boolean, reset_map_tint?: boolean) => Promise<void>)

Type declaration

    • (reset_casting_psy_flag?: boolean, reset_map_tint?: boolean): Promise<void>
    • If called, the casting aura is destroyed.

      Parameters

      • Optional reset_casting_psy_flag: boolean
      • Optional reset_map_tint: boolean

      Returns Promise<void>

target_found_extra_check: ((target: InteractableObjects | NPC) => boolean)

Type declaration

target_is_npc: boolean
target_max_range: number | ((target: InteractableObjects | NPC) => number)
target_object: InteractableObjects | NPC

The target object of this psynergy. Might not be necessary depending on the psynergy.

works_on_disabled_target: boolean
DEFAULT_RANGE: 12 = 12

Methods

  • close_field_psynergy_window(): void
  • finish_psynergy(force?: boolean, stop_char?: boolean, finish_callback?: (() => void)): void
  • Generic funcion that can be overriden. When calling this, the psynergy effect should be finished.

    Parameters

    • force: boolean = false

      for the psynergy to finish.

    • stop_char: boolean = true

      stops the char current animation.

    • Optional finish_callback: (() => void)

      the callback method to be called on psynergy end finish.

        • (): void
        • Returns void

    Returns void

  • init_cast(caster_key_name: string): void
  • no_pp(): void
  • return_to_idle_anim(): Promise<void>
  • search_for_target(): void
  • set_bootstrap_method(method: Function): void
  • Sets the bootstrap method that will be called once psynergy cast is initialized. Each psynergy will have its own bootstrap function.

    Parameters

    • method: Function

      the bootstrap method.

    Returns void

  • set_cast_finisher_method(method: Function): void
  • Pass a method to be called on psynergy cast end when the casting aura starts to be destructed.

    Parameters

    • method: Function

      the method to be called.

    Returns void

  • set_extra_cast_check(method: (() => boolean)): void
  • Adds an extra check for this psynergy to be casted. The given function is tested on this psynergy cast initialization. If the given function call returns false, this psynergy won't be casted.

    Parameters

    • method: (() => boolean)

      the method to be tested.

        • (): boolean
        • Returns boolean

    Returns void

  • set_hero_cast_anim(): void
  • set_target_casted(): void
  • update(): void
  • colorize_map_layers(game: Game, map: Map, options?: { color?: number; intensity?: number; map_colors_sequence?: boolean; after_colorize?: any; after_destroy?: any }): (() => void)
  • Colorizes the map for psynergy casting.

    Parameters

    • game: Game

      the Phaser.Game object.

    • map: Map

      the current map.

    • Optional options: { color?: number; intensity?: number; map_colors_sequence?: boolean; after_colorize?: any; after_destroy?: any }

      some options.

      • Optional color?: number

        the color to colorize the map. In the RGB spectre, values between 0 and 1. Default is random.

      • Optional intensity?: number

        the colorize intensity.

      • Optional map_colors_sequence?: boolean

        if true, it will keep changing colorization color over time.

      • after_colorize?:function
        • after_colorize(): void
      • after_destroy?:function
        • after_destroy(): void

    Returns (() => void)

    returns a function that if called, it will return the map colors to normal.

      • (): void
      • Returns void

  • init_cast_aura(game: Game, data: GoldenSun, char: ControllableChar, after_init?: (() => void), after_destroy?: ((reset_casting_psy_flag: boolean) => void), before_destroy?: ((reset_map_tint: boolean) => void)): ((reset_casting_psy_flag?: boolean, reset_map_tint?: boolean) => Promise<void>)
  • Initializes a casting aura around the caster.

    Parameters

    • game: Game

      the Phase.Game object.

    • data: GoldenSun

      the GoldenSun object.

    • char: ControllableChar

      the caster controllable char.

    • Optional after_init: (() => void)

      after the aura is initialized callback.

        • (): void
        • Returns void

    • Optional after_destroy: ((reset_casting_psy_flag: boolean) => void)

      after the aura is completely destroyed callback.

        • (reset_casting_psy_flag: boolean): void
        • Parameters

          • reset_casting_psy_flag: boolean

          Returns void

    • Optional before_destroy: ((reset_map_tint: boolean) => void)

      on aura destruction init callback.

        • (reset_map_tint: boolean): void
        • Parameters

          • reset_map_tint: boolean

          Returns void

    Returns ((reset_casting_psy_flag?: boolean, reset_map_tint?: boolean) => Promise<void>)

    returns a function that when called, will stop the casting aura.

      • (reset_casting_psy_flag?: boolean, reset_map_tint?: boolean): Promise<void>
      • Parameters

        • Optional reset_casting_psy_flag: boolean
        • Optional reset_map_tint: boolean

        Returns Promise<void>

Generated using TypeDoc