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

Project1

 找回密码
 注册会员
搜索
查看: 1780|回复: 0
打印 上一主题 下一主题

[已经解决] 有那位 高人知道 这脚本怎么用的

[复制链接]

Lv2.观梦者

梦石
0
星屑
575
在线时间
1752 小时
注册时间
2008-11-7
帖子
1431
跳转到指定楼层
1
发表于 2012-8-22 10:40:41 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
  1. #==============================================================================
  2. # ■ 本脚本源自www.66rpg.com,转载与使用请保留此信息
  3. #==============================================================================

  4. #——以下是一些自定义的内容

  5. $mShop_use_1 = "灵魄"    #——这项是购买魔法特技的货币的名称,如“灵魄”、“金钱”

  6. $mShop_use_2 = "特斯拉"  #——这项是购买魔法特技的货币单位,如“点”、“¥”

  7. $mShop_use_variable = 1  #——这项是购买魔法特技时消耗的变量编号,如果=0 则是消耗金钱

  8. $mShop_Window_Opacity = 200  #——这项是窗口透明度

  9. #==============================================================================
  10. # ■ Window_MGold
  11. #------------------------------------------------------------------------------
  12. #  显示金钱的窗口。
  13. #==============================================================================
  14. class Window_MGold < Window_Base
  15.   #--------------------------------------------------------------------------
  16.   # ● 初始化窗口
  17.   #--------------------------------------------------------------------------
  18.   def initialize
  19.     super(0, 0, 272, 64)
  20.     self.contents = Bitmap.new(width - 32, height - 32)
  21.     refresh
  22.   end
  23.   #--------------------------------------------------------------------------
  24.   # ● 刷新
  25.   #--------------------------------------------------------------------------
  26.   def refresh
  27.     self.contents.clear
  28.     self.contents.font.color = system_color
  29.     self.contents.draw_text(0, 0 , 240,32 ,$mShop_use_1)
  30.     self.contents.font.color = normal_color
  31.     self.contents.draw_text(0, 0, 240-contents.text_size($mShop_use_2).width-6, 32, $mShop_gold.to_s, 2)
  32.     self.contents.font.color = system_color
  33.     self.contents.draw_text(0, 0, 240, 32, $mShop_use_2, 2)
  34.   end
  35. end
  36. #==============================================================================
  37. # ■ Scene_MShop
  38. #------------------------------------------------------------------------------
  39. #  处理特技商店画面的类。
  40. #==============================================================================
  41. class Scene_MShop
  42.   #--------------------------------------------------------------------------
  43.   # ● 初始化
  44.   #--------------------------------------------------------------------------
  45.   def initialize(id)
  46.     @id = id
  47.   end   
  48.   #--------------------------------------------------------------------------
  49.   # ● 主处理
  50.   #--------------------------------------------------------------------------
  51.   def main
  52.     screen = Spriteset_Map.new
  53.     if $mShop_use_variable == 0
  54.       $mShop_gold = $game_party.gold
  55.     else
  56.       $mShop_gold = $game_variables[$mShop_use_variable]
  57.     end
  58.     # 生成帮助窗口
  59.     @help_window = Window_Help.new
  60.     @help_window.opacity = $mShop_Window_Opacity
  61.     # 生成金钱窗口
  62.     @gold_window = Window_MGold.new
  63.     @gold_window.x = 368
  64.     @gold_window.y = 416
  65.     @gold_window.opacity = $mShop_Window_Opacity
  66.     # 生成购买窗口
  67.     @buy_window = Window_MShopBuy.new(@id)
  68.     @buy_window.active = true
  69.     @buy_window.visible = true
  70.     @buy_window.help_window = @help_window
  71.     @buy_window.opacity = $mShop_Window_Opacity
  72.     # 生成状态窗口
  73.     @status_window = Window_MShopStatus.new
  74.     @status_window.visible = true
  75.     @status_window.active = false
  76.     @status_window.opacity = $mShop_Window_Opacity
  77.     # 执行过渡
  78.     Graphics.transition
  79.     # 主循环
  80.     loop do
  81.       # 刷新游戏画面
  82.       Graphics.update
  83.       # 刷新输入信息
  84.       Input.update
  85.       # 刷新画面
  86.       update
  87.       # 如果画面切换的话就中断循环
  88.       if $scene != self
  89.         break
  90.       end
  91.     end
  92.     # 准备过渡
  93.     Graphics.freeze
  94.     # 释放窗口
  95.     @help_window.dispose
  96.     #@mhelp_window.dispose
  97.     @gold_window.dispose
  98.     @buy_window.dispose
  99.     @status_window.dispose
  100.     screen.dispose
  101.   end
  102.   #--------------------------------------------------------------------------
  103.   # ● 刷新画面
  104.   #--------------------------------------------------------------------------
  105.   def update
  106.     # 刷新窗口
  107.     @help_window.update
  108.     #@mhelp_window.update
  109.     @gold_window.update
  110.     @buy_window.update
  111.     @status_window.update
  112.     # 购买窗口激活的情况下: 调用 update_buy
  113.     if @buy_window.active
  114.       update_buy
  115.       return
  116.     end
  117.     if @status_window.active
  118.       update_status
  119.       return
  120.     end
  121.   end
  122.   #--------------------------------------------------------------------------
  123.   # ● 刷新画面 (购买窗口激活的情况下)
  124.   #--------------------------------------------------------------------------
  125.   def update_buy
  126.     @status_window.skill = @buy_window.skill
  127.     if Input.trigger?(Input::B)
  128.       $game_system.se_play($data_system.cancel_se)
  129.       $scene = Scene_Map.new
  130.       return
  131.     end
  132.     if Input.trigger?(Input::C)
  133.       @skill = @buy_window.skill
  134.       if @skill == nil or @skill.price > $mShop_gold
  135.         $game_system.se_play($data_system.buzzer_se)
  136.         return
  137.       end
  138.       $game_system.se_play($data_system.decision_se)
  139.       @buy_window.active = false
  140.       @status_window.index = 0
  141.       @status_window.active = true
  142.     end
  143.   end
  144.   #--------------------------------------------------------------------------
  145.   # ● 刷新画面 (状态窗口激活的情况下)
  146.   #--------------------------------------------------------------------------
  147.   def update_status
  148.     if Input.trigger?(Input::B)
  149.       $game_system.se_play($data_system.cancel_se)
  150.       @status_window.active = false
  151.       @status_window.index = -1
  152.       @buy_window.active = true
  153.     end
  154.     if Input.trigger?(Input::C)
  155.       if $game_party.actors[@status_window.index].skill_learn?(@skill.id)
  156.         $game_system.se_play($data_system.cancel_se)
  157.         return
  158.       else
  159.         $game_system.se_play($data_system.decision_se)
  160.         if $mShop_use_variable == 0
  161.           $game_party.gain_gold([email protected])
  162.           $mShop_gold -= @skill.price
  163.         else
  164.           $game_variables[$mShop_use_variable] -= @skill.price
  165.           $mShop_gold -= @skill.price
  166.         end
  167.         $game_party.actors[@status_window.index].learn_skill(@skill.id)
  168.         @gold_window.refresh
  169.         @buy_window.refresh
  170.         @status_window.refresh
  171.         @status_window.active = false
  172.         @status_window.index = -1
  173.         @buy_window.active = true
  174.       end      
  175.     end     
  176.   end
  177. end
  178. #==============================================================================
  179. # ■ Window_MShopStatus
  180. #------------------------------------------------------------------------------
  181. #  特技商店画面、显示物品所持数与角色装备的窗口。
  182. #==============================================================================
  183. class Window_MShopStatus < Window_Selectable
  184.   #--------------------------------------------------------------------------
  185.   # ● 初始化对像
  186.   #--------------------------------------------------------------------------
  187.   def initialize
  188.     super(368, 64, 272, 352)
  189.     self.contents = Bitmap.new(width - 32, height - 32)
  190.     self.contents.font.size = 18
  191.     @skill = nil
  192.     refresh
  193.   end
  194.   #--------------------------------------------------------------------------
  195.   # ● 刷新
  196.   #--------------------------------------------------------------------------
  197.   def refresh
  198.     self.contents.clear
  199.     for i in 0...$game_party.actors.size
  200.       actor = $game_party.actors[i]
  201.       draw_actor_graphic(actor,12,80*i+64)
  202.       self.contents.font.color = system_color
  203.       self.contents.draw_text(44, 80*i, 240, 32, actor.name)
  204.       self.contents.draw_text(0, 80*i , 240-20,32,"等级",2)
  205.       self.contents.font.color = normal_color
  206.       self.contents.draw_text(0, 80*i, 240, 32, actor.level.to_s , 2)
  207.       self.contents.font.color = system_color
  208.       self.contents.draw_text(44, 80*i+22, 45, 32, $data_system.words.hp)
  209.       self.contents.font.color = normal_color
  210.       self.contents.draw_text(44, 80*i+22, 90, 32, actor.maxhp.to_s,2)
  211.       self.contents.font.color = system_color
  212.       self.contents.draw_text(150, 80*i+22, 45, 32, $data_system.words.sp)
  213.       self.contents.font.color = normal_color
  214.       self.contents.draw_text(150, 80*i+22, 90, 32, actor.maxsp.to_s,2)      
  215.       if actor.skill_learn?(@skill.id)
  216.         self.contents.font.color = Color.new(255,255,255,128)
  217.         self.contents.draw_text(44, 80*i+44, 196, 32, "⊙此项特技已经学习⊙",2)         
  218.       else
  219.         self.contents.font.color = Color.new(255,255,0,255)
  220.         self.contents.draw_text(44, 80*i+44, 240, 32, "★此项特技尚未学习★")
  221.       end
  222.     end
  223.     @item_max = $game_party.actors.size
  224.   end
  225.   #--------------------------------------------------------------------------
  226.   # ● 设置物品
  227.   #     item : 新的物品
  228.   #--------------------------------------------------------------------------
  229.   def skill=(skill)
  230.     if @skill != skill
  231.       @skill = skill
  232.       refresh
  233.     end
  234.   end
  235.   #--------------------------------------------------------------------------
  236.   # ● 刷新光标矩形
  237.   #--------------------------------------------------------------------------
  238.   def update_cursor_rect
  239.     if @index < 0
  240.       self.cursor_rect.empty
  241.     else
  242.       self.cursor_rect.set(0, @index * 80, self.width - 32, 80)
  243.     end
  244.   end
  245. end
  246. #==============================================================================
  247. # ■ Window_MShopBuy
  248. #------------------------------------------------------------------------------
  249. #  特技商店画面、浏览显示可以购买的商品的窗口。
  250. #==============================================================================
  251. class Window_MShopBuy < Window_Selectable
  252.   #--------------------------------------------------------------------------
  253.   # ● 初始化对像
  254.   #     shop_goods : 商品
  255.   #--------------------------------------------------------------------------
  256.   def initialize(id)
  257.     super(0, 64, 368, 416)
  258.     @id = id
  259.     refresh
  260.     self.index = 0
  261.   end
  262.   #--------------------------------------------------------------------------
  263.   # ● 获取物品
  264.   #--------------------------------------------------------------------------
  265.   def skill
  266.     return @data[self.index]
  267.   end
  268.   #--------------------------------------------------------------------------
  269.   # ● 刷新
  270.   #--------------------------------------------------------------------------
  271.   def refresh
  272.     if self.contents != nil
  273.       self.contents.dispose
  274.       self.contents = nil
  275.     end
  276.     @data = []
  277.     for skill_id in @id
  278.       skill = $data_skills[skill_id]
  279.       if skill != nil
  280.         @data.push(skill)
  281.       end
  282.     end
  283.     @item_max = @data.size
  284.     if @item_max > 0
  285.       self.contents = Bitmap.new(width - 32, row_max * 32)
  286.       for i in 0...@item_max
  287.         draw_item(i)
  288.       end
  289.     end
  290.   end
  291.   #--------------------------------------------------------------------------
  292.   # ● 描绘羡慕
  293.   #     index : 项目编号
  294.   #--------------------------------------------------------------------------
  295.   def draw_item(index)
  296.     skill = @data[index]
  297.     # 除此之外的情况设置为无效文字色
  298.     if skill.price <= $mShop_gold
  299.       self.contents.font.color = normal_color
  300.     else
  301.       self.contents.font.color = disabled_color
  302.     end
  303.     x = 4
  304.     y = index * 32
  305.     rect = Rect.new(x, y, self.width - 32, 32)
  306.     self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  307.     bitmap = RPG::Cache.icon(skill.icon_name)
  308.     opacity = self.contents.font.color == normal_color ? 255 : 128
  309.     self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
  310.     self.contents.draw_text(x + 28, y, 212, 32, skill.name, 0)
  311.     self.contents.draw_text(x + 240, y, 88, 32, skill.price.to_s, 2)
  312.   end
  313.   #--------------------------------------------------------------------------
  314.   # ● 刷新帮助文本
  315.   #--------------------------------------------------------------------------
  316.   def update_help
  317.     @help_window.set_text(self.skill == nil ? "" : self.skill.description)
  318.   end
  319. end
  320. #==============================================================================
  321. # ■ RPG原装定义
  322. #==============================================================================
  323. module RPG
  324.   class Skill
  325.     def description
  326.       description = @description.split(/@/)[0]
  327.       return description != nil ? description : '
  328.     end
  329.     def price
  330.       price = @description.split(/@/)[1]
  331.       return price != nil ? price.to_i : 0
  332.     end
  333.   end
  334. end
复制代码


‘‘──z2z4于2012-8-22 10:40补充以下内容:

弄了很久 就是没弄明白
’’
RPG魔塔:http://rpg.blue/thread-254429-1-1.html
魔塔2:http://rpg.blue/thread-303601-1-1.html
魔塔3: 制作中...MV
您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

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

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

GMT+8, 2024-5-5 16:01

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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