设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 2045|回复: 2

[已经过期] 求教,可以让这套魔法商店的脚本显示人物行走图+名字吗?

[复制链接]

Lv2.观梦者

梦石
0
星屑
775
在线时间
924 小时
注册时间
2006-6-26
帖子
1529
发表于 2019-7-14 14:01:53 | 显示全部楼层 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有帐号?注册会员

x
RUBY 代码复制
  1. #==============================================================================
  2. # 本脚本来自[url]www.66RPG.com[/url],使用和转载请保留此信息
  3. #==============================================================================
  4. #==============================================================================
  5. #——以下是一些自定义的内容
  6. $mShop_use_1 = "LP"    #——这项是购买魔法特技的货币的名称,如“灵魄”、“金钱”
  7. $mShop_use_2 = "LP"  #——这项是购买魔法特技的货币单位,如“点”、“¥”
  8. $mShop_use_variable = 0  #——这项是购买魔法特技时消耗的变量编号,如果=0 则是消耗金钱
  9. $mShop_Window_Opacity = 200  #——这项是窗口透明度
  10. #==============================================================================
  11. # ■ Window_MGold
  12. #------------------------------------------------------------------------------
  13. #  显示LP的窗口。
  14. #==============================================================================
  15. class Window_MGold < Window_Base
  16.   #--------------------------------------------------------------------------
  17.   # ● 初始化窗口
  18.   #--------------------------------------------------------------------------
  19.   def initialize
  20.     super(0, 0, 544-32-standard_padding*2, 64)
  21.     self.contents = Bitmap.new(width - standard_padding*2, height - standard_padding*2)
  22.     refresh
  23.   end
  24.   #--------------------------------------------------------------------------
  25.   # ● 刷新
  26.   #--------------------------------------------------------------------------
  27.   def refresh
  28.     self.contents.clear
  29.     self.contents.font.color = system_color
  30.     self.contents.draw_text(0, 0 , 240,32 ,$mShop_use_1)
  31.     self.contents.font.color = normal_color
  32.     self.contents.draw_text(0, 0, 240-contents.text_size($mShop_use_2).width-6, 32, $mShop_gold.to_s, 2)
  33.     self.contents.font.color = system_color
  34.     self.contents.draw_text(0, 0, 240, 32, $mShop_use_2, 2)
  35.   end
  36. end
  37. #==============================================================================
  38. # ■ Scene_MShop
  39. #------------------------------------------------------------------------------
  40. #  处理特技商店画面的类。
  41. #==============================================================================
  42. class Scene_MShop < Scene_Base
  43.   #--------------------------------------------------------------------------
  44.   # ● 初始化
  45.   #--------------------------------------------------------------------------
  46.   def initialize(id)
  47.     @id = id
  48.     create_main_viewport
  49.   end   
  50.   #--------------------------------------------------------------------------
  51.   # ● 主处理
  52.   #--------------------------------------------------------------------------
  53.   def main
  54.     if $mShop_use_variable == 0
  55.       $mShop_gold = $game_party.gold
  56.     else
  57.       $mShop_gold = $game_variables[$mShop_use_variable]
  58.     end
  59.     # 生成帮助窗口
  60.     @help_window = Window_Help.new
  61.     @help_window.opacity = $mShop_Window_Opacity
  62.     # 生成金钱窗口
  63.     @gold_window = Window_MGold.new
  64.     @gold_window.x = 0
  65.     @gold_window.y = 416 - 64
  66.     @gold_window.opacity = $mShop_Window_Opacity
  67.     # 生成购买窗口
  68.     @buy_window = Window_MShopBuy.new(@id)
  69.     @buy_window.active = true
  70.     @buy_window.visible = true
  71.     @buy_window.help_window = @help_window
  72.     @buy_window.opacity = $mShop_Window_Opacity
  73.     # 生成状态窗口
  74.     @status_window = Window_MShopStatus.new
  75.     @status_window.visible = true
  76.     @status_window.active = false
  77.     @status_window.opacity = $mShop_Window_Opacity
  78.     @status_window.skill = @buy_window.skill
  79.     # 执行过渡
  80.     Graphics.transition
  81.     # 主循环
  82.     loop do
  83.       # 刷新游戏画面
  84.       Graphics.update
  85.       # 刷新输入信息
  86.       Input.update
  87.       # 刷新画面
  88.       update
  89.       if !SceneManager.scene_is? (Scene_MShop)
  90.         break
  91.       # 如果画面切换的话就中断循环
  92.       end
  93.     end
  94.     # 释放窗口
  95.     pre_terminate
  96.     terminate
  97.   end
  98.   #--------------------------------------------------------------------------
  99.   # ● 刷新画面
  100.   #--------------------------------------------------------------------------
  101.   def update
  102.     # 刷新窗口
  103.     @help_window.update
  104.     #@mhelp_window.update
  105.     @gold_window.update
  106.     @buy_window.update
  107.     @status_window.update
  108.     # 购买窗口激活的情况下: 调用 update_buy
  109.     if @buy_window.active
  110.       update_buy
  111.       return
  112.     end
  113.     if @status_window.active
  114.       update_status
  115.       return
  116.     end
  117.   end
  118.   #--------------------------------------------------------------------------
  119.   # ● 刷新画面 (购买窗口激活的情况下)
  120.   #--------------------------------------------------------------------------
  121.   def update_buy
  122.     @status_window.skill = @buy_window.skill
  123.     if Input.trigger?(Input::B)
  124.       Sound::play_cancel
  125.       # 返回
  126.       SceneManager.return
  127.       # 释放窗口
  128.       return
  129.     end
  130.     if Input.trigger?(Input::C)
  131.       @skill = @buy_window.skill
  132.       if @skill == nil or @skill.price > $mShop_gold
  133.         Sound::play_buzzer
  134.         return
  135.       end
  136.       Sound::play_ok
  137.       @buy_window.active = false
  138.       @status_window.index = 0
  139.       @status_window.active = true
  140.     end
  141.   end
  142.   #--------------------------------------------------------------------------
  143.   # ● 刷新画面 (状态窗口激活的情况下)
  144.   #--------------------------------------------------------------------------
  145.   def update_status
  146.     if Input.trigger?(Input::B)
  147.       Sound::play_cancel
  148.       @status_window.active = false
  149.       @status_window.index = -1
  150.       @buy_window.active = true
  151.     end
  152.     if Input.trigger?(Input::C)
  153.       if $game_party.members[@status_window.index].skill_learn?(@skill)
  154.       Sound::play_buzzer
  155.         return
  156.       else
  157.         Sound::play_ok
  158.         if $mShop_use_variable == 0
  159.           $game_party.gain_gold(-@skill.price)
  160.           $mShop_gold -= @skill.price
  161.         else
  162.           $game_variables[$mShop_use_variable] -= @skill.price
  163.           $mShop_gold -= @skill.price
  164.         end
  165.         $game_party.members[@status_window.index].learn_skill(@skill.id)
  166.         @gold_window.refresh
  167.         @buy_window.refresh
  168.         @status_window.refresh
  169.         @status_window.active = false
  170.         @status_window.index = -1
  171.         @buy_window.active = true
  172.       end      
  173.     end     
  174.   end
  175. end
  176. #==============================================================================
  177. # ■ Window_MShopBuy
  178. #------------------------------------------------------------------------------
  179. #  特技商店画面、浏览显示可以购买的商品的窗口。
  180. #==============================================================================
  181. class Window_MShopBuy < Window_Selectable
  182.  
  183.   #--------------------------------------------------------------------------
  184.   # ● 修改行高为合适的值
  185.   #--------------------------------------------------------------------------
  186.   def line_height
  187.     return 32
  188.   end
  189.   #--------------------------------------------------------------------------
  190.   # ● 初始化对象
  191.   #     shop_goods : 商品
  192.   #--------------------------------------------------------------------------
  193.  
  194.   def initialize(id)
  195.     @id = id
  196.     super(0, 64, 544-32-standard_padding*2, 416-64-64)
  197.     refresh
  198.     self.index = 0
  199.   end
  200.  
  201.   #--------------------------------------------------------------------------
  202.   # ● 获取物品
  203.   #--------------------------------------------------------------------------
  204.   def skill
  205.     return @data[self.index]
  206.   end
  207.   def item_max
  208.     if @id != nil
  209.       return @id.size
  210.     end
  211.   end
  212.   #--------------------------------------------------------------------------
  213.   # ● 刷新
  214.   #--------------------------------------------------------------------------
  215.   def refresh
  216.     if self.contents != nil
  217.       self.contents.dispose
  218.       self.contents = nil
  219.     end
  220.     @data = []
  221.     for skill_id in @id
  222.       skill = $data_skills[skill_id]
  223.       if skill != nil
  224.         @data.push(skill)
  225.       end
  226.     end
  227.     if item_max > 0
  228.       self.contents = Bitmap.new(width - 32, item_max* 32)
  229.       for i in 0...item_max
  230.         draw_item(i)
  231.       end
  232.     end
  233.   end
  234.   #--------------------------------------------------------------------------
  235.   # ● 描绘项目
  236.   #     index : 项目编号
  237.   #--------------------------------------------------------------------------
  238.   def draw_item(index)
  239.     skill = @data[index]
  240.     # 除此之外的情况设置为无效文字色
  241.     if skill.price <= $mShop_gold
  242.       self.contents.font.color = normal_color
  243.     else
  244.       self.contents.font.color = system_color
  245.     end
  246.     x = 4
  247.     y = index * 32
  248.     rect = Rect.new(x, y, self.width - 24, 24)
  249.     self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  250.     draw_icon(skill.icon_index,x,y+4,self.contents.font.color == normal_color)
  251.     self.contents.draw_text(x + 28, y, 212, 32, skill.name, 0)
  252.     self.contents.draw_text(x + 240, y, 88, 32, skill.price.to_s, 2)
  253.   end
  254.   #--------------------------------------------------------------------------
  255.   # ● 刷新帮助文本
  256.   #--------------------------------------------------------------------------
  257.   def update_help
  258.     @help_window.set_text(self.skill == nil ? "" : self.skill.description)
  259.   end
  260.  
  261. end
  262.  
  263. #==============================================================================
  264. # ■ Window_MShopStatus
  265. #------------------------------------------------------------------------------
  266. #  特技商店画面、显示物品所持数与角色装备的窗口。
  267. #==============================================================================
  268. class Window_MShopStatus < Window_Selectable
  269.   #--------------------------------------------------------------------------
  270.   # ● 修改行高为合适的值
  271.   #--------------------------------------------------------------------------
  272.   def line_height
  273.     return 32
  274.   end
  275.   #--------------------------------------------------------------------------
  276.   # ● 初始化对像
  277.   #--------------------------------------------------------------------------
  278.   def initialize
  279.     super(Graphics.width-standard_padding*2-32,64,standard_padding*2+32 , Graphics.height-64)
  280.     self.contents = Bitmap.new(width - 24,  32*$game_party.members.size+2*standard_padding>height - 32-64? 32*$game_party.members.size+2*standard_padding : height - 32-64)
  281.     self.contents.font.size = 32
  282.     @skill = nil
  283.   end
  284.   #--------------------------------------------------------------------------
  285.   # ● 刷新
  286.   #--------------------------------------------------------------------------
  287.   def refresh
  288.     self.contents.clear
  289.     for i in 0...$game_party.members.size
  290.       actor = $game_party.members[i]
  291.       if actor.class.skills.include?(@skill.id)
  292.         if !actor.skill_learn?(@skill)
  293.           draw_actor_graphic(actor,standard_padding+4,32*i+16+12+4)
  294.         else
  295.           draw_actor_graphic(actor,standard_padding+4,32*i+16+12+4,150)
  296.         end
  297.       else
  298.         next
  299.       end
  300.     end
  301.   end
  302.   def item_max
  303.       return $game_party.members.size
  304.     end
  305.   #--------------------------------------------------------------------------
  306.   # ● 设置物品
  307.   #     item : 新的物品
  308.   #--------------------------------------------------------------------------
  309.   def skill=(skill)
  310.     if @skill != skill
  311.       @skill = skill
  312.       refresh
  313.     end
  314.   end
  315.   #--------------------------------------------------------------------------
  316.   # ● 刷新光标矩形
  317.   #--------------------------------------------------------------------------
  318.   def update_cursor_rect
  319.     if @index < 0
  320.       self.cursor_rect.empty
  321.     else
  322.       self.cursor_rect.set(0, @index * 32, 44, 44)
  323.     end
  324.   end
  325. end
  326. #==============================================================================
  327. # ■ RPG原装定义
  328. #==============================================================================
  329. module RPG
  330.   class Skill
  331.     def description
  332.       description = @description.split(/@/)[0]
  333.       return description != nil ? description : ''
  334.     end
  335.     def price
  336.       price = @description.split(/@/)[1]
  337.       return price != nil ? price.to_i : 0
  338.     end
  339.   end
  340.   class Class < BaseItem
  341.     def skills
  342.       @allskills = []
  343.       self.learnings.each do |skill|
  344.       @allskills.push(skill.skill_id)
  345.         end
  346.       return @allskills
  347.     end
  348. end
  349.  
  350. end
  351. #==============================================================================
  352. # ■ 场景管理器定义
  353. #==============================================================================
  354.  
  355. module SceneManager
  356.   #--------------------------------------------------------------------------
  357.   # ● 呼び出し
  358.   #--------------------------------------------------------------------------
  359.   def self.call(scene_class,para = nil)
  360.     @stack.push(@scene)
  361.     @scene = scene_class.new(para)
  362.   end
  363. end
  364.  
  365. class Window_Base < Window
  366.   #--------------------------------------------------------------------------
  367.   # ● 描绘角色行走图(只给定角色对象)
  368.   #--------------------------------------------------------------------------
  369.   def draw_actor_graphic(actor, x, y, alpha = 255)
  370.     draw_character(actor.character_name, actor.character_index, x, y,alpha)
  371.   end
  372.   #--------------------------------------------------------------------------
  373.   # ● 描绘行走图
  374.   #--------------------------------------------------------------------------
  375.   def draw_character(character_name, character_index, x, y,alpha = 255)
  376.     return unless character_name # 不给文件名神马的最讨厌了
  377.     bitmap = Cache.character(character_name) # 读取Cache里的行走图像
  378.     sign = character_name[/^[\!\$]./] # 如果文件名里带!和$的话有特殊含义哦
  379.     if sign && sign.include?('$') # 如果有$的话是大图
  380.       cw = bitmap.width / 3
  381.       ch = bitmap.height / 4
  382.     else                          # 不然是小图。有!表示非人物的行走图。宝箱之类的。
  383.       cw = bitmap.width / 12
  384.       ch = bitmap.height / 8
  385.     end
  386.     n = character_index           # 这都要偷懒啊……
  387.     src_rect = Rect.new((n%4*3+1)*cw, (n/4*4)*ch, cw, ch)
  388.     contents.blt(x - cw / 2, y - ch, bitmap, src_rect,alpha) # Bitmap.blt方法
  389.   end
  390. end
  391.  
  392.  
  393. #==============================================================================
  394. # 本脚本来自[url]www.66RPG.com[/url],使用和转载请保留此信息
  395. #==============================================================================



另外,侧面这个行走图的边框怎么扩大?
我是不是可以签名了?
您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-3-29 06:34

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表