赞 | 0 |
VIP | 5 |
好人卡 | 14 |
积分 | 15 |
经验 | 110639 |
最后登录 | 2015-10-15 |
在线时间 | 1157 小时 |
Lv3.寻梦者 小柯的徒弟
- 梦石
- 0
- 星屑
- 1535
- 在线时间
- 1157 小时
- 注册时间
- 2008-5-24
- 帖子
- 3085
|
本帖最后由 「旅」 于 2009-8-5 23:37 编辑
写出个不成形状的= =b- class Game_Actor < Game_Battler
- #——需要令名的技能
- Need_NewName = [1,31]
- #——我是分割线
-
- alias old_learn_skill learn_skill
- def learn_skill(id2)
- old_learn_skill(id2)
- if Need_NewName.include?(id2)
- $game_system.push_new_skill(id2)
- $game_system.push_actor_id(@actor_id)
- end
- end
- end
- class Game_System
- attr_reader :new_skill
- attr_reader :actor_id
- alias old_initialize initialize
- def initialize
- @new_skill = []
- @skill_name = []
- @actor_id = []
- old_initialize
- end
- def delete_new_skill
- @new_skill.delete_at(0)
- end
- def push_new_skill(id)
- @new_skill.push(id)
- end
- def delete_actor_id
- @actor_id.delete_at(0)
- end
- def push_actor_id(id)
- @actor_id.push(id)
- end
- def skill_name(id)
- return @skill_name[id]
- end
- def push_skill_name(id, value)
- @skill_name[id] = value
- end
-
- end
- #==============================================================================
- # ■ Scene_Name
- #------------------------------------------------------------------------------
- # 处理名称输入画面的类。
- #==============================================================================
- class Scene_Name2
- #--------------------------------------------------------------------------
- # ● 主处理
- #--------------------------------------------------------------------------
- def main
- @id = $game_system.new_skill[0]
- # 获取角色
- @actor = $game_actors[$game_system.actor_id[0]]
- # 生成窗口
- a = 8 #——长度限制
- @edit_window = Window_NameEdit2.new(@actor, a,@id)
- @input_window = Window_NameInput2.new
- # 执行过渡
- Graphics.transition
- # 主循环
- loop do
- # 刷新游戏画面
- Graphics.update
- # 刷新输入信息
- Input.update
- # 刷新信息
- update
- # 如果画面切换就中断循环
- if $scene != self
- break
- end
- end
- $game_system.delete_new_skill
- $game_system.delete_actor_id
- # 准备过渡
- Graphics.freeze
- # 释放窗口
- @edit_window.dispose
- @input_window.dispose
- end
- #--------------------------------------------------------------------------
- # ● 刷新画面
- #--------------------------------------------------------------------------
- def update
- # 刷新窗口
- @edit_window.update
- @input_window.update
- # 按下 B 键的情况下
- if Input.repeat?(Input::B)
- # 光标位置为 0 的情况下
- if @edit_window.index == 0
- return
- end
- # 演奏取消 SE
- $game_system.se_play($data_system.cancel_se)
- # 删除文字
- @edit_window.back
- return
- end
- # 按下 C 键的情况下
- if Input.trigger?(Input::C)
- # 光标位置为 [确定] 的情况下
- if @input_window.character == nil
- # 名称为空的情况下
- if @edit_window.name == ""
- # 还原为默认名称
- @edit_window.restore_default
- # 名称为空的情况下
- if @edit_window.name == ""
- # 演奏冻结 SE
- $game_system.se_play($data_system.buzzer_se)
- return
- end
- # 演奏确定 SE
- $game_system.se_play($data_system.decision_se)
- return
- end
- # 更改角色名称
- $game_system.push_skill_name(@id,@edit_window.name)
- # 演奏确定 SE
- $game_system.se_play($data_system.decision_se)
- # 切换到地图画面
- $scene = Scene_Map.new
- return
- end
- # 光标位置为最大的情况下
- # if @edit_window.index == $game_temp.name_max_char
- # # 演奏冻结 SE
- # $game_system.se_play($data_system.buzzer_se)
- # return
- # end
- # 文字为空的情况下
- if @input_window.character == ""
- # 演奏冻结 SE
- $game_system.se_play($data_system.buzzer_se)
- return
- end
- # 演奏确定 SE
- $game_system.se_play($data_system.decision_se)
- # 添加文字
- @edit_window.add(@input_window.character)
- return
- end
- end
- end
-
- class Window_NameEdit2 < Window_Base
- #--------------------------------------------------------------------------
- # ● 定义实例变量
- #--------------------------------------------------------------------------
- attr_reader :name # 名称
- attr_reader :index # 光标位置
- #--------------------------------------------------------------------------
- # ● 初始化对像
- # actor : 角色
- # max_char : 最大字数
- #--------------------------------------------------------------------------
- def initialize(actor, max_char,skill_id)
- super(0, 0, 640, 160)
- self.contents = Bitmap.new(width - 32, height - 32)
- @actor = actor
- @name = $data_skills[skill_id].name
- @max_char = max_char
- @skill_id = skill_id
- # 控制名字在最大字数以内
- name_array = @name.split(//)[0...@max_char]
- @name = ""
- for i in 0...name_array.size
- @name += name_array[i]
- end
- @default_name = @name
- @index = name_array.size
- refresh
- update_cursor_rect
- end
- #--------------------------------------------------------------------------
- # ● 还原为默认的名称
- #--------------------------------------------------------------------------
- def restore_default
- @name = @default_name
- @index = @name.split(//).size
- refresh
- update_cursor_rect
- end
- #--------------------------------------------------------------------------
- # ● 添加文字
- # character : 要添加的文字
- #--------------------------------------------------------------------------
- def add(character)
- if @index < @max_char and character != ""
- @name += character
- @index += 1
- refresh
- update_cursor_rect
- end
- end
- #--------------------------------------------------------------------------
- # ● 删除文字
- #--------------------------------------------------------------------------
- def back
- if @index > 0
- # 删除一个字
- name_array = @name.split(//)
- @name = ""
- for i in 0...name_array.size-1
- @name += name_array[i]
- end
- @index -= 1
- refresh
- update_cursor_rect
- end
- end
- #--------------------------------------------------------------------------
- # ● 刷新
- #--------------------------------------------------------------------------
- def refresh
- self.contents.clear
- # 描绘名称
- name_array = @name.split(//)
- for i in 0...@max_char
- c = name_array[i]
- if c == nil
- c = "_"
- end
- x = 320 - @max_char * 14 + i * 28
- self.contents.draw_text(x, 32, 28, 32, c, 1)
- end
- self.contents.draw_text(32,90,500,32,"新技能:"+$data_skills[@skill_id].description)
- # 描绘图形
- draw_actor_graphic(@actor, 320 - @max_char * 14 - 40, 80)
- end
- #--------------------------------------------------------------------------
- # ● 刷新光标矩形
- #--------------------------------------------------------------------------
- def update_cursor_rect
- x = 320 - @max_char * 14 + @index * 28
- self.cursor_rect.set(x, 32, 28, 32)
- end
- #--------------------------------------------------------------------------
- # ● 刷新画面
- #--------------------------------------------------------------------------
- def update
- super
- update_cursor_rect
- end
- end
-
- #==============================================================================
- # ■ Window_NameInput
- #------------------------------------------------------------------------------
- # 输入名称的画面、文字选择窗口。
- #==============================================================================
- class Window_NameInput2 < Window_Base
- CHARACTER_TABLE =
- [
- "天","い","う","え","お",
- "か","き","く","け","こ",
- "さ","し","す","せ","そ",
- "た","ち","つ","て","と",
- "な","に","ぬ","ね","の",
- "は","ひ","ふ","へ","ほ",
- "ま","み","む","め","も",
- "や", "" ,"ゆ", "" ,"よ",
- "ら","り","る","れ","ろ",
- "わ", "" ,"を", "" ,"ん",
- "が","ぎ","ぐ","げ","ご",
- "ざ","じ","ず","ぜ","ぞ",
- "だ","ぢ","づ","で","ど",
- "ば","び","ぶ","べ","ぼ",
- "ぱ","ぴ","ぷ","ぺ","ぽ",
- "ゃ","ゅ","ょ","っ","ゎ",
- "ぁ","ぃ","ぅ","ぇ","ぉ",
- "ー","・", "" , "" , "" ,
- "ア","イ","ウ","エ","オ",
- "カ","キ","ク","ケ","コ",
- "サ","シ","ス","セ","ソ",
- "タ","チ","ツ","テ","ト",
- "ナ","ニ","ヌ","ネ","ノ",
- "ハ","ヒ","フ","ヘ","ホ",
- "マ","ミ","ム","メ","モ",
- "ヤ", "" ,"ユ", "" ,"ヨ",
- "ラ","リ","ル","レ","ロ",
- "ワ", "" ,"ヲ", "" ,"ン",
- "ガ","ギ","グ","ゲ","ゴ",
- "ザ","ジ","ズ","ゼ","ゾ",
- "ダ","ヂ","ヅ","デ","ド",
- "バ","ビ","ブ","ベ","ボ",
- "パ","ピ","プ","ペ","ポ",
- "ャ","ュ","ョ","ッ","ヮ",
- "ァ","ィ","ゥ","ェ","ォ",
- "ー","・","ヴ", "" , "" ,
- ]
- #--------------------------------------------------------------------------
- # ● 初始化对像
- #--------------------------------------------------------------------------
- def initialize
- super(0, 160, 640, 320)
- self.contents = Bitmap.new(width - 32, height - 32)
- @index = 0
- refresh
- update_cursor_rect
- end
- #--------------------------------------------------------------------------
- # ● 获取文字
- #--------------------------------------------------------------------------
- def character
- return CHARACTER_TABLE[@index]
- end
- #--------------------------------------------------------------------------
- # ● 刷新
- #--------------------------------------------------------------------------
- def refresh
- self.contents.clear
- for i in 0..179
- x = 4 + i / 5 / 9 * 152 + i % 5 * 24
- y = i / 5 % 9 * 28
- self.contents.draw_text(x, y, 28, 32, CHARACTER_TABLE[i], 1)
- end
- self.contents.draw_text(544, 8 * 32, 64, 32, "确定", 1)
- end
- #--------------------------------------------------------------------------
- # ● 刷新光标矩形
- #--------------------------------------------------------------------------
- def update_cursor_rect
- # 光标位置在 [确定] 的情况下
- if @index >= 180
- self.cursor_rect.set(544, 8 * 32, 64, 32)
- # 光标位置在 [确定] 以外的情况下
- else
- x = 4 + @index / 5 / 9 * 152 + @index % 5 * 24
- y = @index / 5 % 9 * 28
- self.cursor_rect.set(x, y, 28, 32)
- end
- end
- #--------------------------------------------------------------------------
- # ● 刷新画面
- #--------------------------------------------------------------------------
- def update
- super
- # 光标位置在 [确定] 的情况下
- if @index >= 180
- # 光标下
- if Input.trigger?(Input::DOWN)
- $game_system.se_play($data_system.cursor_se)
- @index -= 180
- end
- # 光标上
- if Input.repeat?(Input::UP)
- $game_system.se_play($data_system.cursor_se)
- @index -= 180 - 40
- end
- # 光标位置在 [确定] 以外的情况下
- else
- # 按下方向键右的情况下
- if Input.repeat?(Input::RIGHT)
- # 按下状态不是重复的情况下、
- # 光标位置不在右端的情况下
- if Input.trigger?(Input::RIGHT) or
- @index / 45 < 3 or @index % 5 < 4
- # 光标向右移动
- $game_system.se_play($data_system.cursor_se)
- if @index % 5 < 4
- @index += 1
- else
- @index += 45 - 4
- end
- if @index >= 180
- @index -= 180
- end
- end
- end
- # 按下方向键左的情况下
- if Input.repeat?(Input::LEFT)
- # 按下状态不是重复的情况下、
- # 光标位置不在左端的情况下
- if Input.trigger?(Input::LEFT) or
- @index / 45 > 0 or @index % 5 > 0
- # 光标向右移动
- $game_system.se_play($data_system.cursor_se)
- if @index % 5 > 0
- @index -= 1
- else
- @index -= 45 - 4
- end
- if @index < 0
- @index += 180
- end
- end
- end
- # 按下方向键下的情况下
- if Input.repeat?(Input::DOWN)
- # 光标向下移动
- $game_system.se_play($data_system.cursor_se)
- if @index % 45 < 40
- @index += 5
- else
- @index += 180 - 40
- end
- end
- # 按下方向键上的情况下
- if Input.repeat?(Input::UP)
- # 按下状态不是重复的情况下、
- # 光标位置不在上端的情况下
- if Input.trigger?(Input::UP) or @index % 45 >= 5
- # 光标向上移动
- $game_system.se_play($data_system.cursor_se)
- if @index % 45 >= 5
- @index -= 5
- else
- @index += 180
- end
- end
- end
- # L 键与 R 键被按下的情况下
- if Input.repeat?(Input::L) or Input.repeat?(Input::R)
- # 平假名 / 片假名 之间移动
- $game_system.se_play($data_system.cursor_se)
- if @index / 45 < 2
- @index += 90
- else
- @index -= 90
- end
- end
- end
- update_cursor_rect
- end
- end
-
- module RPG
- class Skill
- def name
- if $game_system.skill_name(@id) != nil
- return $game_system.skill_name(@id)
- else
- return @name
- end
- end
- end
- end
复制代码 脚本Scene_Map的49行下方,加上
$scene = Scene_Name2.new if $game_system.new_skill != [] |
|