Project1

标题: 如何做技能树 [打印本页]

作者: giligilieye    时间: 2018-5-25 18:49
标题: 如何做技能树
求大神指导

我想实现一个升一级获得一个技能点,或用变量代替技能点。
用技能点来学习新技能。


作者: Nil2018    时间: 2018-5-25 18:49
本帖最后由 Nil2018 于 2018-5-26 11:58 编辑

https://rpg.blue/thread-405153-1-1.html

https://forums.rpgmakerweb.com/i ... d-skill-tree.25423/
lune无限技能树,你不会下demo可以私信我要。

tomo技能树:
RUBY 代码复制
  1. # スキルツリーシステムver1.02
  2. # 制作者:TOMO
  3. #
  4. # ツリー型のスキル習得システムです
  5. #
  6. #
  7. # ※使用方法
  8. # 1.スキルツリー画面の呼び出し
  9. # SceneManager.call(Scene_SkillTree)
  10. #
  11. # 2.スキルポイントの追加
  12. # $game_actors[n].add_skill_point(m)
  13. # (nはアクターID、mは追加ポイント)
  14. #
  15. #
  16. # ※補足
  17. # Skillの武器タイプIDは、特徴の「武器タイプ装備」に対応しています
  18. #
  19. # リストに追加したい場合は、
  20. # 対応する武器タイプを装備可能な状態にして下さい
  21.  
  22. # ※更新履歴
  23. # ver1.02
  24. #   習得済みスキルの強調表示
  25. #   線の自動生成で合流時に重なるミスを修正
  26. #
  27. # ver1.01
  28. #   スキルポイントが正常加算されないバグ修正
  29. #   習得確認ウィンドウの追加
  30. #   コストウィンドウの表記変更
  31.  
  32. module TOMO
  33.   module SkillTree
  34.     Skill = {}  # 弄るな!
  35.  
  36.     # スキル名の表示
  37.     Name = true
  38.     # スキル名表示時の横幅
  39.     Width = 144
  40.     # 習得済みスキル用アイコンID
  41.     LearnedIcon = 125
  42.  
  43.     # 各種用語
  44.     SPText = "SP"
  45.     CostText = "消費SP:"
  46.     PremiseText = "前提:"
  47.  
  48.  
  49.     DefaultPoint = 1    # デフォルトの消費スキルポイント
  50.     Point = "2 + level" # スキルポイントの計算式
  51.  
  52.  
  53.     # ツリーデータの設定
  54.     # Skill[武器タイプID] = {
  55.     #   :tree => [[1行目],[2行目],…],
  56.     #   スキルID => {"派生" => [派生先のスキルID],
  57.     #              "前提" => [習得前提スキルID],
  58.     #              "SP" => 習得に必要なポイント,
  59.     #              "反転" => [線を逆にしたい派生先スキルID],}
  60.     # }
  61.     #
  62.     # :tree内で0を指定した場合は、そこを飛ばして表示します
  63.     # "派生"を省略した場合は、線が引かれません
  64.     # "前提"を省略した場合は、ポイント消費だけで習得可能です
  65.     # "SP"を省略した場合は、DefaultPointを参照します
  66.     # "反転"を省略した場合は、線は通常通りです("派生"に無いIDは無効)
  67.     Skill[1] = {
  68.       # ツリー
  69.       :tree => [[0,80],
  70.                 [81,0,82,24],
  71.                 [0,83],
  72.                 [0,84]],
  73.       80 => {"派生" => [81, 82, 24]},
  74.       81 => {"前提" => [80], "派生" => [83]},
  75.       82 => {"前提" => [80], "派生" => [83]},
  76.       83 => {"前提" => [81, 82], "派生" => [84], "SP" => 3},
  77.       84 => {"前提" => [83, 24], "SP" => 5},
  78.       24 => {"前提" => [80], "派生" => [84], "反転" => [84]},
  79.     }
  80.   end
  81. end
  82.  
  83. class Game_Actor
  84.   attr_accessor   :used_skill_point # 使用済みスキルポイント
  85.   #--------------------------------------------------------------------------
  86.   # ● セットアップ
  87.   #--------------------------------------------------------------------------
  88.   alias tomo_skill_tree_setup setup
  89.   def setup(actor_id)
  90.     @skill_point = 0
  91.     @used_skill_point = 0
  92.     tomo_skill_tree_setup(actor_id)
  93.   end
  94.   #--------------------------------------------------------------------------
  95.   # ● スキルポイントの取得
  96.   #--------------------------------------------------------------------------
  97.   def skill_point
  98.     eval(TOMO::SkillTree::Point) + @skill_point - @used_skill_point
  99.   end
  100.   #--------------------------------------------------------------------------
  101.   # ● スキルポイントの追加
  102.   #--------------------------------------------------------------------------
  103.   def add_skill_point(value)
  104.     @skill_point += value
  105.   end
  106. end
  107.  
  108. class Window_SkillTreeTypes < Window_Command
  109.   attr_reader     :tree_window
  110.   #--------------------------------------------------------------------------
  111.   # ● オブジェクト初期化
  112.   #--------------------------------------------------------------------------
  113.   def initialize(x, y)
  114.     super(x, y)
  115.     @actor = nil
  116.     select(0)
  117.   end
  118.   #--------------------------------------------------------------------------
  119.   # ● ウィンドウ幅の取得
  120.   #--------------------------------------------------------------------------
  121.   def window_width
  122.     return 172
  123.   end
  124.   #--------------------------------------------------------------------------
  125.   # ● 表示行数の取得
  126.   #--------------------------------------------------------------------------
  127.   def visible_line_number
  128.     return 4
  129.   end
  130.   #--------------------------------------------------------------------------
  131.   # ● アクターの設定
  132.   #--------------------------------------------------------------------------
  133.   def actor=(actor)
  134.     return if @actor == actor
  135.     @actor = actor
  136.     refresh
  137.     select(0)
  138.   end
  139.   #--------------------------------------------------------------------------
  140.   # ● コマンドリストの作成
  141.   #--------------------------------------------------------------------------
  142.   def make_command_list
  143.     if @actor
  144.       $data_system.weapon_types.size.times do |wtype|
  145.         if TOMO::SkillTree::Skill[wtype] && @actor.equip_wtype_ok?(wtype)
  146.           name = $data_system.weapon_types[wtype]
  147.           add_command(name, :tree_type, true, wtype)
  148.         end
  149.       end
  150.     end
  151.   end
  152.   #--------------------------------------------------------------------------
  153.   # ● フレーム更新
  154.   #--------------------------------------------------------------------------
  155.   def update
  156.     super
  157.     @tree_window.tree_type = current_ext if @tree_window
  158.   end
  159.   #--------------------------------------------------------------------------
  160.   # ● スキルツリーウィンドウの設定
  161.   #--------------------------------------------------------------------------
  162.   def tree_window=(tree_window)
  163.     @tree_window = tree_window
  164.   end
  165. end
  166.  
  167. class Window_SkillTree < Window_Selectable
  168.   attr_reader     :cost_window
  169.   #--------------------------------------------------------------------------
  170.   # ● オブジェクト初期化
  171.   #--------------------------------------------------------------------------
  172.   def initialize(x, y)
  173.     super(x, y, Graphics.width - x, Graphics.height - y - fitting_height(3))
  174.     @actor = nil
  175.     @tree_type = 0
  176.     deactivate
  177.   end
  178.   #--------------------------------------------------------------------------
  179.   # ● スキルツリーのセットを取得
  180.   #--------------------------------------------------------------------------
  181.   def tree
  182.     TOMO::SkillTree::Skill[@tree_type]
  183.   end
  184.   #--------------------------------------------------------------------------
  185.   # ● 項目数の取得
  186.   #--------------------------------------------------------------------------
  187.   def item_max
  188.     col_max * row_max
  189.   end
  190.   #--------------------------------------------------------------------------
  191.   # ● 横に項目が並ぶときの空白の幅を取得
  192.   #--------------------------------------------------------------------------
  193.   def spacing
  194.     return 0
  195.   end
  196.   #--------------------------------------------------------------------------
  197.   # ● 桁数の取得
  198.   #--------------------------------------------------------------------------
  199.   def col_max
  200.     tree && tree[:tree] ? tree[:tree].collect{|row| row.size }.max : 1
  201.   end
  202.   #--------------------------------------------------------------------------
  203.   # ● 行数の取得
  204.   #--------------------------------------------------------------------------
  205.   def row_max
  206.     tree && tree[:tree] ? tree[:tree].size : 1
  207.   end
  208.   #--------------------------------------------------------------------------
  209.   # ● 項目の幅を取得
  210.   #--------------------------------------------------------------------------
  211.   def item_width
  212.     TOMO::SkillTree::Name ? TOMO::SkillTree::Width : 24
  213.   end
  214.   #--------------------------------------------------------------------------
  215.   # ● ウィンドウ内容の幅を計算
  216.   #--------------------------------------------------------------------------
  217.   def contents_width
  218.     item_width * col_max
  219.   end
  220.   #--------------------------------------------------------------------------
  221.   # ● ウィンドウ内容の高さを計算
  222.   #--------------------------------------------------------------------------
  223.   def contents_height
  224.     item_height * (row_max * 2 - 1)
  225.   end
  226.   #--------------------------------------------------------------------------
  227.   # ● 項目を描画する矩形の取得
  228.   #--------------------------------------------------------------------------
  229.   def item_rect(index)
  230.     rect = Rect.new
  231.     rect.width = item_width
  232.     rect.height = item_height
  233.     rect.x = index % col_max * (item_width + spacing)
  234.     rect.y = index / col_max * 2 * item_height
  235.     rect
  236.   end
  237.   #--------------------------------------------------------------------------
  238.   # ● カーソル位置が画面内になるようにスクロール
  239.   #--------------------------------------------------------------------------
  240.   def ensure_cursor_visible
  241.     super
  242.     if (index % col_max + 1) * item_width > width - standard_padding * 2
  243.       self.ox = (index % col_max - 1) * item_width
  244.     else
  245.       self.ox = 0
  246.     end
  247.   end
  248.   #--------------------------------------------------------------------------
  249.   # ● カーソルを右に移動
  250.   #--------------------------------------------------------------------------
  251.   def cursor_right(wrap = false)
  252.     if col_max >= 2 && index % col_max < col_max - 1
  253.       select((index + 1) % item_max)
  254.     end
  255.   end
  256.   #--------------------------------------------------------------------------
  257.   # ● カーソルを左に移動
  258.   #--------------------------------------------------------------------------
  259.   def cursor_left(wrap = false)
  260.     if col_max >= 2 && index % col_max > 0
  261.       select((index - 1 + item_max) % item_max)
  262.     end
  263.   end
  264.   #--------------------------------------------------------------------------
  265.   # ● アクターの設定
  266.   #--------------------------------------------------------------------------
  267.   def actor=(actor)
  268.     return if @actor == actor
  269.     @actor = actor
  270.   end
  271.   #--------------------------------------------------------------------------
  272.   # ● スキルツリータイプの設定
  273.   #--------------------------------------------------------------------------
  274.   def tree_type=(type)
  275.     return if @tree_type == type
  276.     @tree_type = type
  277.     refresh
  278.   end
  279.   #--------------------------------------------------------------------------
  280.   # ● 選択項目のスキルIDを取得
  281.   #--------------------------------------------------------------------------
  282.   def skill_id
  283.     id = tree[:tree][index / col_max][index % col_max] if tree && tree[:tree]
  284.     id = 0 unless id
  285.     id
  286.   end
  287.   #--------------------------------------------------------------------------
  288.   # ● 選択項目のスキルポイントを取得
  289.   #--------------------------------------------------------------------------
  290.   def sp
  291.     tree[skill_id]["SP"] ? tree[skill_id]["SP"] : TOMO::SkillTree::DefaultPoint
  292.   end
  293.   #--------------------------------------------------------------------------
  294.   # ● スキルが習得済みか?
  295.   #--------------------------------------------------------------------------
  296.   def learned?(skill)
  297.     @actor && @actor.skill_learn?(skill)
  298.   end
  299.   #--------------------------------------------------------------------------
  300.   # ● スキルが習得可能か?
  301.   #--------------------------------------------------------------------------
  302.   def learn_ok?(skill)
  303.     point = TOMO::SkillTree::DefaultPoint
  304.     point = tree[skill.id]["SP"] if tree[skill.id]["SP"]
  305.     @actor && !@actor.skill_learn?(skill) &&
  306.     @actor.skill_point >= point && (tree[skill.id]["前提"] ?
  307.     tree[skill.id]["前提"].all?{|id|learned?($data_skills[id])} : true)
  308.   end
  309.   #--------------------------------------------------------------------------
  310.   # ● 選択項目の有効状態を取得
  311.   #--------------------------------------------------------------------------
  312.   def current_item_enabled?
  313.     return false unless @actor
  314.     return false unless tree
  315.     skill = $data_skills[skill_id]
  316.     return false unless skill
  317.     return learn_ok?(skill)
  318.   end
  319.   #--------------------------------------------------------------------------
  320.   # ● スキルを許可状態で表示するかどうか
  321.   #--------------------------------------------------------------------------
  322.   def enable?(skill)
  323.     return false unless @actor
  324.     return false unless tree
  325.     return learned?(skill) || learn_ok?(skill)
  326.   end
  327.   #--------------------------------------------------------------------------
  328.   # ● 項目の描画
  329.   #--------------------------------------------------------------------------
  330.   def draw_item(index)
  331.     rect = item_rect_for_text(index)
  332.     if tree && tree[:tree]
  333.       skill_id = tree[:tree][index / col_max][index % col_max]
  334.       if skill_id && skill_id > 0
  335.         skill = $data_skills[skill_id]
  336.         if TOMO::SkillTree::Name
  337.           draw_item_name(skill, rect.x, rect.y, enable?(skill), rect.width - 24)
  338.         else
  339.           draw_icon(skill.icon_index, rect.x, rect.y, enable?(skill))
  340.         end
  341.         if learned?(skill)
  342.           bitmap = Cache.system("Iconset")
  343.           icon_index = TOMO::SkillTree::LearnedIcon
  344.           s_rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
  345.           rect.set(rect.x + 8, rect.y + 8, 16, 16)
  346.           contents.stretch_blt(rect, bitmap, s_rect)
  347.         end
  348.       end
  349.     end
  350.   end
  351.   #--------------------------------------------------------------------------
  352.   # ● 全ての線の描画
  353.   #--------------------------------------------------------------------------
  354.   def draw_lines
  355.     if tree && tree[:tree]
  356.       row_max.size.times do |start_y|
  357.         tree[:tree][start_y].each_with_index do |skill_id, start_x|
  358.           next unless skill_id > 0
  359.           next unless tree[skill_id]["派生"]
  360.           tree[skill_id]["派生"].each do |next_skill|
  361.             tree[:tree].each_with_index do |list, end_y|
  362.               if list.include?(next_skill)
  363.                 end_x = list.index(next_skill)
  364.                 mirror = tree[skill_id]["反転"] &&
  365.                   tree[skill_id]["反転"].include?(next_skill)
  366.                 draw_line(start_x, start_y, end_x, end_y, mirror)
  367.               end
  368.             end
  369.           end
  370.         end
  371.       end
  372.     end
  373.   end
  374.   #--------------------------------------------------------------------------
  375.   # ● 線の描画
  376.   #--------------------------------------------------------------------------
  377.   def draw_line(start_x, start_y, end_x, end_y, mirror = false)
  378.     x1, y1 = start_x * item_width, start_y * item_height * 2
  379.     x2, y2 = end_x * item_width, end_y * item_height * 2
  380.     width, height = item_width / 2, item_height / 2
  381.     x, y = x1 + width - 1, y1 + item_height
  382.     if x1 == x2
  383.       contents.fill_rect(x, y, 2, y2 - y, system_color)
  384.     elsif mirror
  385.       if x2 > x1
  386.         contents.fill_rect(x, y, 2, y2 - y - height - 1, system_color)
  387.         contents.fill_rect(x, y2 - height - 1, x2 - x1 + 2,
  388.         2, system_color)
  389.         contents.fill_rect(x2 + width - 1, y2 - height - 1, 2,
  390.         height + 1, system_color)
  391.       else
  392.         contents.fill_rect(x, y, 2, y2 - y - height - 1, system_color)
  393.         contents.fill_rect(x2 + width - 1, y2 - height - 1,
  394.         x1 - x2 + 2, 2, system_color)
  395.         contents.fill_rect(x2 + width - 1, y2 - height - 1, 2,
  396.         height + 1, system_color)
  397.       end
  398.     elsif x2 > x1
  399.       contents.fill_rect(x, y, 2, height + 1, system_color)
  400.       contents.fill_rect(x, y + height - 1, x2 - x1 + 2, 2, system_color)
  401.       contents.fill_rect(x2 + width - 1, y + height, 2,
  402.       y2 - y - height, system_color)
  403.     else
  404.       contents.fill_rect(x, y, 2, height + 1, system_color)
  405.       contents.fill_rect(x2 + width - 1, y + height - 1,
  406.       x1 - x2 + 2, 2, system_color)
  407.       contents.fill_rect(x2 + width - 1, y + height, 2,
  408.       y2 - y - height, system_color)
  409.     end
  410.   end
  411.   #--------------------------------------------------------------------------
  412.   # ● リフレッシュ
  413.   #--------------------------------------------------------------------------
  414.   def refresh
  415.     contents.clear
  416.     create_contents
  417.     draw_all_items
  418.     draw_lines
  419.   end
  420.   #--------------------------------------------------------------------------
  421.   # ● コストウィンドウの設定
  422.   #--------------------------------------------------------------------------
  423.   def cost_window=(cost_window)
  424.     @cost_window = cost_window
  425.     call_update_help
  426.   end
  427.   #--------------------------------------------------------------------------
  428.   # ● ヘルプテキスト更新
  429.   #--------------------------------------------------------------------------
  430.   def update_help
  431.     @help_window.set_item($data_skills[skill_id]) if skill_id
  432.     if @cost_window
  433.       @cost_window.skill_data = [skill_id, tree[skill_id]] if tree && skill_id
  434.     end
  435.   end
  436. end
  437.  
  438. class Window_SkillTreeStatus < Window_Base
  439.   #--------------------------------------------------------------------------
  440.   # ● オブジェクト初期化
  441.   #--------------------------------------------------------------------------
  442.   def initialize(x, y)
  443.     super(x, y, 172, fitting_height(2))
  444.     @actor = nil
  445.   end
  446.   #--------------------------------------------------------------------------
  447.   # ● アクターの設定
  448.   #--------------------------------------------------------------------------
  449.   def actor=(actor)
  450.     return if @actor == actor
  451.     @actor = actor
  452.     refresh
  453.   end
  454.   #--------------------------------------------------------------------------
  455.   # ● リフレッシュ
  456.   #--------------------------------------------------------------------------
  457.   def refresh
  458.     contents.clear
  459.     if @actor
  460.       draw_actor_name(@actor, 0, 0)
  461.       change_color(system_color)
  462.       rect = Rect.new(0, line_height, contents_width, line_height)
  463.       draw_text(rect, TOMO::SkillTree::SPText)
  464.       change_color(normal_color)
  465.       draw_text(rect, @actor.skill_point, 2)
  466.     end
  467.   end
  468. end
  469.  
  470. class Window_SkillTreeCost < Window_Base
  471.   #--------------------------------------------------------------------------
  472.   # ● オブジェクト初期化
  473.   #--------------------------------------------------------------------------
  474.   def initialize(x, y)
  475.     super(x, y, Graphics.width - x, fitting_height(3))
  476.     @actor = nil
  477.     @skill_data = nil
  478.   end
  479.   #--------------------------------------------------------------------------
  480.   # ● アクターの設定
  481.   #--------------------------------------------------------------------------
  482.   def actor=(actor)
  483.     return if @actor == actor
  484.     @actor = actor
  485.   end
  486.   #--------------------------------------------------------------------------
  487.   # ● スキルデータの設定
  488.   #--------------------------------------------------------------------------
  489.   def skill_data=(skill_data)
  490.     return if @skill_data == skill_data
  491.     @skill_data = skill_data
  492.     refresh
  493.   end
  494.   #--------------------------------------------------------------------------
  495.   # ● リフレッシュ
  496.   #--------------------------------------------------------------------------
  497.   def refresh
  498.     contents.clear
  499.     if @skill_data && @skill_data[1]
  500.       change_color(system_color)
  501.       rect = Rect.new(0, 0, contents_width, line_height)
  502.       if @actor && @actor.skill_learn?($data_skills[@skill_data[0]])
  503.         draw_text(rect, "取得済み")
  504.       else
  505.         draw_text(rect, TOMO::SkillTree::CostText)
  506.         width = text_size(TOMO::SkillTree::CostText).width
  507.         cost = TOMO::SkillTree::DefaultPoint
  508.         cost = @skill_data[1]["SP"] if @skill_data[1]["SP"]
  509.         change_color(normal_color, @actor.skill_point >= cost)
  510.         draw_text(rect.x + width, rect.y, rect.width - width, rect.height, cost)
  511.         change_color(system_color)
  512.         rect.y += line_height
  513.         draw_text(rect, TOMO::SkillTree::PremiseText)
  514.         p_width = text_size(TOMO::SkillTree::PremiseText).width
  515.         width = TOMO::SkillTree::Width
  516.         count = (contents_width - p_width) / width
  517.         if @skill_data[1]["前提"]
  518.           @skill_data[1]["前提"].each_with_index do |skill_id, i|
  519.             x = rect.x + p_width + width * (i % count)
  520.             y = rect.y + line_height * (i / count)
  521.             enabled = @actor.skill_learn?($data_skills[skill_id])
  522.             draw_item_name($data_skills[skill_id], x, y, enabled, width - 24)
  523.           end
  524.         end
  525.       end
  526.     end
  527.   end
  528. end
  529.  
  530. class Window_SkillTreeChoice < Window_Selectable
  531.   #--------------------------------------------------------------------------
  532.   # ● オブジェクト初期化
  533.   #--------------------------------------------------------------------------
  534.   def initialize
  535.     x = (Graphics.width - 360) / 2
  536.     y = (Graphics.height - fitting_height(4)) / 2
  537.     super(x, y, 360, fitting_height(4))
  538.     @actor = nil
  539.     @skill_id = 0
  540.     @cost = 0
  541.     self.openness = 0
  542.     deactivate
  543.   end
  544.   #--------------------------------------------------------------------------
  545.   # ● 桁数の取得
  546.   #--------------------------------------------------------------------------
  547.   def col_max
  548.     return 2
  549.   end
  550.   #--------------------------------------------------------------------------
  551.   # ● 項目数の取得
  552.   #--------------------------------------------------------------------------
  553.   def item_max
  554.     col_max
  555.   end
  556.   #--------------------------------------------------------------------------
  557.   # ● 項目を描画する矩形の取得
  558.   #--------------------------------------------------------------------------
  559.   def item_rect(index)
  560.     rect = Rect.new
  561.     rect.width = item_width
  562.     rect.height = item_height
  563.     rect.x = index % col_max * (item_width + spacing)
  564.     rect.y = (index / col_max + 3) * item_height
  565.     rect
  566.   end
  567.   #--------------------------------------------------------------------------
  568.   # ● 決定ハンドラの呼び出し
  569.   #--------------------------------------------------------------------------
  570.   def call_ok_handler
  571.     handle?(:ok) && index == 1 ? call_handler(:cancel) : super
  572.   end
  573.   #--------------------------------------------------------------------------
  574.   # ● アクターの設定
  575.   #--------------------------------------------------------------------------
  576.   def actor=(actor)
  577.     return if @actor == actor
  578.     @actor = actor
  579.   end
  580.   #--------------------------------------------------------------------------
  581.   # ● スキルの設定
  582.   #--------------------------------------------------------------------------
  583.   def set_skill(skill_id, cost)
  584.     return if @skill_id == skill_id && @cost == cost
  585.     @skill_id = skill_id
  586.     @cost = cost
  587.     refresh
  588.   end
  589.   #--------------------------------------------------------------------------
  590.   # ● 水平線の色を取得
  591.   #--------------------------------------------------------------------------
  592.   def line_color
  593.     color = normal_color
  594.     color.alpha = 48
  595.     color
  596.   end
  597.   #--------------------------------------------------------------------------
  598.   # ● 水平線の描画
  599.   #--------------------------------------------------------------------------
  600.   def draw_horz_line(y)
  601.     line_y = y + line_height / 2 - 1
  602.     contents.fill_rect(0, line_y, contents_width, 2, line_color)
  603.   end
  604.   #--------------------------------------------------------------------------
  605.   # ● リフレッシュ
  606.   #--------------------------------------------------------------------------
  607.   def refresh
  608.     contents.clear
  609.     if @actor && @skill_id && @cost
  610.       draw_item_name($data_skills[@skill_id], 0, 0)
  611.       rect = Rect.new(0, 0, contents_width, line_height)
  612.       draw_text(rect, "を習得しますか?", 2)
  613.       rect.y += line_height
  614.  
  615.       change_color(system_color)
  616.       text = TOMO::SkillTree::SPText + ":"
  617.       draw_text(rect, text)
  618.       rect.width -= text_size(text).width
  619.       rect.x += text_size(text).width
  620.       draw_text(rect, "→", 1)
  621.       change_color(normal_color)
  622.       draw_text(rect, @actor.skill_point - @cost, 2)
  623.       rect.width = rect.width / 2 - 12
  624.       draw_text(rect, @actor.skill_point, 2)
  625.  
  626.       draw_horz_line(line_height * 2)
  627.       draw_text(item_rect_for_text(0), "はい", 1)
  628.       draw_text(item_rect_for_text(1), "いいえ", 1)
  629.     end
  630.   end
  631. end
  632.  
  633.  
  634.  
  635. class Scene_SkillTree < Scene_MenuBase
  636.   #--------------------------------------------------------------------------
  637.   # ● 開始処理
  638.   #--------------------------------------------------------------------------
  639.   def start
  640.     super
  641.     create_help_window
  642.     create_status_window
  643.     create_command_window
  644.     create_tree_window
  645.     create_choice_window
  646.     create_cost_window
  647.   end
  648.   #--------------------------------------------------------------------------
  649.   # ● ステータスウィンドウの作成
  650.   #--------------------------------------------------------------------------
  651.   def create_status_window
  652.     @status_window = Window_SkillTreeStatus.new(0, @help_window.height)
  653.     @status_window.actor = @actor
  654.   end
  655.   #--------------------------------------------------------------------------
  656.   # ● コマンドウィンドウの作成
  657.   #--------------------------------------------------------------------------
  658.   def create_command_window
  659.     wy = @status_window.y + @status_window.height
  660.     @command_window = Window_SkillTreeTypes.new(0, wy)
  661.     @command_window.actor = @actor
  662.     @command_window.set_handler(:ok,       method(:on_type_ok))
  663.     @command_window.set_handler(:cancel,   method(:return_scene))
  664.     @command_window.set_handler(:pagedown, method(:next_actor))
  665.     @command_window.set_handler(:pageup,   method(:prev_actor))
  666.   end
  667.   #--------------------------------------------------------------------------
  668.   # ● ツリーウィンドウの作成
  669.   #--------------------------------------------------------------------------
  670.   def create_tree_window
  671.     wx, wy = @command_window.width, @help_window.height
  672.     @tree_window = Window_SkillTree.new(wx, wy)
  673.     @tree_window.actor = @actor
  674.     @tree_window.tree_type = @command_window.current_ext
  675.     @tree_window.help_window = @help_window
  676.     @tree_window.set_handler(:ok,     method(:on_tree_ok))
  677.     @tree_window.set_handler(:cancel, method(:on_tree_cancel))
  678.     @command_window.tree_window = @tree_window
  679.   end
  680.   #--------------------------------------------------------------------------
  681.   # ● 選択ウィンドウの作成
  682.   #--------------------------------------------------------------------------
  683.   def create_choice_window
  684.     @choice_window = Window_SkillTreeChoice.new
  685.     @choice_window.actor = @actor
  686.     @choice_window.set_handler(:ok,     method(:on_choice_ok))
  687.     @choice_window.set_handler(:cancel, method(:on_choice_cancel))
  688.   end
  689.   #--------------------------------------------------------------------------
  690.   # ● コストウィンドウの作成
  691.   #--------------------------------------------------------------------------
  692.   def create_cost_window
  693.     wy = @tree_window.y + @tree_window.height
  694.     @cost_window = Window_SkillTreeCost.new(0, wy)
  695.     @cost_window.actor = @actor
  696.     @tree_window.cost_window = @cost_window
  697.   end
  698.   #--------------------------------------------------------------------------
  699.   # ● スキルツリータイプ[決定]
  700.   #--------------------------------------------------------------------------
  701.   def on_type_ok
  702.     @tree_window.tree_type = @command_window.current_ext
  703.     @tree_window.activate.select(0)
  704.   end
  705.   #--------------------------------------------------------------------------
  706.   # ● スキルツリー[決定]
  707.   #--------------------------------------------------------------------------
  708.   def on_tree_ok
  709.     @choice_window.set_skill(@tree_window.skill_id, @tree_window.sp)
  710.     @choice_window.open.activate.select(0)
  711.   end
  712.   #--------------------------------------------------------------------------
  713.   # ● スキルツリー[決定]
  714.   #--------------------------------------------------------------------------
  715.   def on_tree_cancel
  716.     @tree_window.unselect
  717.     @command_window.activate
  718.   end
  719.   #--------------------------------------------------------------------------
  720.   # ● 選択[決定]
  721.   #--------------------------------------------------------------------------
  722.   def on_choice_ok
  723.     @actor.used_skill_point += @tree_window.sp
  724.     @actor.learn_skill(@tree_window.skill_id)
  725.     @status_window.refresh
  726.     @cost_window.refresh
  727.     @choice_window.close.deactivate
  728.     @tree_window.activate.refresh
  729.   end
  730.   #--------------------------------------------------------------------------
  731.   # ● 選択[決定]
  732.   #--------------------------------------------------------------------------
  733.   def on_choice_cancel
  734.     @choice_window.close.deactivate
  735.     @tree_window.activate.refresh
  736.   end
  737.   #--------------------------------------------------------------------------
  738.   # ● アクターの切り替え
  739.   #--------------------------------------------------------------------------
  740.   def on_actor_change
  741.     @status_window.actor = @actor
  742.     @command_window.actor = @actor
  743.     @tree_window.actor = @actor
  744.     @tree_window.tree_type = @command_window.current_ext
  745.     @choice_window.actor = @actor
  746.     @cost_window.actor = @actor
  747.     @command_window.activate
  748.   end
  749. end


作者: giligilieye    时间: 2018-5-26 11:27
没人吗?
作者: giligilieye    时间: 2018-5-26 18:12
Nil2018 发表于 2018-5-25 18:49
https://rpg.blue/thread-405153-1-1.html

https://forums.rpgmakerweb.com/index.php?threads/lune-unlim ...

尝试了一下,不知道怎么用,求教!
作者: giligilieye    时间: 2018-5-26 21:50
Nil2018 发表于 2018-5-25 18:49
https://rpg.blue/thread-405153-1-1.html

https://forums.rpgmakerweb.com/index.php?threads/lune-unlim ...

已加群,等待同意。




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