Class: GamePlay::Shop
- Inherits:
-
BaseCleanUpdate::FrameBalanced
- Object
- Base
- BaseCleanUpdate
- BaseCleanUpdate::FrameBalanced
- GamePlay::Shop
- Includes:
- UI::Shop
- Defined in:
- scripts/01450 Systems/00203 Shop/00003 GamePlay/00100 Shop.rb,
scripts/01450 Systems/00203 Shop/00003 GamePlay/00140 Shop_Mouse.rb,
scripts/01450 Systems/00203 Shop/00003 GamePlay/00102 Shop_Inputs.rb,
scripts/01450 Systems/00203 Shop/00003 GamePlay/00130 Shop_Actions.rb,
scripts/01450 Systems/00203 Shop/00003 GamePlay/00101 Shop_Graphics.rb,
scripts/01450 Systems/00203 Shop/00003 GamePlay/00110 Shop_Animations.rb
Direct Known Subclasses
Constant Summary collapse
- MOUSE_OVER_ENABLED =
Tell if the mouse over is enabled
false
Constants inherited from BaseCleanUpdate
BaseCleanUpdate::AIU_KEY2METHOD
Constants inherited from Base
Base::DEFAULT_TRANSITION, Base::DEFAULT_TRANSITION_PARAMETER
Constants included from Input
Input::ALIAS_KEYS, Input::AXIS_MAPPING, Input::AXIS_SENSITIVITY, Input::DEAD_ZONE, Input::Keyboard, Input::Keys, Input::NON_TRIGGER_ZONE, Input::REPEAT_COOLDOWN, Input::REPEAT_SPACE
Constants included from DisplayMessage
DisplayMessage::MESSAGE_ERROR, DisplayMessage::MESSAGE_PROCESS_ERROR
Instance Attribute Summary
Attributes inherited from Base
#__last_scene, #__result_process, #running, #viewport
Attributes included from DisplayMessage
Instance Method Summary collapse
-
#create_arrow
Create the selection arrow.
-
#create_base_ui
Create the generic background for the UI.
-
#create_graphics
Create the different graphics for the UI.
-
#create_item_desc_window
Create the item description window.
-
#create_item_list
Create the item list for the items to sell.
-
#create_money_window
Create the money window showing the player money.
-
#create_scrollbar
Create the scrollbar.
-
#create_shop_banner
Create the banner spelling “shop” in different languages.
-
#initialize(symbol_or_list, price_overwrite = {}, show_background: true) ⇒ Shop
constructor
Create a new Item Shop.
-
#update_arrow
Update the selection arrow animation.
-
#update_graphics
Update the graphics every frame.
-
#update_in_stock_item(nb)
Update the number of the actual item currently in stock.
-
#update_inputs
Update the inputs every frame.
-
#update_item_button_list
Update the item list.
-
#update_item_desc
Method that calls all the informations updating method of the description window.
-
#update_item_desc_name(name)
Update the name of the item currently shown.
-
#update_item_desc_text(text)
Update the description of the item currently shown.
-
#update_money_text
Update the money the player has.
-
#update_mouse(moved) ⇒ Boolean
Update the mouse interactions.
-
#update_nb_item(nb)
Update the number of the actual item possessed by the player.
-
#update_scrollbar
Update the scrollbar's max index information.
Methods inherited from BaseCleanUpdate::FrameBalanced
Methods included from Graphics::FPSBalancer::Marker
Methods inherited from BaseCleanUpdate
#automatic_input_update, #update
Methods inherited from Base
#add_disposable, #call_scene, #dispose, #find_parent, #main, #return_to_scene, #snap_to_bitmap, #update, #visible, #visible=
Methods included from Input
dir4, dir8, get_text, joy_axis_position, press?, register_events, released?, repeat?, swap_states, trigger?
Methods included from DisplayMessage
#can_display_message_be_called?, #close_message_window, #display_message, #display_message_and_wait, #message_class, #message_processing?, #message_visible, #message_visible=
Constructor Details
#initialize(symbol_shop) ⇒ Shop #initialize(symbol_shop, price_overwritten) ⇒ Shop #initialize(list_id_object) ⇒ Shop #initialize(list_id_object, price_overwrite) ⇒ Shop
Create a new Item Shop
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'scripts/01450 Systems/00203 Shop/00003 GamePlay/00100 Shop.rb', line 22 def initialize(symbol_or_list, price_overwrite = {}, show_background: true) super() return if symbol_or_list == false validate_param(:initialize, :symbol_or_list, symbol_or_list => [Symbol, Array]) validate_param(:initialize, :symbol_or_list, symbol_or_list => { Array => Integer }) if symbol_or_list.class == Array validate_param(:initialize, :price_overwrite, price_overwrite => Hash) @force_close = nil @shop = PFM.game_state.shop @show_background = :show_background @symbol_or_list = symbol_or_list @price_overwrite = price_overwrite @what_was_buyed = [] load_item_list unless @force_close == true @index = @index.clamp(0, @last_index) @running = true end end |
Instance Method Details
#create_arrow
Create the selection arrow
64 65 66 |
# File 'scripts/01450 Systems/00203 Shop/00003 GamePlay/00101 Shop_Graphics.rb', line 64 def create_arrow @arrow = Arrow.new(@viewport) end |
#create_base_ui
Create the generic background for the UI
30 31 32 |
# File 'scripts/01450 Systems/00203 Shop/00003 GamePlay/00101 Shop_Graphics.rb', line 30 def create_base_ui @base_ui = UI::GenericBase.new(@viewport, hide_background_and_button: true) end |
#create_graphics
Create the different graphics for the UI
6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'scripts/01450 Systems/00203 Shop/00003 GamePlay/00101 Shop_Graphics.rb', line 6 def create_graphics super() unless @force_close create_base_ui if @show_background create_money_window create_item_list create_arrow create_item_desc_window Graphics.sort_z end end |
#create_item_desc_window
Create the item description window
74 75 76 77 |
# File 'scripts/01450 Systems/00203 Shop/00003 GamePlay/00101 Shop_Graphics.rb', line 74 def create_item_desc_window @item_desc_window = ItemDesc.new(@viewport) update_item_desc end |
#create_item_list
Create the item list for the items to sell
51 52 53 54 |
# File 'scripts/01450 Systems/00203 Shop/00003 GamePlay/00101 Shop_Graphics.rb', line 51 def create_item_list @item_list = ItemList.new(@viewport) end |
#create_money_window
Create the money window showing the player money
35 36 37 38 |
# File 'scripts/01450 Systems/00203 Shop/00003 GamePlay/00101 Shop_Graphics.rb', line 35 def create_money_window @gold_window = MoneyWindow.new(@viewport) update_money_text end |
#create_scrollbar
Create the scrollbar
108 109 110 111 |
# File 'scripts/01450 Systems/00203 Shop/00003 GamePlay/00101 Shop_Graphics.rb', line 108 def @scroll_bar = ScrollBar.new(@viewport) end |
#create_shop_banner
Create the banner spelling “shop” in different languages
46 47 48 |
# File 'scripts/01450 Systems/00203 Shop/00003 GamePlay/00101 Shop_Graphics.rb', line 46 def @banner = ShopBanner.new(@viewport) end |
#update_arrow
Update the selection arrow animation
69 70 71 |
# File 'scripts/01450 Systems/00203 Shop/00003 GamePlay/00101 Shop_Graphics.rb', line 69 def update_arrow @arrow.update end |
#update_graphics
Update the graphics every frame
21 22 23 24 25 26 27 |
# File 'scripts/01450 Systems/00203 Shop/00003 GamePlay/00101 Shop_Graphics.rb', line 21 def update_graphics unless @force_close @base_ui.update_background_animation if @show_background @animation&.call update_arrow end end |
#update_in_stock_item(nb)
Update the number of the actual item currently in stock
103 104 105 |
# File 'scripts/01450 Systems/00203 Shop/00003 GamePlay/00101 Shop_Graphics.rb', line 103 def update_in_stock_item(nb) @item_desc_window.nb_in_stock = nb end |
#update_inputs
Update the inputs every frame
4 5 6 7 8 9 10 11 |
# File 'scripts/01450 Systems/00203 Shop/00003 GamePlay/00102 Shop_Inputs.rb', line 4 def update_inputs unless @force_close return false if @animation return && update_list_input end end |
#update_item_button_list
Update the item list
57 58 59 60 61 |
# File 'scripts/01450 Systems/00203 Shop/00003 GamePlay/00101 Shop_Graphics.rb', line 57 def @item_list.item_list = @list_item @item_list.item_price = @list_price @item_list.index = @index end |
#update_item_desc
Method that calls all the informations updating method of the description window
80 81 82 83 84 85 |
# File 'scripts/01450 Systems/00203 Shop/00003 GamePlay/00101 Shop_Graphics.rb', line 80 def update_item_desc update_item_desc_name(data_item(@list_item[@index]).name) update_item_desc_text(data_item(@list_item[@index]).description) update_nb_item($bag.item_quantity(@list_item[@index])) update_in_stock_item(@item_quantity[@index]) if @item_quantity != [] end |
#update_item_desc_name(name)
Update the name of the item currently shown
88 89 90 |
# File 'scripts/01450 Systems/00203 Shop/00003 GamePlay/00101 Shop_Graphics.rb', line 88 def update_item_desc_name(name) @item_desc_window.name = name end |
#update_item_desc_text(text)
Update the description of the item currently shown
93 94 95 |
# File 'scripts/01450 Systems/00203 Shop/00003 GamePlay/00101 Shop_Graphics.rb', line 93 def update_item_desc_text(text) @item_desc_window.text = text end |
#update_money_text
Update the money the player has
41 42 43 |
# File 'scripts/01450 Systems/00203 Shop/00003 GamePlay/00101 Shop_Graphics.rb', line 41 def update_money_text @gold_window.text = parse_text(11, 9, NUM7R => PFM.game_state.money.to_s) end |
#update_mouse(moved) ⇒ Boolean
Update the mouse interactions
8 9 10 11 12 13 14 15 |
# File 'scripts/01450 Systems/00203 Shop/00003 GamePlay/00140 Shop_Mouse.rb', line 8 def update_mouse(moved) unless @force_close return update_mouse_index if Mouse.wheel != 0 return false if moved && update_mouse_list else @running = false end end |
#update_nb_item(nb)
Update the number of the actual item possessed by the player
98 99 100 |
# File 'scripts/01450 Systems/00203 Shop/00003 GamePlay/00101 Shop_Graphics.rb', line 98 def update_nb_item(nb) @item_desc_window.nb_item = nb end |
#update_scrollbar
Update the scrollbar's max index information
114 115 116 |
# File 'scripts/01450 Systems/00203 Shop/00003 GamePlay/00101 Shop_Graphics.rb', line 114 def @scroll_bar.max_index = @last_index end |