查看: 3123|回复: 6

[已经解决] 【已解决】如何实现一个等级多重名称

[复制链接]
梦石
0
星屑
6447
在线时间
1702 小时
注册时间
2018-1-16
回帖
364
发表于 2020-11-12 20:01:11 | 显示全部楼层 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有账号?注册会员

×
本帖最后由 l734273398 于 2020-11-13 15:17 编辑

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

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



  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
复制代码
  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
复制代码
梦石
0
星屑
39336
在线时间
11161 小时
注册时间
2009-3-15
回帖
4768
发表于 2020-11-12 21:28:26 | 显示全部楼层
  1. LEVEL_LIST = {
  2.   1=>"菜鸡",
  3.   2=>"小菜鸡",

  4. }
  5. LEVEL_LIST2 = {
  6.   1=>"勇士",
  7.   2=>"小勇士",

  8. }
  9. class Window_Base < Window
  10.   def draw_actor_level(actor, x, y)
  11.     if LEVEL_LIST.has_key?(actor.level) or LEVEL_LIST2.has_key?(actor.level)
  12.       self.contents.draw_text(x, y, 128, 32, LEVEL_LIST[actor.level]) if $game_switches[1]
  13.       self.contents.draw_text(x, y, 128, 32, LEVEL_LIST2[actor.level]) if $game_switches[2]
  14.     else
  15.       self.contents.font.color = system_color
  16.       self.contents.draw_text(x, y, 32, 32, "Lv")
  17.       self.contents.font.color = normal_color
  18.       self.contents.draw_text(x + 32, y, 24, 32, actor.level.to_s, 2)
  19.     end
  20.   end
  21. end


复制代码

评分

参与人数 3星屑 +50 赞 +2 收起 理由
taeckle + 1 大神威武!
RyanBern + 50 认可答案
l734273398 + 1 认可答案

查看全部评分

回复 1 0

使用道具 举报

梦石
0
星屑
8003
在线时间
1184 小时
注册时间
2007-7-29
回帖
2014
发表于 2020-11-12 21:38:28 | 显示全部楼层
我更建议用变量,如下是当变量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
复制代码

点评

实际上这么搞的话开关和变量没区别···用到脚本了直接让开关X等于123456789就行了···  发表于 2020-11-13 12:40
好的,谢谢  发表于 2020-11-12 22:05
我建议用变量是因为只需要一个变量就可以控制,开关则是需要到两个或以上,抱着能省就省当然是变量优先XD。  发表于 2020-11-12 22:04
谢谢了,不过之所以用开关的话,是因为开关决定一些剧情的开启,而不同的开关可以会造成不同的等级名称  发表于 2020-11-12 21:40

评分

参与人数 1赞 +1 收起 理由
l734273398 + 1 塞糖

查看全部评分

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部