赞 | 0 |
VIP | 0 |
好人卡 | 2 |
积分 | 1 |
经验 | 952 |
最后登录 | 2013-12-27 |
在线时间 | 336 小时 |
Lv1.梦旅人
- 梦石
- 0
- 星屑
- 50
- 在线时间
- 336 小时
- 注册时间
- 2010-8-26
- 帖子
- 428
|
回复 ngngy 的帖子
- #==============================================================================
- # 易用型传送点系统 by 沉影不器
- #------------------------------------------------------------------------------
- # 功能描述: ① 传送点上按确定键即激活传送点,各个已激活的传送点之间可相互传送.
- # ② 指向当前所在地图的选项不传送; 要求金钱的地图,钱不够不传送.
- # ③ 为节省位置,折成两列显示.
- #------------------------------------------------------------------------------
- # 使用说明: ① 复制脚本插入到main之前
- # ② 传送点的事件脚本中写 $scene = Scene_Way_points.new(@event_id)
- # ③ 给每张有传送点的地图取个像样的名称
- # ④ 要求金钱的地图,在名称后添加",金钱数"(不包括引号),详见范例
- # ⑤ 参数设定在脚本第17-22行
- #==============================================================================
- # 参数设定
- #==============================================================================
- module WP
- WP_WIDTH = 160 # 单列地图选项的宽度(共两列)
- WP_MAX = 10 # 传送窗体显示的传送点数
- WP_ANIMATION = 367 # 传送时显示的动画 id
- WP_HIDE_WINDOW = true # 传送时隐藏窗体
- WP_ICON = 153 # 地图选项的图标 id
- # 您也可以为每个地图设置单独图标
- SELF_ICON = false # 打开此开关将描绘Icons文件夹下与地图名相同的图标
- end
- #==============================================================================
- # ■ Game_System
- #==============================================================================
- class Game_System
- #--------------------------------------------------------------------------
- # ● 定义实例变量
- #--------------------------------------------------------------------------
- attr_accessor :way_points # 传送点选项
- #--------------------------------------------------------------------------
- # ● 初始化对象
- #--------------------------------------------------------------------------
- alias ini initialize
- def initialize
- ini;@way_points = []
- end
- end
- #==============================================================================
- # □ Window_WP_Help
- #==============================================================================
- class Window_WP_Help < Window_Base
- #--------------------------------------------------------------------------
- # ○ 初始化对像
- #--------------------------------------------------------------------------
- def initialize(x, y)
- super(x, y, WP::WP_WIDTH * 2, 80)
- self.opacity = 192
- end
- #--------------------------------------------------------------------------
- # ○ 设置文本
- # text1 : 地图名
- # text2 : 金钱数
- #--------------------------------------------------------------------------
- def set_text(text1, text2)
- if text1 != @text1 or text2 != @text2
- @text1 = text1
- @text2 = text2
- # 再描绘文本
- self.contents.clear
- self.contents.font.color = system_color
- self.contents.draw_text(4, 0, self.width - 40, WLH, text1 + "传送点")
- self.contents.font.color = normal_color
- if text2 == 0
- text2 = "免费传送"
- else
- text2 = "花费 " + text2.to_s + Vocab::gold
- end
- self.contents.draw_text(4, WLH, self.width - 40, WLH, text2, 2)
- end
- self.visible = true
- end
- end
- #==============================================================================
- # □ Window_Way_Points
- #==============================================================================
- class Window_Way_Points < Window_Selectable
- #--------------------------------------------------------------------------
- # ○ 初始化
- # event_id : 事件 id
- #--------------------------------------------------------------------------
- def initialize(event_id)
- # 设定部分
- setup($game_map.map_id, event_id)
- @item_max = $game_system.way_points.size
- # 计算 super 参数
- width = WP::WP_WIDTH * 2
- if WP::WP_MAX >= @item_max
- height = (@item_max+1)/2*WLH
- else
- height = (WP::WP_MAX+1)/2*WLH
- end
- x = Graphics.width/2 - width/2
- y = Graphics.height/2 - height/2 + 40
- super(x, y, width, height + 32)
- @column_max = 2
- # 指定光标于当前地图选项
- self.index = now_index($game_map.map_id)
- self.opacity = 192
- refresh
- end
- #--------------------------------------------------------------------------
- # ○ 设定部分
- # map_id : 地图 id
- # event_id : 事件 id
- #--------------------------------------------------------------------------
- def setup(map_id, event_id)
- # 获取地图信息
- mapinfos = load_data("Data/MapInfos.rvdata")
- # 地图名
- map_name = mapinfos[map_id].name.split(/,/)[0]
- # 传送费用(放空时为0)
- cost = mapinfos[map_id].name.split(/,/)[1].to_i.abs
- # way_points 结构
- result = [map_id, event_id, map_name, cost]
- # 不重复时添加点
- unless $game_system.way_points.include? result
- $game_system.way_points << result
- end
- end
- #--------------------------------------------------------------------------
- # ○ 获取当前地图选项 index
- # map_id : 地图 id
- #--------------------------------------------------------------------------
- def now_index(map_id)
- for i in 0...$game_system.way_points.size
- if $game_system.way_points[i][0] == map_id
- return i
- end
- end
- # 默认值为 0
- return 0
- end
- #--------------------------------------------------------------------------
- # ○ 是否能传送
- # index : 选项编号
- #--------------------------------------------------------------------------
- def transportable?(index)
- # 未开启任何传送点时为假
- return false if $game_system.way_points.empty?
- map_id = $game_system.way_points[index][0]
- cost = $game_system.way_points[index][3]
- # 不是当前地图,且足够金钱时为真
- return (map_id != $game_map.map_id and cost <= $game_party.gold)
- end
- #--------------------------------------------------------------------------
- # ○ 刷新
- #--------------------------------------------------------------------------
- def refresh
- @item_max = $game_system.way_points.size
- create_contents
- for i in 0...@item_max
- draw_item(i)
- end
- end
- #--------------------------------------------------------------------------
- # ○ 描绘项目
- # index : 项目编号
- #--------------------------------------------------------------------------
- def draw_item(index)
- rect = item_rect(index)
- self.contents.clear_rect(rect)
- way_point = $game_system.way_points[index]
- if way_point != nil
- rect.width -= 4
- enabled = transportable?(index)
- draw_map_name(way_point[2], rect.x, rect.y, enabled)
- end
- end
- #--------------------------------------------------------------------------
- # ○ 描绘地图名
- # map_name : 地图名
- # x : 描绘目标 X 坐标
- # y : 描绘目标 Y 坐标
- # enabled : 有效标志。false 为描绘为半透明
- #--------------------------------------------------------------------------
- def draw_map_name(map_name, x, y, enabled = true)
- if map_name != ""
- if WP::SELF_ICON
- # 地图名做图标文件名
- draw_self_icon(map_name, x, y, enabled)
- else
- # 默认图标
- draw_icon(WP::WP_ICON, x, y, enabled)
- end
- self.contents.font.color = normal_color
- self.contents.font.color.alpha = enabled ? 255 : 128
- self.contents.draw_text(x + 24, y, 172, WLH, map_name)
- end
- end
- #--------------------------------------------------------------------------
- # ○ 描绘指定名图标
- # file_name : 图标文件名
- # x : 描绘目标 X 坐标
- # y : 描绘目标 Y 坐标
- # enabled : 有效标志。false 为半透明显示
- #--------------------------------------------------------------------------
- def draw_self_icon(file_name, x, y, enabled = true)
- bitmap = Cache.load_bitmap("Graphics/Icons/", file_name)
- rect = Rect.new(0, 0, 24, 24)
- self.contents.blt(x, y, bitmap, rect, enabled ? 255 : 128)
- end
- #--------------------------------------------------------------------------
- # ○ 获取当前项
- #--------------------------------------------------------------------------
- def item
- return $game_system.way_points[self.index]
- end
- #--------------------------------------------------------------------------
- # ○ 刷新帮助文本
- #--------------------------------------------------------------------------
- def update_help
- # 地图名称
- text1 = $game_system.way_points[self.index][2]
- # 费用
- text2 = $game_system.way_points[self.index][3]
- @help_window.set_text(text1,text2)
- end
- end
- #==============================================================================
- # □ Scene_Way_Point
- #==============================================================================
- class Scene_Way_Point < Scene_Base
- #--------------------------------------------------------------------------
- # ○ 初始化对像
- # event_id : 当前事件 id
- #--------------------------------------------------------------------------
- def initialize(event_id)
- @event_id = event_id
- end
- #--------------------------------------------------------------------------
- # ○ 开始处理
- #--------------------------------------------------------------------------
- def start
- ##create_menu_background
- # 为了显示动画
- @map_sprite = Spriteset_Map.new
- @way_points_window = Window_Way_Points.new(@event_id)
- x = @way_points_window.x
- y = @way_points_window.y - 80
- @help_window = Window_WP_Help.new(x, y)
- @way_points_window.help_window = @help_window
- end
- #--------------------------------------------------------------------------
- # ○ 更新画面
- #--------------------------------------------------------------------------
- def update
- # 刷新窗口
- @help_window.update
- @way_points_window.update
- # 按下取消键的情况下
- if Input.trigger?(Input::B)
- Sound.play_cancel
- $scene = Scene_Map.new
- return
- end
- # 按下确定键的情况下
- if Input.trigger?(Input::C)
- index = @way_points_window.index
- # 排除无法传送的情况
- unless @way_points_window.transportable?(index)
- Sound.play_buzzer
- else
- # 传送
- map_id = @way_points_window.item[0]
- trans(map_id)
- # 扣钱
- $game_party.gain_gold(-$game_system.way_points[index][3])
- # 动画(Iselia雪的方法)
- $game_player.animation_id = WP::WP_ANIMATION
- # vx不同于xp的动画刷新计算
- duration = $data_animations[WP::WP_ANIMATION].frame_max * 4 + 1
- duration.times do
- Graphics.update
- @map_sprite.update
- end
- $scene = Scene_Map.new
- return
- end
- end
- end
- #--------------------------------------------------------------------------
- # ○ 结束处理
- #--------------------------------------------------------------------------
- def terminate
- ##dispose_menu_background
- @map_sprite.dispose
- @way_points_window.dispose
- @help_window.dispose
- end
- #--------------------------------------------------------------------------
- # ○ 取得传送点坐标
- # map_id : 地图编号
- #--------------------------------------------------------------------------
- def way_point_xy(map_id)
- new_map = load_data(sprintf("Data/Map%03d.rvdata", map_id))
- index = @way_points_window.index
- event_id = $game_system.way_points[index][1].to_i
- return [new_map.events[event_id].x,new_map.events[event_id].y]
- end
- #--------------------------------------------------------------------------
- # ○ 传送
- # map_id : 地图编号
- #--------------------------------------------------------------------------
- def trans(map_id)
- # 设定窗体可视性
- @way_points_window.visible = @help_window.visible = !WP::WP_HIDE_WINDOW
- event_xy = way_point_xy(map_id)
- # 无法取得坐标,或移动中
- unless event_xy == nil or $game_player.transfer?
- $game_player.reserve_transfer(map_id, event_xy[0], event_xy[1], 0)
- end
- end
- end
复制代码 |
评分
-
查看全部评分
|