| Roi |
 |
 |
Inscrit le: 13 Aoû 2006, 00:00 Messages: 2414 Localisation: Montréal, QC Logiciel(s) préféré(s): RMXP, VS2008 Point(s) Fort(s): Script Points d'aide: Illimité
Créations :
- Séparation d'inventaire
- Sprite_Text
Voir ses créations
|
1.3. Exemple de scène- Code: Tout sélectionner
#=============================================================================== # ■ Scene Socket #------------------------------------------------------------------------------- # Cette scene est un exemple d'utilisation du script Socket System #------------------------------------------------------------------------------- # Installation : # Copier ce script dans un nouveau script entre Socket System et Main. #------------------------------------------------------------------------------- # Pour appeller la scene, il suffit d'utiliser le code suivant # $scene = Scene_Socket.new #------------------------------------------------------------------------------- # Personnalisation JEWEL_ID = 17 #Identifiant de l'attribut distinguant les objets sertibles # SOCKET_PRICE = 100 #Le prix pour ajouter un emplacement dans un equipement #===============================================================================
class Window_SocketStat < Window_Base attr_accessor :item attr_accessor :jewel def initialize(item) super(0, 64, 272, 224) self.contents = Bitmap.new(width - 32, height - 32) self.contents.font.name = $fontface self.contents.font.size = $fontsize @item = item @jewel = nil refresh self.active = false end def draw_str parameter_name = $data_system.words.str parameter_value = @item == nil ? 0 : @item.str_plus self.contents.font.color = system_color self.contents.draw_text(0, 0, 120, 32, parameter_name) self.contents.font.color = normal_color self.contents.draw_text(120, 0, 36, 32, parameter_value.to_s, 2) if @jewel != nil if @jewel.parameter_type == 3 parameter_add = @jewel.parameter_points + @item.str_plus else parameter_add = @item.str_plus end self.contents.font.color = system_color self.contents.draw_text(160, 0, 40, 32, "→", 1) self.contents.font.color = normal_color self.contents.draw_text(200, 0, 36, 32, parameter_add.to_s, 2) end end def draw_dex parameter_name = $data_system.words.dex parameter_value = @item == nil ? 0 : @item.dex_plus self.contents.font.color = system_color self.contents.draw_text(0, 32, 120, 32, parameter_name) self.contents.font.color = normal_color self.contents.draw_text(120, 32, 36, 32, parameter_value.to_s, 2) if @jewel != nil if @jewel.parameter_type == 4 parameter_add = @jewel.parameter_points + @item.dex_plus else parameter_add = @item.dex_plus end self.contents.font.color = system_color self.contents.draw_text(160, 32, 40, 32, "→", 1) self.contents.font.color = normal_color self.contents.draw_text(200, 32, 36, 32, parameter_add.to_s, 2) end end def draw_agi parameter_name = $data_system.words.agi parameter_value = @item == nil ? 0 : @item.agi_plus self.contents.font.color = system_color self.contents.draw_text(0, 64, 120, 32, parameter_name) self.contents.font.color = normal_color self.contents.draw_text(120, 64, 36, 32, parameter_value.to_s, 2) if @jewel != nil if @jewel.parameter_type == 5 parameter_add = @jewel.parameter_points + @item.agi_plus else parameter_add = @item.agi_plus end self.contents.font.color = system_color self.contents.draw_text(160, 64, 40, 32, "→", 1) self.contents.font.color = normal_color self.contents.draw_text(200, 64, 36, 32, parameter_add.to_s, 2) end end def draw_int parameter_name = $data_system.words.int parameter_value = @item == nil ? 0 : @item.int_plus self.contents.font.color = system_color self.contents.draw_text(0, 96, 120, 32, parameter_name) self.contents.font.color = normal_color self.contents.draw_text(120, 96, 36, 32, parameter_value.to_s, 2) if @jewel != nil if @jewel.parameter_type == 6 parameter_add = @jewel.parameter_points + @item.int_plus else parameter_add = @item.dex_plus end self.contents.font.color = system_color self.contents.draw_text(160, 96, 40, 32, "→", 1) self.contents.font.color = normal_color self.contents.draw_text(200, 96, 36, 32, parameter_add.to_s, 2) end end def draw_pdef parameter_name = $data_system.words.pdef parameter_value = @item == nil ? 0 : @item.pdef self.contents.font.color = system_color self.contents.draw_text(0, 128, 120, 32, parameter_name) self.contents.font.color = normal_color self.contents.draw_text(120, 128, 36, 32, parameter_value.to_s, 2) if @jewel != nil parameter_add = @jewel.pdef_f + @item.pdef self.contents.font.color = system_color self.contents.draw_text(160, 128, 40, 32, "→", 1) self.contents.font.color = normal_color self.contents.draw_text(200, 128, 36, 32, parameter_add.to_s, 2) end end def draw_mdef parameter_name = $data_system.words.mdef parameter_value = @item == nil ? 0 : @item.mdef self.contents.font.color = system_color self.contents.draw_text(0, 160, 120, 32, parameter_name) self.contents.font.color = normal_color self.contents.draw_text(120, 160, 36, 32, parameter_value.to_s, 2) if @jewel != nil parameter_add = @jewel.mdef_f + @item.mdef self.contents.font.color = system_color self.contents.draw_text(160, 160, 40, 32, "→", 1) self.contents.font.color = normal_color self.contents.draw_text(200, 160, 36, 32, parameter_add.to_s, 2) end end def refresh self.contents.clear draw_str draw_dex draw_agi draw_int draw_pdef draw_mdef end end
class Window_SocketItem < Window_Selectable def initialize super(272, 64, 368, 224) @column_max = 1 refresh self.index = 0 end def refresh if self.contents != nil self.contents.dispose self.contents = nil end @data = $game_party.weapons + $game_party.armors @item_max = @data.size if @item_max > 0 self.contents = Bitmap.new(width - 32, row_max * 32) self.contents.font.name = $fontface self.contents.font.size = $fontsize for i in 0...@item_max draw_item(i) end end end def draw_item(index) item = @data[index] if item.can_add_jewel? self.contents.font.color = normal_color else self.contents.font.color = disabled_color end x = 4 y = index * 32 rect = Rect.new(x, y, self.width / @column_max - 32, 32) self.contents.fill_rect(rect, Color.new(0, 0, 0, 0)) bitmap = RPG::Cache.icon(item.icon_name) opacity = self.contents.font.color == normal_color ? 255 : 128 self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity) self.contents.draw_text(x + 28, y, 212, 32, item.name, 0) end def item return @data[self.index] end def update_help @help_window.set_text(self.item == nil ? "" : self.item.description) end end
class Window_Jewel < Window_Selectable def initialize super(0, 288, 640, 192) @column_max = 2 refresh self.active = false self.index = -1 end def refresh if self.contents != nil self.contents.dispose self.contents = nil end @data = [] for item in $game_party.items @data.push(item) if item.element_set .include?(JEWEL_ID) end @item_max = @data.size if @item_max > 0 self.contents = Bitmap.new(width - 32, row_max * 32) self.contents.font.name = $fontface self.contents.font.size = $fontsize for i in 0...@item_max draw_item(i) end end end def draw_item(index) item = @data[index] x = 4 + index % 2 * (288 + 32) y = index / 2 * 32 rect = Rect.new(x, y, self.width / @column_max - 32, 32) self.contents.fill_rect(rect, Color.new(0, 0, 0, 0)) bitmap = RPG::Cache.icon(item.icon_name) opacity = self.contents.font.color == normal_color ? 255 : 128 self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity) self.contents.draw_text(x + 28, y, 212, 32, item.name, 0) end def item return @data[self.index] end def update_help @help_window.set_text(self.item == nil ? "" : self.item.description) end end
class Window_SockAdd < Window_Selectable
def initialize super(0, 288, 640, 192) self.z = 500 @column_max = 2 @item_max = 2 refresh self.active = false self.visible = false self.index = 0 end def refresh if self.contents != nil self.contents.dispose self.contents = nil end self.contents = Bitmap.new(width - 32, height - 32) self.contents.font.name = $fontface self.contents.font.size = $fontsize text = "Voulez-vous ajouter un emplacement ?" self.contents.draw_text(0,0,640,32,text,0) self.contents.draw_text(10,32,50,32,"Oui",0) self.contents.draw_text(330,32,50,32,"Non",0) end def update_cursor_rect if @index < 0 self.cursor_rect.empty return end row = @index / @column_max if row < self.top_row self.top_row = row end if row > self.top_row + (self.page_row_max - 1) self.top_row = row - (self.page_row_max - 1) end cursor_width = self.width / @column_max - 32 x = @index % @column_max * (cursor_width + 32) y = @index / @column_max * 32 - self.oy self.cursor_rect.set(x, y + 32, cursor_width, 32) end end
class Scene_Socket def main @help_window = Window_Help.new @item_window = Window_SocketItem.new @item_window.help_window = @help_window @stat_window = Window_SocketStat.new(@item_window.item) @item_window.active = true @jewel_window = Window_Jewel.new @jewel_window.help_window = @help_window @sock_window = Window_SockAdd.new Graphics.transition loop do Graphics.update Input.update update if $scene != self break end end Graphics.freeze @help_window.dispose @stat_window.dispose @item_window.dispose @jewel_window.dispose @sock_window.dispose end def update @help_window.update @stat_window.update @item_window.update @jewel_window.update @sock_window.update if @item_window.active update_item return end if @jewel_window.active update_jewel return end if @sock_window.active update_sock return end end def update_item @stat_window.item = @item_window.item @stat_window.refresh if Input.trigger?(Input::B) $game_system.se_play($data_system.cancel_se) $scene = Scene_Map.new return end if Input.trigger?(Input::C) if @item_window.item != nil and @item_window.item.can_add_jewel? $game_system.se_play($data_system.decision_se) @item_window.active = false @jewel_window.index = 0 @jewel_window.active = true elsif @item_window.item != nil and @item_window.item.can_add_socket? and $game_party.gold >= SOCKET_PRICE @item_window.active = false @sock_window.active = true @sock_window.visible = true else $game_system.se_play($data_system.buzzer_se) end end end def update_jewel @stat_window.jewel = @jewel_window.item @stat_window.refresh if Input.trigger?(Input::B) $game_system.se_play($data_system.cancel_se) @jewel_window.index = -1 @stat_window.jewel = nil @jewel_window.active = false @item_window.active = true return end if Input.trigger?(Input::C) $game_system.se_play($data_system.decision_se) @item_window.item.add_jewel(@jewel_window.item) $game_party.lose_item(@jewel_window.item) @jewel_window.refresh @item_window.refresh if ! @item_window.item.can_add_jewel? @jewel_window.index = -1 @stat_window.jewel = nil @jewel_window.active = false @item_window.active = true end return end end def update_sock if Input.trigger?(Input::B) $game_system.se_play($data_system.cancel_se) @sock_window.active = false @sock_window.visible = false @item_window.active = true return end if Input.trigger?(Input::C) case @sock_window.index when 0 $game_system.se_play($data_system.decision_se) @item_window.item.add_socket $game_party.lose_gold(SOCKET_PRICE) @item_window.refresh @sock_window.active = false @sock_window.visible = false @item_window.active = true return when 1 $game_system.se_play($data_system.cancel_se) @sock_window.index = 0 @sock_window.active = false @sock_window.visible = false @item_window.active = true return end end end end
|
|