Project1

标题: 角色圖鑑ver.1.0 [打印本页]

作者: 冰鎮史萊姆    时间: 2013-8-13 20:17
标题: 角色圖鑑ver.1.0
本帖最后由 冰鎮史萊姆 于 2013-8-13 20:21 编辑

可以看到現時角色資訊的圖鑑
PS 有用就拿去吧



RUBY 代码复制
  1. #===========================================================================
  2. # [VA]角色圖鑑 ver.1.0                                           by 冰鎮史萊姆
  3. #===========================================================================
  4. =begin
  5. 使用方法:
  6. 開啟角色 $game_switches[x] = true x為角色id+1000
  7. 例 開啟角色id 1號 $game_switches[1001] = true
  8. HIDE_ACTOR_ID 為不出現在圖鑑中的角色ID
  9. HIDE_JOB_ID 為不出現在圖鑑中的職業ID
  10. NONE 為未開啟圖鑑中的角色時顯示
  11. EXP 為EXP的名稱
  12. 開圖鑑用 SceneManager.call(Scene_CharBook)
  13. =end
  14. module ICE_CharBook
  15.   HIDE_ACTOR_ID = []
  16.   HIDE_JOB_ID = [6, 7, 8, 9, 10]
  17.   NONE = "甚麼也沒有"
  18.   EXP = "EXP"
  19. end
  20.  
  21.  
  22. class Window_CharBook_List < Window_Selectable
  23.   include ICE_CharBook
  24.   #-------------------------------------------------------------------------
  25.   # ● 公開实例变量
  26.   #-------------------------------------------------------------------------
  27.   attr_reader   :status_window
  28.   #-------------------------------------------------------------------------
  29.   # ● 初始化对象
  30.   #-------------------------------------------------------------------------
  31.   def initialize(x, y, width, height)
  32.     super(x, y, width, height)
  33.     @char_id = []
  34.     @data = {}
  35.     $data_actors.each do |x|
  36.       next if x == nil or ICE_CharBook::HIDE_ACTOR_ID.include?(x.id) or ICE_CharBook::HIDE_JOB_ID.include?(x.class_id)
  37.       @char_id.push(x.id)
  38.     end
  39.     @char_id.each do |x|
  40.       @data[$data_actors[x].class_id] = Array.new
  41.     end
  42.     @char_id.each do |x|
  43.       @data[$data_actors[x].class_id].push(x)
  44.     end
  45.     @current_job = nil
  46.   end
  47.   #-------------------------------------------------------------------------
  48.   # ● 取得項目數
  49.   #-------------------------------------------------------------------------
  50.   def item_max
  51.     @n_data ? @n_data.size : 1
  52.   end
  53.   #-------------------------------------------------------------------------
  54.   # ● 取得項目
  55.   #-------------------------------------------------------------------------
  56.   def item
  57.     $game_actors[@n_data[index]]
  58.   end
  59.   #-------------------------------------------------------------------------
  60.   # ● 取得當前職業
  61.   #-------------------------------------------------------------------------
  62.   def get_current_job(current_job)
  63.     @current_job = current_job
  64.     @n_data = @data[current_job]
  65.     refresh
  66.   end
  67.   #--------------------------------------------------------------------------
  68.   # ● 刷新
  69.   #--------------------------------------------------------------------------
  70.   def refresh
  71.     create_contents
  72.     draw_all_items
  73.   end
  74.   #--------------------------------------------------------------------------
  75.   # ● 項目の描画
  76.   #--------------------------------------------------------------------------
  77.   def draw_item(index)
  78.     item = $game_actors[@n_data[index]]
  79.     rect = item_rect(index)
  80.     if $game_switches[1000 + item.id]
  81.       draw_actor_name(item, rect.x, rect.y, width = 112)
  82.     else
  83.       draw_text(rect,"-------",1)
  84.     end
  85.   end
  86.   #--------------------------------------------------------------------------
  87.   # ● 狀態の設定
  88.   #--------------------------------------------------------------------------
  89.   def status_window=(status_window)
  90.     @status_window = status_window
  91.      call_update_help
  92.   end
  93.   #--------------------------------------------------------------------------
  94.   # ● 调用狀態窗口的更新方法
  95.   #--------------------------------------------------------------------------
  96.   def call_update_help
  97.     update_help if active && @status_window
  98.   end
  99.   #--------------------------------------------------------------------------
  100.   # ● 狀態更新
  101.   #--------------------------------------------------------------------------
  102.   def update_help
  103.     @status_window.item = item if @status_window
  104.   end
  105. end
  106. #============================================================================
  107. #============================================================================
  108. class Scene_CharBook < Scene_MenuBase
  109.   #--------------------------------------------------------------------------
  110.   # ● 開始処理
  111.   #--------------------------------------------------------------------------
  112.   def start
  113.     super
  114.     create_category_window
  115.     create_dummy1_window
  116.     create_dummy2_window
  117.     create_status_window
  118.     create_list_window
  119.   end
  120.   #--------------------------------------------------------------------------
  121.   # ● DUMMY1の作成
  122.   #--------------------------------------------------------------------------
  123.   def create_dummy1_window
  124.     wy = @category_window.height
  125.     wh = Graphics.height - wy
  126.     @dummy1_window = Window_Base.new(0, wy, 181, wh)
  127.     @dummy1_window.viewport = @viewport
  128.   end
  129.   #--------------------------------------------------------------------------
  130.   # ● DUMMY2の作成
  131.   #--------------------------------------------------------------------------
  132.   def create_dummy2_window
  133.     wy = @category_window.height
  134.     wh = Graphics.height - wy
  135.     @dummy2_window = Window_Base.new(181, wy, 363, wh)
  136.     @dummy2_window.viewport = @viewport
  137.   end
  138.   #--------------------------------------------------------------------------
  139.   # ● ステータスウィンドウの作成
  140.   #--------------------------------------------------------------------------
  141.   def create_status_window
  142.     wy = @category_window.height
  143.     wh = Graphics.height - wy
  144.     @status_window = Window_CharBook_Status.new(181, wy, 363, wh)
  145.     @status_window.viewport = @viewport
  146.     @status_window.hide
  147.   end
  148.   #--------------------------------------------------------------------------
  149.   # ● アイテムリストウィンドウの作成
  150.   #--------------------------------------------------------------------------
  151.   def create_list_window
  152.     wy = @category_window.height
  153.     wh = Graphics.height - wy
  154.     @list_window = Window_CharBook_List.new(0, wy, 181, wh)
  155.     @list_window.viewport = @viewport
  156.     @list_window.status_window = @status_window
  157.     @list_window.hide
  158.     @list_window.set_handler(:cancel, method(:on_list_cancel))   
  159.   end
  160.   #--------------------------------------------------------------------------
  161.   # ● カテゴリウィンドウの作成
  162.   #--------------------------------------------------------------------------
  163.   def create_category_window
  164.     @category_window = Window_CharBook_Category.new
  165.     @category_window.viewport = @viewport
  166.     @category_window.y = 0
  167.     @category_window.width = Graphics.width
  168.     @category_window.activate
  169.     @category_window.set_handler(:ok,     method(:on_category_ok))
  170.     @category_window.set_handler(:cancel, method(:return_scene))
  171.   end
  172.   #--------------------------------------------------------------------------
  173.   # ● LIST CANCEL
  174.   #--------------------------------------------------------------------------
  175.   def on_list_cancel
  176.     @category_window.activate
  177.     @dummy1_window.show
  178.     @dummy2_window.show
  179.     @list_window.hide
  180.     @status_window.hide
  181.     @status_window.item = nil
  182.   end
  183.   #--------------------------------------------------------------------------
  184.   # ● CATEGORY[決定]
  185.   #--------------------------------------------------------------------------
  186.   def on_category_ok
  187.     @list_window.select(0)
  188.     @list_window.get_current_job(@category_window.current_symbol.to_i)
  189.     @list_window.show.activate
  190.     @status_window.show
  191.   end
  192. end
  193. #===========================================================================
  194. #===========================================================================
  195. class Window_CharBook_Category < Window_HorzCommand
  196.   include ICE_CharBook
  197.   #--------------------------------------------------------------------------
  198.   # ● 初始化对象
  199.   #--------------------------------------------------------------------------
  200.   def initialize
  201.     super(0, 0)
  202.   end
  203.   #-------------------------------------------------------------------------
  204.   # ● 桁数の取得
  205.   #-------------------------------------------------------------------------
  206.   def col_max
  207.     return @job_id.size
  208.   end
  209.   #--------------------------------------------------------------------------
  210.   # ● 获取窗口的宽度
  211.   #--------------------------------------------------------------------------
  212.   def window_width
  213.     return 544
  214.   end
  215.   #-------------------------------------------------------------------------
  216.   # ● LISTの作成
  217.   #-------------------------------------------------------------------------
  218.   def make_command_list
  219.     @job_id = []
  220.     $data_classes.each do |x|
  221.       next if x == nil or ICE_CharBook::HIDE_JOB_ID.include?(x.id)
  222.       @job_id.push(x.id)
  223.     end
  224.     @job_id.each do |i|
  225.       sym = i.to_s
  226.       add_command($data_classes[i].name, sym )
  227.     end
  228.   end
  229. end
  230. #===========================================================================
  231. #===========================================================================
  232. class Window_CharBook_Status < Window_Base
  233.   #--------------------------------------------------------------------------
  234.   # ● 初始化对象
  235.   #--------------------------------------------------------------------------
  236.   def initialize(x, y, width, height)
  237.     super(x, y, width, height)
  238.     [url=home.php?mod=space&uid=95897]@actor[/url] = nil
  239.     refresh
  240.   end
  241.   #--------------------------------------------------------------------------
  242.   # ● 刷新
  243.   #--------------------------------------------------------------------------
  244.   def refresh
  245.     contents.clear
  246.     if [url=home.php?mod=space&uid=95897]@actor[/url] != nil
  247.       if $game_switches[1000 + @actor.id]
  248.         draw_block1   (line_height * 0)
  249.         draw_horz_line(line_height * 5)
  250.         draw_block2   (line_height * 7)
  251.       else
  252.         draw_text(0, 0, 181, 200, ICE_CharBook::NONE)
  253.       end
  254.     end
  255.   end
  256.  
  257.   #--------------------------------------------------------------------------
  258.   # ● アイテムの設定
  259.   #--------------------------------------------------------------------------
  260.   def item=(item)
  261.     @actor = item
  262.     refresh
  263.   end
  264.   #--------------------------------------------------------------------------
  265.   # ● 繪畫BLOCK 1
  266.   #--------------------------------------------------------------------------
  267.   def draw_block1(y)
  268.     draw_actor_face(@actor, 8, y)
  269.     draw_actor_level(@actor, 248, y + line_height * 0)
  270.     draw_actor_icons(@actor, 8, y + line_height * 3)
  271.     draw_actor_name(@actor, 136, y + line_height * 0)
  272.     draw_actor_class(@actor, 136, y + line_height * 1)
  273.     draw_actor_nickname(@actor, 136, y + line_height * 2)
  274.     draw_actor_exp(@actor, 136, y + line_height * 3)
  275.     draw_actor_hp(@actor, 32, y + line_height * 4)
  276.     draw_actor_mp(@actor, 181, y + line_height * 4)
  277.   end
  278.   #--------------------------------------------------------------------------
  279.   # ● 繪畫BLOCK 2
  280.   #--------------------------------------------------------------------------
  281.   def draw_block2(y)
  282.  
  283.     draw_actor_param(@actor, 64, y + line_height * 0, 2)
  284.     draw_actor_param(@actor, 104, y + line_height * 1, 3)
  285.     draw_actor_param(@actor, 64, y + line_height * 2, 4)
  286.     draw_actor_param(@actor, 104, y + line_height * 3, 5)
  287.     draw_actor_param(@actor, 64, y + line_height * 4, 6)
  288.     draw_actor_param(@actor, 104, y + line_height * 5, 7)
  289.   end
  290.   #--------------------------------------------------------------------------
  291.   # ● 水平線繪畫
  292.   #--------------------------------------------------------------------------
  293.   def draw_horz_line(y)
  294.     line_y = y + line_height / 2 - 1
  295.     contents.fill_rect(0, line_y, contents_width, 2, line_color)
  296.   end
  297.   #--------------------------------------------------------------------------
  298.   # ● 水平線の色を取得
  299.   #--------------------------------------------------------------------------
  300.   def line_color
  301.     color = normal_color
  302.     color.alpha = 48
  303.     color
  304.   end
  305.   #--------------------------------------------------------------------------
  306.   # ● EXP 繪畫
  307.   #--------------------------------------------------------------------------
  308.   def draw_actor_exp(actor, x, y, width = 124)
  309.     draw_gauge(x, y, width, actor.exp.to_f / actor.next_level_exp,
  310.       text_color(28), text_color(29))
  311.     change_color(system_color)
  312.     draw_text(x, y, 30, line_height, ICE_CharBook::EXP)
  313.     draw_current_and_max_values(x, y, width, actor.exp, actor.next_level_exp,
  314.       exp_color(actor), normal_color)
  315.   end
  316.   def exp_color(actor)
  317.       return normal_color
  318.   end
  319. end


範例
角色图鉴 1.0.rar (303.92 KB, 下载次数: 104)
只收1元 求給糖   
作者: 黄濑凉太    时间: 2013-8-13 21:02
貌似是为了完成某个提问区里的人发的问题把?
作者: 我在孤岛等你    时间: 2013-8-13 21:39
不错不错!
作者: 我在孤岛等你    时间: 2013-8-13 21:40
还可以。
作者: z2z4    时间: 2013-8-14 10:37
居然有日文 也算原创  - -
作者: 布里蓝    时间: 2013-8-14 10:44
z2z4 发表于 2013-8-14 10:37
居然有日文 也算原创  - -

窗口描画这些懒得打而直接复制默认脚本里的也算原创吧……
作者: xggzga117    时间: 2013-8-16 09:37
好东西,收下了。




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