Project1
标题:
“字符串”技能树
[打印本页]
作者:
恐惧剑刃
时间:
2013-10-18 22:02
标题:
“字符串”技能树
本帖最后由 恋′挂机 于 2013-10-18 22:06 编辑
源自:
http://rpg.blue/thread-336098-1-1.html
看似很复杂,其实很简单。
脚本参考,当然要自行做一些整合
选择窗口
# --------------------
# 重要!!!!!!!!
# --------------------
attr_accessor :skill_case
attr_accessor :shuzhi_hash
复制代码
初始化
# --------------------
# 重要!!!!!!!!
# --------------------
# 判断选择状态用的哈希表
@skill_case = {}
# 树枝的哈希表
@shuzhi_hash = {}
复制代码
添加
# ------------------
# 描绘图标与树枝
# ------------------
# 循环准备
xunhuan_time = 0
jineng_time = 0
# 简化
#@shuzhi_array.size - 1
#@shuzhi_array[jianqu1].split(/◎/)[0].to_i
jianqu1 = @shuzhi_array.size - 1
jxmh = @shuzhi_array[jianqu1].split(/◎/)[0].to_i
# 矩形
rect = Rect.new(0, 0, 24, 24)
# 循环
for i in @shuzhi_array
# 坐标
x = (xunhuan_time % jxmh) * 32 + 4
y = (xunhuan_time / jxmh) * 32 + 4
# 不等与"☆"描绘
if i != "☆"
case i
# 技能图标
when "★"
# 图标透明度
unless @actor.skills.include?(@skill[jineng_time].id)
opacity_icon = 160
else
opacity_icon = 255
end
self.contents.blt(x, y, @icon[jineng_time], rect, opacity_icon)
# 以XY坐标为主键技能为值
@skill_case[x.to_s+"◎"+y.to_s] = @skill[jineng_time]
jineng_time += 1
# 树枝
when "→"
self.contents.blt(x, y, @shuzhi_picture[0], rect)
# 以XY坐标为主键方向字符为值
@shuzhi_hash[x.to_s+"◎"+y.to_s] = "→"
when "←"
self.contents.blt(x, y, @shuzhi_picture[1], rect)
# 以XY坐标为主键方向字符为值
@shuzhi_hash[x.to_s+"◎"+y.to_s] = "←"
when "↑"
self.contents.blt(x, y, @shuzhi_picture[2], rect)
# 以XY坐标为主键方向字符为值
@shuzhi_hash[x.to_s+"◎"+y.to_s] = "↑"
when "↓"
self.contents.blt(x, y, @shuzhi_picture[3], rect)
# 以XY坐标为主键方向字符为值
@shuzhi_hash[x.to_s+"◎"+y.to_s] = "↓"
when "↖"
self.contents.blt(x, y, @shuzhi_picture[4], rect)
# 以XY坐标为主键方向字符为值
@shuzhi_hash[x.to_s+"◎"+y.to_s] = "↖"
when "↗"
self.contents.blt(x, y, @shuzhi_picture[5], rect)
# 以XY坐标为主键方向字符为值
@shuzhi_hash[x.to_s+"◎"+y.to_s] = "↗"
when "↘"
self.contents.blt(x, y, @shuzhi_picture[6], rect)
# 以XY坐标为主键方向字符为值
@shuzhi_hash[x.to_s+"◎"+y.to_s] = "↘"
when "↙"
self.contents.blt(x, y, @shuzhi_picture[7], rect)
# 以XY坐标为主键方向字符为值
@shuzhi_hash[x.to_s+"◎"+y.to_s] = "↙"
end
end
# 项目判断
xunhuan_time += 1
end
复制代码
帮助刷新
# 刷新帮助
def update_help
# 为了刷新,就只好牺牲内存了
# 判断
#if self.index != @old_index
# 隐藏帮助
@help_window.visible = false
# 简化写法
jianqu1 = @shuzhi_array.size - 1
jxmh = @shuzhi_array[jianqu1].split(/◎/)[0].to_i
# 帮助坐标
x = (self.index % jxmh) * 32
y = (self.index / jxmh) * 32
# 循环
for i in @skill_case.keys
# 判断
if i == (x+4).to_s+"◎"+(y+4).to_s
@help_window.set_text(
x + 50, y, @skill_case[(x+4).to_s+"◎"+(y+4).to_s], @actor)
end
end
# @old_index = self.index
#end
end
复制代码
# 刷新选择窗口
def update_select_window
# B键的按下
if Input.trigger?(Input::B)
$scene = Scene_Map.new
end
# C键的按下
if Input.trigger?(Input::C)
# 获取坐标,以坐标为媒介(主键)获取相关信息
# 坐标
jianqu1 = SHEZHI::ACTOR_ARRAY[@actor.id].size - 1
jxmh = SHEZHI::ACTOR_ARRAY[@actor.id][jianqu1].split(/◎/)[0].to_i
x = (@select_window.index % jxmh) * 32 + 4
y = (@select_window.index / jxmh) * 32 + 4
# 判断是否选中技能
if @select_window.skill_case[x.to_s+"◎"+y.to_s] != nil
# 简化,方便之后使用skill值
skill = @select_window.skill_case[x.to_s+"◎"+y.to_s]
# 判断技能是否已经领悟
unless @actor.skills.include?(skill)
# ------------------
# 判断技能树关系
# (判断基础技能是否学习)
# ------------------
# 连接线:→←↑↓↖↗↘↙
# ------------------
# 判断准备
base_skill_array = []
# 左边:
x_copy = x - 32
y_copy = y
if @select_window.shuzhi_hash[x_copy.to_s+"◎"+y_copy.to_s] != nil
# 简化
shuzhi = @select_window.shuzhi_hash[x_copy.to_s+"◎"+y_copy.to_s]
# 分歧
if shuzhi == "→"
# 获得基础技能坐标
x_copy = x - 64
y_copy = y
# 简化,通过基础技能坐标获取基础技能
base = @select_window.skill_case[x_copy.to_s+"◎"+y_copy.to_s]
base_skill_array << base
end
end
# 右边:
x_copy = x + 32
y_copy = y
if @select_window.shuzhi_hash[x_copy.to_s+"◎"+y_copy.to_s] != nil
# 简化
shuzhi = @select_window.shuzhi_hash[x_copy.to_s+"◎"+y_copy.to_s]
# 分歧
if shuzhi == "←"
# 获得基础技能坐标
x_copy = x + 64
y_copy = y
# 简化,通过基础技能坐标获取基础技能
base = @select_window.skill_case[x_copy.to_s+"◎"+y_copy.to_s]
base_skill_array << base
end
end
# 上边:
x_copy = x
y_copy = y - 32
if @select_window.shuzhi_hash[x_copy.to_s+"◎"+y_copy.to_s] != nil
# 简化
shuzhi = @select_window.shuzhi_hash[x_copy.to_s+"◎"+y_copy.to_s]
# 分歧
if shuzhi == "↓"
# 获得基础技能坐标
x_copy = x
y_copy = y - 64
# 简化,通过基础技能坐标获取基础技能
base = @select_window.skill_case[x_copy.to_s+"◎"+y_copy.to_s]
base_skill_array << base
end
end
# 下边:
x_copy = x
y_copy = y + 32
if @select_window.shuzhi_hash[x_copy.to_s+"◎"+y_copy.to_s] != nil
# 简化
shuzhi = @select_window.shuzhi_hash[x_copy.to_s+"◎"+y_copy.to_s]
# 分歧
if shuzhi == "↑"
# 获得基础技能坐标
x_copy = x
y_copy = y + 64
# 简化,通过基础技能坐标获取基础技能
base = @select_window.skill_case[x_copy.to_s+"◎"+y_copy.to_s]
base_skill_array << base
end
end
# 左上方:
x_copy = x - 32
y_copy = y - 32
if @select_window.shuzhi_hash[x_copy.to_s+"◎"+y_copy.to_s] != nil
# 简化
shuzhi = @select_window.shuzhi_hash[x_copy.to_s+"◎"+y_copy.to_s]
# 分歧
if shuzhi == "↘"
# 获得基础技能坐标
x_copy = x - 64
y_copy = y - 64
# 简化,通过基础技能坐标获取基础技能
base = @select_window.skill_case[x_copy.to_s+"◎"+y_copy.to_s]
base_skill_array << base
end
end
# 右上方:
x_copy = x + 32
y_copy = y - 32
if @select_window.shuzhi_hash[x_copy.to_s+"◎"+y_copy.to_s] != nil
# 简化
shuzhi = @select_window.shuzhi_hash[x_copy.to_s+"◎"+y_copy.to_s]
# 分歧
if shuzhi == "↙"
# 获得基础技能坐标
x_copy = x + 64
y_copy = y - 64
# 简化,通过基础技能坐标获取基础技能
base = @select_window.skill_case[x_copy.to_s+"◎"+y_copy.to_s]
base_skill_array << base
end
end
# 右下方:
x_copy = x + 32
y_copy = y + 32
if @select_window.shuzhi_hash[x_copy.to_s+"◎"+y_copy.to_s] != nil
# 简化
shuzhi = @select_window.shuzhi_hash[x_copy.to_s+"◎"+y_copy.to_s]
# 分歧
if shuzhi == "↖"
# 获得基础技能坐标
x_copy = x + 64
y_copy = y + 64
# 简化,通过基础技能坐标获取基础技能
base = @select_window.skill_case[x_copy.to_s+"◎"+y_copy.to_s]
base_skill_array << base
end
end
# 左下方:
x_copy = x - 32
y_copy = y + 32
if @select_window.shuzhi_hash[x_copy.to_s+"◎"+y_copy.to_s] != nil
# 简化
shuzhi = @select_window.shuzhi_hash[x_copy.to_s+"◎"+y_copy.to_s]
# 分歧
if shuzhi == "↗"
# 获得基础技能坐标
x_copy = x - 64
y_copy = y + 64
# 简化,通过基础技能坐标获取基础技能
base = @select_window.skill_case[x_copy.to_s+"◎"+y_copy.to_s]
base_skill_array << base
end
end
# 处理干净
@yes_or_no = nil
# 正式判断
if base_skill_array != []
for i in base_skill_array
# 任意一项基础技能已经领悟,把true就赋予@yes_or_no
if @actor.skills.include?(i.id)
@yes_or_no = true
end
end
if @yes_or_no
# 领悟技能
@actor.learn_skill(skill.id)
# 选择窗口刷新
@select_window.refresh
# 刷新帮助窗口
@select_window.update_help
end
else
# 领悟技能
@actor.learn_skill(skill.id)
# 选择窗口刷新
@select_window.refresh
# 刷新帮助窗口
@select_window.update_help
end
end#include?
end#select
end#if input c
end#def
复制代码
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1