Project1

标题: 【已解决】如何实现一个等级多重名称 [打印本页]

作者: l734273398    时间: 2020-11-12 20:01
标题: 【已解决】如何实现一个等级多重名称
本帖最后由 l734273398 于 2020-11-13 15:17 编辑

如题,看题目可能会有点糊涂,
打个比方:当1号开关打开时,使用【1号系列的等级名称】,当2号开关打开时,使用【2系列的等级名称】以此类推

【当打开1号开关】【1级名称=菜鸡】【2级名称=小菜鸡】
【当打开2号开关】【1级名称=勇士】【2级名称=小勇士】



RUBY 代码复制
  1. LEVEL_LIST = {
  2.   1=>"菜鸡",
  3.   2=>"小菜鸡",
  4.  
  5. }
  6. class Window_Base < Window
  7.   def draw_actor_level(actor, x, y)
  8.     if LEVEL_LIST.has_key?(actor.level)
  9.       self.contents.draw_text(x, y, 128, 32, LEVEL_LIST[actor.level])
  10.     else
  11.       self.contents.font.color = system_color
  12.       self.contents.draw_text(x, y, 32, 32, "Lv")
  13.       self.contents.font.color = normal_color
  14.       self.contents.draw_text(x + 32, y, 24, 32, actor.level.to_s, 2)
  15.     end
  16.   end
  17. end

RUBY 代码复制
  1. LEVEL_LIST = {
  2.   1=>"勇士",
  3.   2=>"小勇士",
  4.  
  5. }
  6. class Window_Base < Window
  7.   def draw_actor_level(actor, x, y)
  8.     if LEVEL_LIST.has_key?(actor.level)
  9.       self.contents.draw_text(x, y, 128, 32, LEVEL_LIST[actor.level])
  10.     else
  11.       self.contents.font.color = system_color
  12.       self.contents.draw_text(x, y, 32, 32, "Lv")
  13.       self.contents.font.color = normal_color
  14.       self.contents.draw_text(x + 32, y, 24, 32, actor.level.to_s, 2)
  15.     end
  16.   end
  17. end

作者: soulsaga    时间: 2020-11-12 21:28
RUBY 代码复制
  1. LEVEL_LIST = {
  2.   1=>"菜鸡",
  3.   2=>"小菜鸡",
  4.  
  5. }
  6. LEVEL_LIST2 = {
  7.   1=>"勇士",
  8.   2=>"小勇士",
  9.  
  10. }
  11. class Window_Base < Window
  12.   def draw_actor_level(actor, x, y)
  13.     if LEVEL_LIST.has_key?(actor.level) or LEVEL_LIST2.has_key?(actor.level)
  14.       self.contents.draw_text(x, y, 128, 32, LEVEL_LIST[actor.level]) if $game_switches[1]
  15.       self.contents.draw_text(x, y, 128, 32, LEVEL_LIST2[actor.level]) if $game_switches[2]
  16.     else
  17.       self.contents.font.color = system_color
  18.       self.contents.draw_text(x, y, 32, 32, "Lv")
  19.       self.contents.font.color = normal_color
  20.       self.contents.draw_text(x + 32, y, 24, 32, actor.level.to_s, 2)
  21.     end
  22.   end
  23. end

作者: enghao_lim    时间: 2020-11-12 21:38
我更建议用变量,如下是当变量10为1的话会使用菜鸡,2会使用勇士,不设定时返回默认。
  1. class Window_Base
  2.   alias cool_alias_draw_actor_level draw_actor_level
  3.   def draw_actor_level(actor, x, y)
  4.     varId = 10 #变量号
  5.     #变量值 => { 等级 => 名称 }
  6.     list = {
  7.       1 => {
  8.         1 => "菜鸡",
  9.         2 => "小菜鸡",
  10.       },
  11.       2 => {
  12.         1 => "勇士",
  13.         2 => "小勇士",
  14.       }
  15.     }
  16.     set = list[$game_variables[varId]]
  17.     if set and set[actor.level]
  18.       self.contents.font.color = normal_color
  19.       self.contents.draw_text(x, y, 64, 32, set[actor.level])
  20.     else
  21.       cool_alias_draw_actor_level(actor, x, y)
  22.     end
  23.   end
  24. end
复制代码





欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1