class Scene_Menu #-------------------------------------------------------------------------- # ● 初始化对像 # menu_index : 命令光标的初期位置 #-------------------------------------------------------------------------- def initialize(menu_index = 0) @menu_index = menu_index end #-------------------------------------------------------------------------- # ● 主处理 #-------------------------------------------------------------------------- def main # 生成命令窗口 s1 = $spawn s2 = $spawn2 s3 = $spawn3 s4 = $spawn4 s5 = $spawn5 s6 = $spawn6 s7 = $spawn7 s8 = $spawn8 s9 = $spawn9 s10 = $spawn10 @command_window = Window_Command.new(160, [s1, s2, s3, s4, s5, s6,s7,s8,s9,s10]) @command_window.index = @menu_index # 同伴人数为 0 的情况下 # 执行过渡 Graphics.transition # 主循环 loop do # 刷新游戏画面 Graphics.update # 刷新输入信息 Input.update # 刷新画面 update # 如果切换画面就中断循环 if $scene != self break #中断 end end # 准备过渡 Graphics.freeze # 释放窗口 @command_window.dispose # @playtime_window.dispose # @steps_window.dispose # @gold_window.dispose # @status_window.dispose end #-------------------------------------------------------------------------- # ● 刷新画面 #-------------------------------------------------------------------------- def update # 刷新窗口 @command_window.update # 命令窗口被激活的情况下: 调用 update_command if @command_window.active update_command return end end #-------------------------------------------------------------------------- # ● 刷新画面 (命令窗口被激活的情况下) #-------------------------------------------------------------------------- def update_command # 按下 B 键的情况下 if Input.trigger?(Input::B) # 演奏取消 SE $game_system.se_play($data_system.cancel_se) # 切换的地图画面 $scene = Scene_menu2.new return end # 按下 C 键的情况下 if Input.trigger?(Input::C) # 同伴人数为 0、存档、游戏结束以外的场合 if $game_party.actors.size == 0 and @command_window.index < 4 # 演奏冻结 SE $game_system.se_play($data_system.buzzer_se) return end # 命令窗口的光标位置分支 case @command_window.index when 0 # 出战布阵点1 # 演奏确定 SE $game_system.se_play($data_system.decision_se) # 切换到物品画面 $出战=[115,320] @buzhen_spawn = Sprite.new @buzhen_spawn.bitmap = RPG::Cache.title("title-base-light") @buzhen_spawn.x = 115 @buzhen_spawn.y = 320 when 1 # 出战布阵点2 # 演奏确定 SE $game_system.se_play($data_system.decision_se) # 激活状态窗口 $出战=[135,300] @buzhen_spawn = Sprite.new @buzhen_spawn.bitmap = RPG::Cache.title("title-base-light") @buzhen_spawn.x = 135 @buzhen_spawn.y = 300 when 2 # 出战布阵点3 # 演奏确定 SE $game_system.se_play($data_system.decision_se) # 激活状态窗口 $出战=[155,320] @buzhen_spawn = Sprite.new @buzhen_spawn.bitmap = RPG::Cache.title("title-base-light") @buzhen_spawn.x = 155 @buzhen_spawn.y = 320 when 3 # 出战布阵点4 # 演奏确定 SE $game_system.se_play($data_system.decision_se) # 激活状态窗口 $出战=[175,300] @buzhen_spawn = Sprite.new @buzhen_spawn.bitmap = RPG::Cache.title("title-base-light") @buzhen_spawn.x = 135 @buzhen_spawn.y = 300 when 4 # 出战布阵点5 # 演奏确定 SE $game_system.se_play($data_system.decision_se) # 激活状态窗口 $出战=[175,340] @buzhen_spawn = Sprite.new @buzhen_spawn.bitmap = RPG::Cache.title("title-base-light") @buzhen_spawn.x = 175 @buzhen_spawn.y = 340 when 5 # 出战布阵点6 $出战=[215,420] @buzhen_spawn = Sprite.new @buzhen_spawn.bitmap = RPG::Cache.title("title-base-light") @buzhen_spawn.x = 215 @buzhen_spawn.y = 420 when 6 # 出战布阵点7 $出战=[135,440] @buzhen_spawn = Sprite.new @buzhen_spawn.bitmap = RPG::Cache.title("title-base-light") @buzhen_spawn.x = 135 @buzhen_spawn.y = 440 when 7 # 出战布阵点8 $出战=[155,460] @buzhen_spawn = Sprite.new @buzhen_spawn.bitmap = RPG::Cache.title("title-base-light") @buzhen_spawn.x = 217 @buzhen_spawn.y = 460 when 5 # 出战布阵点9 $出战=[175,440] @buzhen_spawn = Sprite.new @buzhen_spawn.bitmap = RPG::Cache.title("title-base-light") @buzhen_spawn.x = 218 @buzhen_spawn.y = 423 when 5 # 出战布阵点10 $出战=[215,460] @buzhen_spawn = Sprite.new @buzhen_spawn.bitmap = RPG::Cache.title("title-base-light") @buzhen_spawn.x = 219 end return end end #-------------------------------------------------------------------------- # ● 刷新画面 (状态窗口被激活的情况下) #-------------------------------------------------------------------------- def update_status # 按下 B 键的情况下 if Input.trigger?(Input::B) # 演奏取消 SE $game_system.se_play($data_system.cancel_se) # 激活命令窗口 @command_window.active = true return end # 按下 C 键的情况下 if Input.trigger?(Input::C) # 命令窗口的光标位置分支 case @command_window.index when 1 # 特技 # 本角色的行动限制在 2 以上的情况下 if $game_party.actors[@status_window.index].restriction >= 2 # 演奏冻结 SE $game_system.se_play($data_system.buzzer_se) return end # 演奏确定 SE $game_system.se_play($data_system.decision_se) # 切换到特技画面 $scene = Scene_Skill.new(@status_window.index) when 2 # 装备 # 演奏确定 SE $game_system.se_play($data_system.decision_se) # 切换的装备画面 $scene = Scene_Equip.new(@status_window.index) when 3 # 状态 # 演奏确定 SE $game_system.se_play($data_system.decision_se) # 切换到状态画面 $scene = Scene_Status.new(@status_window.index) end return end end end
# ———————————————————————————————————— # 本脚本来自[url]www.66rpg.com[/url],转载请保留此信息 # ———————————————————————————————————— #============================================================================== # 选项动态加强 # 作者:carol3 #============================================================================== # ■ Window_Command #------------------------------------------------------------------------------ # 一般的命令选择行窗口。 #============================================================================== class Window_Command < Window_Selectable #-------------------------------------------------------------------------- # ● 初始化对像 # width : 窗口的宽 # commands : 命令字符串序列 #-------------------------------------------------------------------------- def initialize(width, commands) # 由命令的个数计算出窗口的高 super(0, 0, width, commands.size * 32 + 32) @item_max = commands.size @commands = commands self.contents = Bitmap.new(width - 32, @item_max * 32) @item = [] self.index = 0 refresh @oldindex = 0 end #-------------------------------------------------------------------------- # ● 刷新 #-------------------------------------------------------------------------- def refresh self.contents.clear for i in 0...@item_max if i != self.index draw_item_dis(i) else draw_item_active(i,@item[i]) end end end #-------------------------------------------------------------------------- # ● 描绘项目 # index : 项目编号 # color : 文字色 #-------------------------------------------------------------------------- def draw_item_dis(index) self.contents.font.size -= 2 self.contents.font.color = disabled_color # rect = Rect.new(4+16, 32 * index, self.contents.width - 24, 32) self.contents.fill_rect(rect, Color.new(0, 255, 255, 255)) self.contents.draw_text(rect, @commands[index]) self.contents.font.size += 2 end def draw_item_active(index, type) self.contents.font.color = Color.new(0,0,0,255) self.contents.draw_text(5,32*index+1,self.contents.width,32, @commands[index]) if type==1 self.contents.font.color = disabled_color else self.contents.font.color = Color.new(255,238,17,255) end self.contents.draw_text(4,32*index,self.contents.width,32, @commands[index]) end #-------------------------------------------------------------------------- # ● 项目无效化 # index : 项目编号 #-------------------------------------------------------------------------- def disable_item(index) @item[index] = 1 end #-------------------------------------------------------------------------- # ● 刷新方法更新 #-------------------------------------------------------------------------- def update super #——这里使用的刷新方法比直接refresh节约很多内存 if self.index != @oldindex @oldindex = self.index refresh end end end
布阵.png (388.89 KB, 下载次数: 22)
soulsaga 发表于 2024-6-16 04:35
以前教你的人我觉得都白教...应该能从以往的回答想到解决方法的吧
soulsaga 发表于 2024-6-16 18:38
你没看到已经没人理你了吗
我也不打算理
class Scene_Menu @window_CB_selected_troop = Window_CustomBattle.new(0,aviliable_groups,aviliable_num_per_group,player_or_enermy) #@窗口CB选择的部队.z= 999 @window_CB_selected_troop.x= 200 if Input.trigger?(Input::C) #进入选择士兵界面 if @window_CB_selected_troop.v_index == 0 #进入选择士兵界面 $game_system.se_play($data_system.decision_se) if @window_CB_selected_troop.active @window_CB_selected_troop.active = false @window_troops_list.active = true else #选择士兵 if @window_CB_selected_troop.item_num < @window_CB_selected_troop.item_max @selected_units[@window_CB_selected_troop.index].push @window_troops_list.now_selected_troop @window_CB_selected_troop.set_units(@selected_units) @window_CB_selected_troop.refresh else $game_system.se_play($data_system.buzzer_se) end #< end #@window_CB_selected_troop.active else #@window_CB_selected_troop.v_index == 0 #操作 $game_system.se_play($data_system.decision_se) if @window_CB_selected_troop.second_index == 0 nothing = true for i in 0...@selected_units.size nothing = false if @selected_units[i].size != 0 end if nothing $game_system.se_play($data_system.buzzer_se) else back_to_title_normal end elsif @window_CB_selected_troop.second_index == 1 @window_CB_selected_troop.delete_last_troop# elsif @window_CB_selected_troop.second_index == 2 @window_CB_selected_troop.empty_troops end end #@window_CB_selected_troop.v_index == 0 end # Input.trigger?(Input::C)
#-------------------------------------------------------------------------- # ● 更新光标矩形 #-------------------------------------------------------------------------- class Window_CustomBattle < Window_Base # attr_reader :index #属性读取器:索引 attr_reader :v_index #属性读取器:v_索引 attr_reader :slide_over #属性读取器:#滚动结束 attr_reader :item_max #属性阅读器:项目最大值 attr_reader :second_index #属性阅读器: 第二个索引 @button_base = Sprite.new #@按钮_底座=新的精灵 if player_or_enermy == 0 #@按钮_底座位图 = RPG::Cache.title("绿色背景图") @button_base.bitmap = RPG::Cache.title("")#("selected-unites-base") else #@按钮_底座位图 = RPG::Cache.title("红色背景图") @button_base.bitmap = RPG::Cache.title("selected-unites-e-base") end @button_base.x = origin_x @button_base.y = origin_y @finish_button = Sprite.new #@完成按钮=精灵.new #if player_or_enermy == 0 #@完成按钮位图= RPG::Cache.title("完成") @finish_button.bitmap = RPG::Cache.title("bottom-button-1-basic") # else # @finish_button.bitmap = RPG::Cache.title("bottom-button-1-basic-e") # end @finish_button.x = origin_x + 16#完成按钮.x = origin_x + 16 @finish_button.y = origin_y + 187 @able = []#@表=[] @max_row = 2 #@最大行=2 @bottom_buttons = [] #@底部按钮=[] @max_item_row_2 = 3 #@最大项目行2=3 @delete_button = Sprite.new #@删除按钮=精灵新 #@删除按钮位图=RPG::Cache.title("删除按钮") @delete_button.bitmap = RPG::Cache.title("bottom-button-2-basic") @delete_button.x = origin_x @delete_button.y = origin_y # @清空按钮=精灵.new @empty_button = Sprite.new # @清空按钮位图= RPG::Cache.title("清空按钮") @empty_button.bitmap = RPG::Cache.title("bottom-button-3-basic") @empty_button.x = origin_x @empty_button.y = origin_y @bottom_buttons.push @finish_button# @底部按钮。按下完成按钮 @bottom_buttons.push @delete_button# @底部按钮。按下删除按钮 @bottom_buttons.push @empty_button # @底部按钮。按下清空按钮 @second_index = @index #@第二个索引=@索引 def update_cursor_rect if @v_index == 0 # 光标位置不满 0 的情况下 if @index < 0 for i in 0...@item_max back_normal(i) end return end if @player_or_enermy == 0 @groups[@index].bitmap = RPG::Cache.title("team-highlight")#+i.to_s) else @groups[@index].bitmap = RPG::Cache.title("enermy-highlight")#+i.to_s) end @group_text[@index].bitmap = RPG::Cache.title("group"+(index+1).to_s+"-l") else #level 2 if @second_index < 0 for i in 0..@max_item_row_2-1 back_normal(i) end return end #p @index,@second_index # @second_index%=2 完成 @bottom_buttons[@second_index].bitmap = RPG::Cache.title("bottom-button-"+(@second_index+1).to_s+"-l")#+i.to_s) end end #-------------------------------------------------------------------------- # ● 刷新画面 #-------------------------------------------------------------------------- def update if self.active if Input.repeat?(Input::DOWN) $game_system.se_play($data_system.cursor_se) @v_index = (@v_index+1)%@max_row #@last_index = @index if @v_index == 0 #back_normal(@second_index) @second_index = -1 for i in 0..@max_item_row_2-1 back_normal(i) end else #back_normal(@index) @second_index = 1 #@index%=@max_item_row_2 if @player_or_enermy == 0 @groups[@index].bitmap = RPG::Cache.title("team-basic")#+i.to_s) else @groups[@index].bitmap = RPG::Cache.title("enermy-basic")#+i.to_s) end end refresh end if Input.repeat?(Input::UP) $game_system.se_play($data_system.cursor_se) #back_normal(@index) @v_index = (@v_index-1)%@max_row # @last_index = @index if @v_index == 0 #back_normal(@second_index) @second_index = -1 for i in 0..@max_item_row_2-1 back_normal(i) end else #back_normal(@index) @second_index = 1 #@index%=@max_item_row_2 if @player_or_enermy == 0 #队伍1-5背景 @groups[@index].bitmap = RPG::Cache.title("team-basic")#+i.to_s) else # 敌人队伍1-5背景 @groups[@index].bitmap = RPG::Cache.title("enermy-basic")#+i.to_s) end end refresh end if @v_index == 0 # 方向键左被按下的情况下 if Input.repeat?(Input::RIGHT) $game_system.se_play($data_system.cursor_se) back_normal(@index) @index = (@index+1)%@group_max until @able[@index] @index = (@index+1)%@group_max end refresh end # 方向键右被按下的情况下 if Input.repeat?(Input::LEFT) $game_system.se_play($data_system.cursor_se) back_normal(@index) @index = (@index+@item_max-1)%@group_max until @able[@index] @index = (@index+@item_max-1)%@group_max end refresh end else # level 2 # 方向键左被按下的情况下 if Input.repeat?(Input::RIGHT) $game_system.se_play($data_system.cursor_se) back_normal(@second_index) @second_index = (@second_index+1)%@max_item_row_2 #p @second_index refresh end # 方向键右被按下的情况下 if Input.repeat?(Input::LEFT) $game_system.se_play($data_system.cursor_se) back_normal(@second_index) @second_index = (@second_index-1)%@max_item_row_2 refresh end end # @v_index == 0 end update_cursor_rect #if @slide_over end #-------------------------------------------------------------------------- # ● 获取东西 #-------------------------------------------------------------------------- def item_num(index = @index) # 定义项目 (索引=@索引) return @selected_units[@index].size end def set_units(a)#定义设置单位(a) @selected_units = a#选定的单位=a end #-------------------------------------------------------------------------- # ● 更新内容 #-------------------------------------------------------------------------- def refresh #定义 恢复精力 for i in 0...@item_max @icons[i].bitmap = nil end #对于i,单位为0..@选定的单位[@索引]。大小-1 for i in 0..@selected_units[@index].size-1 @icons[i].bitmap = RPG::Cache.icon(Figter_data::CHARACTER_NAME[@selected_units[@index][i]]) #p Figter_data::CHARACTER_NAME[twoArray[@index][i]] end end #-------------------------------------------------------------------------- # ● 删除士兵 #-------------------------------------------------------------------------- def delete_last_troop#删除最后一个部队 @selected_units[@index].pop#@选定的单位[@index].短暂离去 refresh end #-------------------------------------------------------------------------- # ● 清空士兵 #-------------------------------------------------------------------------- def empty_troops @selected_units[@index]=[] refresh end end
无规律的索引.png (58.33 KB, 下载次数: 22)
欢迎光临 Project1 (https://rpg.blue/) | Powered by Discuz! X3.1 |