Project1

标题: 横版战斗怎么让数据库的战斗图也插入 [打印本页]

作者: 傻,死呆子    时间: 2016-11-20 13:06
标题: 横版战斗怎么让数据库的战斗图也插入
数据库的角色脸谱用来战斗,数据库的战斗图插入到状态

360截图.png (434.04 KB, 下载次数: 15)

360截图.png

作者: j296196585    时间: 2016-12-5 21:10
RUBY 代码复制
  1. # ————————————————————————————————————
  2. # 本脚本来自[url]www.66rpg.com[/url],转载请保留此信息
  3. # ————————————————————————————————————
  4. #==============================================================================
  5. # ■ Game_Actor
  6. #------------------------------------------------------------------------------
  7. #  处理角色的类。本类在 Game_Actors 类 ($game_actors)
  8. # 的内部使用、Game_Party 类请参考 ($game_party) 。
  9. #==============================================================================
  10. class Game_Actor < Game_Battler
  11.   #--------------------------------------------------------------------------
  12.   # ● 取得战斗画面的 X 坐标
  13.   #--------------------------------------------------------------------------
  14.   def screen_x
  15. case $game_party.actors.size  #判断当前出战的总人数
  16. when 1                       #判断当前出战的总人数为1
  17. case self.index
  18. when 0                        #1号角色
  19.    return 455               
  20. else
  21.    return 640
  22. end
  23.   #出战人数为2
  24. when 2
  25. case self.index
  26. when 0 #1号角色
  27.    return 435
  28. when 1 #2号角色
  29.    return 515
  30. else
  31.    return 640
  32. end
  33.   #出战人数为3
  34. when 3
  35. case self.index
  36. when 0 #1号角色
  37.    return 395
  38. when 1 #2号角色
  39.    return 505
  40. when 2 #3号角色
  41.    return 515
  42. else
  43.    return 640
  44.   end
  45.   #出战人数为4
  46. when 4
  47. case self.index
  48. when 0 #1号角色
  49.    return 435
  50. when 1 #2号角色
  51.    return 515
  52. when 2 #3号角色
  53.    return 335
  54. when 3 #4号角色
  55.    return 590
  56. else
  57.    return 640
  58.   end
  59. end
  60.   #--------------------------------------------------------------------------
  61.   # ● 取得战斗画面的 Y 坐标 大是下 小是上
  62.   #--------------------------------------------------------------------------
  63. def screen_y
  64. case $game_party.actors.size  #判断当前出战的总人数
  65. when 1                       #判断当前出战的总人数为1
  66. case self.index
  67. when 0                        #1号角色
  68.    return 485               
  69. else
  70.    return 500
  71. end
  72.   #出战人数为2
  73. when 2
  74. case self.index
  75. when 0 #1号角色
  76.    return 215
  77. when 1 #2号角色
  78.    return 235
  79. else
  80.    return 1000
  81. end
  82.   #出战人数为3
  83. when 3
  84. case self.index
  85. when 0 #1号角色
  86.    return 215
  87. when 1 #2号角色
  88.    return 235
  89. when 2 #3号角色
  90.    return 495
  91. else
  92.    return 600
  93.   end
  94.   #出战人数为4
  95. when 4
  96. case self.index
  97. when 0 #1号角色
  98.    return 215
  99. when 1 #2号角色
  100.    return 235
  101. when 2 #3号角色
  102.    return 375
  103. when 3 #4号角色
  104.    return 240
  105. else
  106.    return 1000
  107.   end
  108. end
  109.   #--------------------------------------------------------------------------
  110.   # ● 取得战斗画面的 Z 坐标
  111.   #--------------------------------------------------------------------------
  112.   def screen_z
  113.     case self.index
  114.     when 0
  115.       return 15#10
  116.     when 1
  117.       return 14
  118.     when 2
  119.       return 16
  120.     when 3
  121.       return 13
  122.     else
  123.       return 0
  124.     end
  125.   end
  126. end
  127. end
  128. end
  129. ###################################################
  130. #==============================================================================
  131. # ■ Window_Base
  132. #------------------------------------------------------------------------------
  133. #  游戏中全部窗口的超级类。
  134. #==============================================================================
  135. class Window_Base < Window
  136.   #--------------------------------------------------------------------------
  137.   # ● 描绘 HP
  138.   #     actor : 角色
  139.   #     x     : 描画目标 X 坐标
  140.   #     y     : 描画目标 Y 坐标
  141.   #     width : 描画目标的宽
  142.   #--------------------------------------------------------------------------
  143.   def draw_actor_hp1(actor, x, y, width = 72)
  144.     # 描绘字符串 "HP"
  145.     self.contents.font.color = system_color
  146.     self.contents.draw_text(x, y, 24, 24, $data_system.words.hp)
  147.     # 计算描绘 MaxHP 所需的空间
  148.     if width - 24 >= 32
  149.       hp_x = x + 32# + width - 24
  150.     end
  151.     # 描绘 HP
  152.     self.contents.font.color = actor.hp == 0 ? knockout_color :
  153.       actor.hp <= actor.maxhp / 4 ? crisis_color : normal_color
  154.    # self.contents.font.color = Color.new(255, 225, 198, 255)
  155.  
  156.     self.contents.draw_text(hp_x, y, 32, 24, actor.hp.to_s, 2)
  157.   end
  158.   #--------------------------------------------------------------------------
  159.   # ● 描绘 SP
  160.   #     actor : 角色
  161.   #     x     : 描画目标 X 坐标
  162.   #     y     : 描画目标 Y 坐标
  163.   #     width : 描画目标的宽
  164.   #--------------------------------------------------------------------------
  165.   def draw_actor_sp1(actor, x, y, width = 72)
  166.     # 描绘字符串 "SP"
  167.     self.contents.font.color = system_color
  168.     self.contents.draw_text(x, y, 24, 24, $data_system.words.sp)
  169.     # 计算描绘 MaxSP 所需的空间
  170.     if width - 24 >= 32
  171.       sp_x = x + 32# + width - 24
  172.     end
  173.     # 描绘 SP
  174.     self.contents.font.color = actor.sp == 0 ? knockout_color :
  175.       actor.sp <= actor.maxsp / 4 ? crisis_color : normal_color
  176.    # self.contents.font.color = Color.new(255, 125, 198, 255)
  177.     self.contents.draw_text(sp_x, y, 32, 24, actor.sp.to_s, 2)
  178.   end
  179.     ###########################################################################
  180.   #--------------------------------------------------------------------------
  181.   # ● 战斗时图形的描绘
  182.   #     actor : 角色
  183.   #     x     : 描画目标 X 坐标
  184.   #     y     : 描画目标 Y 坐标
  185.   #--------------------------------------------------------------------------
  186.   def draw_battle_actor(actor, x, y)
  187.     bitmap=Bitmap.new("Graphics/Picturess/#{actor.id}")
  188.     cw = bitmap.width
  189.     ch = bitmap.height
  190.     src_rect = Rect.new(0, 0, cw, ch)
  191.     self.contents.blt(x - cw/20, y - ch, bitmap, src_rect)
  192.   end
  193.   ###########################################################################
  194. end
  195.  
  196.  
  197.  
  198. #==============================================================================
  199. # ■ Window_BattleStatus
  200. #------------------------------------------------------------------------------
  201. #  显示战斗画面同伴状态的窗口。
  202. #==============================================================================
  203. class Window_BattleStatus < Window_Base
  204.   #--------------------------------------------------------------------------
  205.   # ● 初始化对像
  206.   #--------------------------------------------------------------------------
  207.   #$data_system_level_up_me = "Audio/ME/升级音乐"
  208.   def initialize
  209.     super(0, 0, 640, 480)#(0, 0, 640, 480)
  210.     self.contents = Bitmap.new(width - 10, height - 32)
  211.     self.opacity = 0
  212.     @level_up_flags = [false, false, false, false]
  213.     refresh
  214.   end
  215.   #--------------------------------------------------------------------------
  216.   # ● 释放
  217.   #--------------------------------------------------------------------------
  218.   def dispose
  219.     super
  220.   end
  221.   #--------------------------------------------------------------------------
  222.   # ● 设置升级标志
  223.   #     actor_index : 角色索引
  224.   #--------------------------------------------------------------------------
  225.   def level_up(actor_index)
  226.     @level_up_flags[actor_index] = true
  227.   end
  228.   #--------------------------------------------------------------------------
  229.   # ● 刷新
  230.   #--------------------------------------------------------------------------
  231.   def refresh
  232.     self.contents.clear
  233.     @item_max = $game_party.actors.size
  234.     for i in 0...$game_party.actors.size
  235.       actor = $game_party.actors[i]
  236.       x = i * 150 + 140#160 + 140
  237.       y = 370
  238.       #########################################
  239.       draw_battle_actor(actor,x-180,y+83) #整体图片的坐标
  240.       #########################################
  241.  
  242.       if @level_up_flags[i]
  243.         self.contents.font.color = normal_color
  244.         self.contents.draw_text(x+18,y+50, 80, 24, "等级 提升!")
  245.         Audio.me_stop
  246.       else
  247.        draw_actor_hp1(actor, x-90, y+20, 80)   
  248.        draw_actor_sp1(actor, x-75, y+35, 80)#战斗画面角色血量文字的位置
  249.    #按照CP制度的位置进行调整 最后的180是显示所需要的长度
  250.    draw_actor_state(actor, actor.screen_x-50, actor.screen_y-30, 180)
  251.       end
  252.     end
  253.   end
  254.   #--------------------------------------------------------------------------
  255.   # ● 刷新画面
  256.   #--------------------------------------------------------------------------
  257.   def update
  258.     super
  259.     # 主界面的不透明度下降
  260.     if $game_temp.battle_main_phase
  261.       self.contents_opacity -= 50 if self.contents_opacity > 255
  262.     else
  263.       self.contents_opacity += 50 if self.contents_opacity < 255
  264.     end
  265.   end
  266. end
  267.  
  268.  
  269. #==============================================================================
  270. # ■ Window_BattleStatus
  271. #==============================================================================
  272. class Window_BattleStatus < Window_Base
  273.   #--------------------------------------------------------------------------
  274.   # ● 初始化
  275.   #--------------------------------------------------------------------------
  276.   alias xrxs_bp2_refresh refresh
  277.   def refresh
  278.     xrxs_bp2_refresh
  279.     @item_max = $game_party.actors.size
  280.     for i in 0...$game_party.actors.size
  281.       actor = $game_party.actors[i]
  282.       x = i * 150 + 140#队友之间血条的距离
  283.       y = 370
  284.      # draw_actor_hp_meter(actor, x, y, 100)#血条的长短
  285.       #draw_actor_sp_meter(actor, x, y + 8, 100)
  286.       draw_actor_hp_meter(actor, x-70, y + 28, 55)
  287.       draw_actor_sp_meter(actor, x-85, y +40, 65)
  288.  
  289.     end
  290.   end
  291. end
  292. #==============================================================================
  293. # ■ Window_Base
  294. #==============================================================================
  295. class Window_Base < Window
  296.   #--------------------------------------------------------------------------
  297.   # ● HP描画
  298.   #--------------------------------------------------------------------------
  299.   def draw_actor_hp_meter(actor, x, y, width = 156, type = 0)
  300.     if type == 1 and actor.hp == 0
  301.       return
  302.     end
  303.     self.contents.font.color = system_color
  304.    # self.contents.fill_rect(x-1, y+27, width+2,6, Color.new(0, 0, 0, 25))
  305.     self.contents.fill_rect(x-1, y+27, width+2,6, Color.new(0, 0, 0, 25))
  306.     w = width * actor.hp / actor.maxhp
  307.     #######################################################################
  308.     self.contents.fill_rect(x, y+28, w,2, Color.new(255, 96, 96, 255))
  309.     self.contents.fill_rect(x, y+30, w,1, Color.new(255, 96, 96, 255))
  310.     self.contents.fill_rect(x, y+29, w,1, Color.new(255, 0, 0, 255))
  311.     self.contents.fill_rect(x, y+30, w,1, Color.new(128, 0, 0, 255))
  312.     self.contents.fill_rect(x, y+31, w,1, Color.new(0, 0, 0, 255))
  313.     ###########################################################################
  314.     #self.contents.fill_rect(x-131, y+55, w,1, Color.new(255, 96, 96, 255))
  315.    # self.contents.fill_rect(x-131, y+54, w,1, Color.new(255, 0, 0, 255))
  316.     #self.contents.fill_rect(x-131, y+55, w,1, Color.new(128, 0, 0, 255))
  317.    # self.contents.fill_rect(x-131, y+56, w,1, Color.new(0, 0, 0, 255))
  318.   end
  319.   #--------------------------------------------------------------------------
  320.   # ● SP描画
  321.   #--------------------------------------------------------------------------
  322.   def draw_actor_sp_meter(actor, x, y, width = 156, type = 0)
  323.     if type == 1 and actor.hp == 0
  324.       return
  325.     end
  326.     self.contents.font.color = system_color
  327.     self.contents.fill_rect(x-1, y+27, width+2,6, Color.new(0, 0, 0, 255))
  328.     w = width * actor.sp / actor.maxsp
  329.     self.contents.fill_rect(x, y+28, w,1, Color.new(128, 255, 255, 255))
  330.     self.contents.fill_rect(x, y+29, w,1, Color.new(0, 255, 255, 255))
  331.     self.contents.fill_rect(x, y+30, w,1, Color.new(0, 192, 192, 255))
  332.     self.contents.fill_rect(x, y+31, w,1, Color.new(0, 128, 128, 255))
  333.  
  334.    # self.contents.fill_rect(x-131, y+70, w,1, Color.new(128, 255, 255, 255))
  335.     #self.contents.fill_rect(x-131, y+69, w,1, Color.new(0, 255, 255, 255))
  336.     #self.contents.fill_rect(x-131, y+70, w,1, Color.new(0, 192, 192, 255))
  337.    # self.contents.fill_rect(x-131, y+71, w,1, Color.new(0, 128, 128, 255))
  338. end
  339. end

作者: cinderelmini    时间: 2016-12-5 21:51
如果只需要表示一下战斗图的话,
也许可以用那个横板战斗系统,然后在Window_BattleStatus里绘制一下各角色的战斗图就好了?
前提是这些在状态栏里的战斗图不会成为攻击对象,不会闪烁,不会掉数字不会显示状态动画等等。。。




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