Project1

标题: 请问如何显示状态回合数? [打印本页]

作者: 存档不能    时间: 2013-9-18 08:39
标题: 请问如何显示状态回合数?
请问如何将默认的状态显示(即“[正常]”这样的文字)改成显示该状态的剩余回合数?
作者: 芯☆淡茹水    时间: 2013-9-18 08:39
初制品。由于要显示的状态文字较多,缩小了字体大小。
  1. #==============================================================================
  2. class Game_Battler
  3.   attr_accessor :states_turn
  4. end
  5. #==============================================================================
  6. class Window_Base < Window
  7.   #--------------------------------------------------------------------------
  8.   def make_battler_state_text(battler, width, need_normal)
  9.     brackets_width = self.contents.text_size("[]").width
  10.     if battler.is_a?(Game_Actor)
  11.       text = []
  12.       txt = ""
  13.       if battler.states != []
  14.         txt_1 = "回合后,"
  15.         txt_2 = "% 几率解除。"
  16.         for i in battler.states_turn.keys.clone
  17.           if $data_states[i].rating >= 1
  18.             txt = $data_states[i].name
  19.             txt = "[" + txt + "]  " + battler.states_turn[i].to_s + txt_1
  20.             txt = txt + $data_states[i].auto_release_prob.to_s + txt_2
  21.             text.push(txt)
  22.           end
  23.         end
  24.       end
  25.       if text == []
  26.         if need_normal
  27.           text.push("[正常]")
  28.         end
  29.       end
  30.     else
  31.       text = ""
  32.       for i in battler.states
  33.         if $data_states[i].rating >= 1
  34.           if text == ""
  35.             text = $data_states[i].name
  36.           else
  37.             new_text = text + "/" + $data_states[i].name
  38.             text_width = self.contents.text_size(new_text).width
  39.             if text_width > width - brackets_width
  40.               break
  41.             end
  42.             text = new_text
  43.           end
  44.         end
  45.       end
  46.       # 状态名空的字符串是 "[正常]" 的情况下
  47.       if text == ""
  48.         if need_normal
  49.           text = "[正常]"
  50.         end
  51.       else
  52.         # 加上括号
  53.         text = "[" + text + "]"
  54.       end
  55.     end
  56.     return text
  57.   end
  58.   #--------------------------------------------------------------------------
  59.   def draw_actor_state(actor, x, y, width = 120)
  60.     text = make_battler_state_text(actor, width, true)
  61.     self.contents.font.size = 16
  62.     self.contents.font.color = actor.hp == 0 ? knockout_color : normal_color
  63.     for i in 0...text.size
  64.       txt = text[i]
  65.       y = i * 24 + y
  66.       self.contents.draw_text(x, y, width, 32, txt)
  67.     end
  68.     self.contents.font.size = 22
  69.   end
  70. end
复制代码





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