Project1

标题: 关于角色图鉴怎么设置按确定键角色加入队伍的功能 [打印本页]

作者: 罗曼    时间: 2015-2-26 11:40
标题: 关于角色图鉴怎么设置按确定键角色加入队伍的功能

怎么做到这个时候按确定键,娜塔莉加入队伍?
求大神帮帮忙


角色图鉴如下:
  1. #===========================================================================
  2. # 角色圖鑑 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. class Window_CharBook_List < Window_Selectable
  21.   include ICE_CharBook
  22.   #-------------------------------------------------------------------------
  23.   # ● 公開实例变量
  24.   #-------------------------------------------------------------------------
  25.   attr_reader   :status_window
  26.   #-------------------------------------------------------------------------
  27.   # ● 初始化对象
  28.   #-------------------------------------------------------------------------
  29.   def initialize(x, y, width, height)
  30.     super(x, y, width, height)
  31.     @char_id = []
  32.     @data = {}
  33.     $data_actors.each do |x|
  34.       next if x == nil or ICE_CharBook::HIDE_ACTOR_ID.include?(x.id) or ICE_CharBook::HIDE_JOB_ID.include?(x.class_id)
  35.       @char_id.push(x.id)
  36.     end
  37.     @char_id.each do |x|
  38.       @data[$data_actors[x].class_id] = Array.new
  39.     end
  40.     @char_id.each do |x|
  41.       @data[$data_actors[x].class_id].push(x)
  42.     end
  43.     @current_job = nil
  44.   end
  45.   #-------------------------------------------------------------------------
  46.   # ● 取得項目數
  47.   #-------------------------------------------------------------------------
  48.   def item_max
  49.     @n_data ? @n_data.size : 1
  50.   end
  51.   #-------------------------------------------------------------------------
  52.   # ● 取得項目
  53.   #-------------------------------------------------------------------------
  54.   def item
  55.     $game_actors[@n_data[index]]
  56.   end
  57.   #-------------------------------------------------------------------------
  58.   # ● 取得當前職業
  59.   #-------------------------------------------------------------------------
  60.   def get_current_job(current_job)
  61.     @current_job = current_job
  62.     @n_data = @data[current_job]
  63.     refresh
  64.   end
  65.   #--------------------------------------------------------------------------
  66.   # ● 刷新
  67.   #--------------------------------------------------------------------------
  68.   def refresh
  69.     create_contents
  70.     draw_all_items
  71.   end
  72.   #--------------------------------------------------------------------------
  73.   # ● 項目の描画
  74.   #--------------------------------------------------------------------------
  75.   def draw_item(index)
  76.     item = $game_actors[@n_data[index]]
  77.     rect = item_rect(index)
  78.     if $game_switches[1000 + item.id]
  79.       draw_actor_name(item, rect.x, rect.y, width = 112)
  80.     else
  81.       draw_text(rect,"-------",1)
  82.     end
  83.   end
  84.   #--------------------------------------------------------------------------
  85.   # ● 狀態の設定
  86.   #--------------------------------------------------------------------------
  87.   def status_window=(status_window)
  88.     @status_window = status_window
  89.      call_update_help
  90.   end
  91.   #--------------------------------------------------------------------------
  92.   # ● 调用狀態窗口的更新方法
  93.   #--------------------------------------------------------------------------
  94.   def call_update_help
  95.     update_help if active && @status_window
  96.   end
  97.   #--------------------------------------------------------------------------
  98.   # ● 狀態更新
  99.   #--------------------------------------------------------------------------
  100.   def update_help
  101.     @status_window.item = item if @status_window
  102.   end
  103. end
  104. #============================================================================
  105. #============================================================================
  106. class Scene_CharBook < Scene_MenuBase
  107.   #--------------------------------------------------------------------------
  108.   # ● 開始処理
  109.   #--------------------------------------------------------------------------
  110.   def start
  111.     super
  112.     create_category_window
  113.     create_dummy1_window
  114.     create_dummy2_window
  115.     create_status_window
  116.     create_list_window
  117.   end
  118.   #--------------------------------------------------------------------------
  119.   # ● DUMMY1の作成
  120.   #--------------------------------------------------------------------------
  121.   def create_dummy1_window
  122.     wy = @category_window.height
  123.     wh = Graphics.height - wy
  124.     @dummy1_window = Window_Base.new(0, wy, 181, wh)
  125.     @dummy1_window.viewport = @viewport
  126.   end
  127.   #--------------------------------------------------------------------------
  128.   # ● DUMMY2の作成
  129.   #--------------------------------------------------------------------------
  130.   def create_dummy2_window
  131.     wy = @category_window.height
  132.     wh = Graphics.height - wy
  133.     @dummy2_window = Window_Base.new(181, wy, 363, wh)
  134.     @dummy2_window.viewport = @viewport
  135.   end
  136.   #--------------------------------------------------------------------------
  137.   # ● ステータスウィンドウの作成
  138.   #--------------------------------------------------------------------------
  139.   def create_status_window
  140.     wy = @category_window.height
  141.     wh = Graphics.height - wy
  142.     @status_window = Window_CharBook_Status.new(181, wy, 363, wh)
  143.     @status_window.viewport = @viewport
  144.     @status_window.hide
  145.   end
  146.   #--------------------------------------------------------------------------
  147.   # ● アイテムリストウィンドウの作成
  148.   #--------------------------------------------------------------------------
  149.   def create_list_window
  150.     wy = @category_window.height
  151.     wh = Graphics.height - wy
  152.     @list_window = Window_CharBook_List.new(0, wy, 181, wh)
  153.     @list_window.viewport = @viewport
  154.     @list_window.status_window = @status_window
  155.     @list_window.hide
  156.     @list_window.set_handler(:cancel, method(:on_list_cancel))   
  157.   end
  158.   #--------------------------------------------------------------------------
  159.   # ● カテゴリウィンドウの作成
  160.   #--------------------------------------------------------------------------
  161.   def create_category_window
  162.     @category_window = Window_CharBook_Category.new
  163.     @category_window.viewport = @viewport
  164.     @category_window.y = 0
  165.     @category_window.width = Graphics.width
  166.     @category_window.activate
  167.     @category_window.set_handler(:ok,     method(:on_category_ok))
  168.     @category_window.set_handler(:cancel, method(:return_scene))
  169.   end
  170.   #--------------------------------------------------------------------------
  171.   # ● LIST CANCEL
  172.   #--------------------------------------------------------------------------
  173.   def on_list_cancel
  174.     @category_window.activate
  175.     @dummy1_window.show
  176.     @dummy2_window.show
  177.     @list_window.hide
  178.     @status_window.hide
  179.     @status_window.item = nil
  180.   end
  181.   #--------------------------------------------------------------------------
  182.   # ● CATEGORY[決定]
  183.   #--------------------------------------------------------------------------
  184.   def on_category_ok
  185.     @list_window.select(0)
  186.     @list_window.get_current_job(@category_window.current_symbol.to_i)
  187.     @list_window.show.activate
  188.     @status_window.show
  189.   end
  190. end
  191. #===========================================================================
  192. #===========================================================================
  193. class Window_CharBook_Category < Window_HorzCommand
  194.   include ICE_CharBook
  195.   #--------------------------------------------------------------------------
  196.   # ● オブジェクト初期化
  197.   #--------------------------------------------------------------------------
  198.   def initialize
  199.     super(0, 0)
  200.   end
  201.   #-------------------------------------------------------------------------
  202.   # ● 桁数の取得
  203.   #-------------------------------------------------------------------------
  204.   def col_max
  205.     return @job_id.size
  206.   end
  207.   #--------------------------------------------------------------------------
  208.   # ● 获取窗口的宽度
  209.   #--------------------------------------------------------------------------
  210.   def window_width
  211.     return 544
  212.   end
  213.   #-------------------------------------------------------------------------
  214.   # ● LISTの作成
  215.   #-------------------------------------------------------------------------
  216.   def make_command_list
  217.     @job_id = []
  218.     $data_classes.each do |x|
  219.       next if x == nil or ICE_CharBook::HIDE_JOB_ID.include?(x.id)
  220.       @job_id.push(x.id)
  221.     end
  222.     @job_id.each do |i|
  223.       sym = i.to_s
  224.       add_command($data_classes[i].name, sym )
  225.     end
  226.   end
  227. end
  228. #===========================================================================
  229. #===========================================================================
  230. class Window_CharBook_Status < Window_Base
  231.   #--------------------------------------------------------------------------
  232.   # ● オブジェクト初期化
  233.   #--------------------------------------------------------------------------
  234.   def initialize(x, y, width, height)
  235.     super(x, y, width, height)
  236.     @actor = nil
  237.     refresh
  238.   end
  239.   #--------------------------------------------------------------------------
  240.   # ● リフレッシュ
  241.   #--------------------------------------------------------------------------
  242.   def refresh
  243.     contents.clear
  244.     if @actor != nil
  245.       if $game_switches[1000 + @actor.id]
  246.         draw_block1   (line_height * 0)

  247.         draw_horz_line(line_height * 5)
  248.         draw_block2   (line_height * 7)
  249.       else
  250.         draw_text(0, 0, 181, 200, ICE_CharBook::NONE)
  251.       end
  252.     end
  253.   end

  254.   #--------------------------------------------------------------------------
  255.   # ● アイテムの設定
  256.   #--------------------------------------------------------------------------
  257.   def item=(item)
  258.     @actor = item
  259.     refresh
  260.   end
  261.   #--------------------------------------------------------------------------
  262.   # ● 繪畫BLOCK 1
  263.   #--------------------------------------------------------------------------
  264.   def draw_block1(y)
  265.     draw_actor_face(@actor, 8, y)
  266.     draw_actor_level(@actor, 248, y + line_height * 0)
  267.     draw_actor_icons(@actor, 8, y + line_height * 3)
  268.     draw_actor_name(@actor, 136, y + line_height * 0)
  269.     draw_actor_class(@actor, 136, y + line_height * 1)
  270.     draw_actor_nickname(@actor, 136, y + line_height * 2)
  271.     draw_actor_exp(@actor, 136, y + line_height * 3)
  272.     draw_actor_hp(@actor, 32, y + line_height * 4)
  273.     draw_actor_mp(@actor, 181, y + line_height * 4)
  274.   end
  275.   #--------------------------------------------------------------------------
  276.   # ● 繪畫BLOCK 2
  277.   #--------------------------------------------------------------------------
  278.   def draw_block2(y)
  279.    
  280.     draw_actor_param(@actor, 64, y + line_height * 0, 2)
  281.     draw_actor_param(@actor, 104, y + line_height * 1, 3)
  282.     draw_actor_param(@actor, 64, y + line_height * 2, 4)
  283.     draw_actor_param(@actor, 104, y + line_height * 3, 5)
  284.     draw_actor_param(@actor, 64, y + line_height * 4, 6)
  285.     draw_actor_param(@actor, 104, y + line_height * 5, 7)
  286.   end
  287.   #--------------------------------------------------------------------------
  288.   # ● 水平線繪畫
  289.   #--------------------------------------------------------------------------
  290.   def draw_horz_line(y)
  291.     line_y = y + line_height / 2 - 1
  292.     contents.fill_rect(0, line_y, contents_width, 2, line_color)
  293.   end
  294.   #--------------------------------------------------------------------------
  295.   # ● 水平線の色を取得
  296.   #--------------------------------------------------------------------------
  297.   def line_color
  298.     color = normal_color
  299.     color.alpha = 48
  300.     color
  301.   end
  302.   #--------------------------------------------------------------------------
  303.   # ● EXP 繪畫
  304.   #--------------------------------------------------------------------------
  305.   def draw_actor_exp(actor, x, y, width = 124)
  306.     draw_gauge(x, y, width, actor.exp.to_f / actor.next_level_exp,
  307.       text_color(28), text_color(29))
  308.     change_color(system_color)
  309.     draw_text(x, y, 30, line_height, ICE_CharBook::EXP)
  310.     draw_current_and_max_values(x, y, width, actor.exp, actor.next_level_exp,
  311.       exp_color(actor), normal_color)
  312.   end
  313.   def exp_color(actor)
  314.       return normal_color
  315.   end
  316. end
复制代码





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