赞 | 1 |
VIP | 17 |
好人卡 | 3 |
积分 | 1 |
经验 | 49919 |
最后登录 | 2020-2-6 |
在线时间 | 898 小时 |
Lv1.梦旅人 矿工
- 梦石
- 0
- 星屑
- 134
- 在线时间
- 898 小时
- 注册时间
- 2012-10-5
- 帖子
- 1535
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员
x
本帖最后由 876加几 于 2013-10-4 15:50 编辑
单元数判断:方法:用数组新建任务就会总是提示.size出错,帮助文本本来就这么写的呀,怎么会出错呢?
原脚本:- #==============================================================================
- # ■ Window_Task
- #------------------------------------------------------------------------------
- # 显示任务的选择行窗口。
- #==============================================================================
- class Window_Task < Window_Selectable
- #--------------------------------------------------------------------------
- # ● 初始化对像
- #--------------------------------------------------------------------------
- def initialize
- super(0, 0, 640, 480 - 64)
- @name = nil
- @task_help = nil
- [url=home.php?mod=space&uid=236945]@gold[/url] = nil
- @items = nil
- @weapons = nil
- @armors = nil
- @item = nil
- [url=home.php?mod=space&uid=36793]@weapon[/url] = nil
- @armor = nil
- if @name == nil
- @item_max = 1
- else
- @item_max = @name.size
- end
- difficulty = nil
- self.contents = Bitmap.new(width - 32, height - 32)
- refresh
- self.index = -1
- end
- #--------------------------------------------------------------------------
- # ● 刷新
- #--------------------------------------------------------------------------
- def refresh
- self.contents.clear
- if @name == nil
- @item_max = 1
- else
- @item_max = @name.size
- end
- end
- #--------------------------------------------------------------------------
- # ● 报偿设置
- # item_id/weapon_id/armor_id : 报偿物品在数据库中的位置,nil等于没报偿
- #--------------------------------------------------------------------------
- def reward_items(item_id = nil)
- @item[@item.size] = item_id
- end
- def reward_weapons(weapon_id = nil)
- @weapon[@weapon.size] = weapon_id
- end
- def reward_armor(armor_id = nil)
- @armor[@armor.size] = armor_id
- end
- #--------------------------------------------------------------------------
- # ● 新建任务
- # new_name : 新任务的名称
- # task_help : 新任务的简介
- # difficulty : 新任务的难度
- # gold : 金钱报偿,0等于没报偿
- #--------------------------------------------------------------------------
- def new_task(new_name, task_help, difficulty = 1, gold = 0)
- @name_size = @name.size
- @task_help_size = @task_help.size
- difficulty_size = difficulty.size
- @gold_size = @gold.size
- @items_size = @items.size
- @weapons_size = @weapons.size
- @armors_size = @armors.size
- @name[@name_size] = new_name
- @name2[@name_size] = new_name
- @task_help[@task_help_size] = task_help
- difficulty[difficulty_size] = difficulty
- @gold[@gold_size] = gold
- @items[@items_size] = @item
- @weapons[@weapons_size] = @weapon
- @armors[@armors_size] = @armor
- end
- #--------------------------------------------------------------------------
- # ● 完成任务
- # bbb : 任务ID
- #--------------------------------------------------------------------------
- def final_task(bbb)
- [url=home.php?mod=space&uid=110690]@BBB[/url] = bbb - 1
- unless @name[@bbb].include?("(已失败)")
- @name[@bbb] = @name[@bbb] + "(已完成)"
- @task_help[@bbb] = @task_help[@bbb] + "(已完成)"
- $game_party.gain_gold(@gold[bbb])
- for i in [email protected]
- if @item != nil
- $game_party.gain_item(@item[i], 1)
- end
- end
- for i in [email protected]
- if @weapon != nil
- $game_party.gain_weapon(@weapon[i], 1)
- end
- end
- for i in [email protected]
- if @armor != nil
- $game_party.gain_armor(@armor[i], 1)
- end
- end
- end
- end
- #--------------------------------------------------------------------------
- # ● 任务失败
- # ccc : 任务ID
- #--------------------------------------------------------------------------
- def lose_task(ccc)
- [url=home.php?mod=space&uid=9267]@CCC[/url] = ccc - 1
- unless @name[@bbb].include?("(已完成)")
- @name[@ccc] = @name[@ccc] + "(已失败)"
- @task_help[@ccc] = @task_help[@ccc] + "(已失败)"
- end
- end
- #--------------------------------------------------------------------------
- # ● 描绘项目
- # index : 项目编号
- # color : 文字色
- #--------------------------------------------------------------------------
- def draw_item(index,color)
- self.contents.font.color = color
- rect = Rect.new(4, 32 * index, 640 / 2 - 8, 32)
- self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
- self.contents.draw_text(rect, @name[index])
- end
- #--------------------------------------------------------------------------
- # ● 项目无效化
- # index : 项目编号
- #--------------------------------------------------------------------------
- def disable_item(index)
- draw_item(index, disabled_color)
- end
- #--------------------------------------------------------------------------
- # ● 刷新光标矩形
- #--------------------------------------------------------------------------
- def update_cursor_rect
- if [url=home.php?mod=space&uid=370741]@Index[/url] < 0
- self.cursor_rect.empty
- else
- self.cursor_rect.set(0, @index * 56, 320 - 8, 32)
- end
- end
- #--------------------------------------------------------------------------
- # ● 拆分数组并显示内容
- #--------------------------------------------------------------------------
- def update
- for i in 0...@item_max
- x = 320 + 16
- if self.index == i and $t == true
- refresh
- self.contents.font.color = system_color
- self.contents.draw_text(x, 0, 100, 32, "任务名:")
- self.contents.draw_text(x, 64, 100, 32, "难度:")
- self.contents.draw_text(x, 112, 100, 32, "说明:")
- if @gold[index] != 0
- self.contents.draw_text(x, 176, 100, 32, "奖励金钱:")
- y = 240
- else
- y = 208
- end
- if @items[index] != nil
- self.contents.draw_text(x, y, 100, 32, "奖励物品:")
- end
- self.contents.font.color = normal_color
- self.contents.draw_text(x, 32, 320 - 32, 32, @name2[index])
- self.contents.draw_text(x, 144, 280, 32, @task_help[index])
- if @gold[index] != 0
- self.contents.draw_text(x, 208, 100, 32, @gold[index])
- end
- if @items[index] != nil and @item != nil
- for j in [email protected]
- @y = y + @item[j] * 32
- end
- for g in [email protected]
- draw_item_name($data_items[@item[g]], x, @y)
- end
- for g in [email protected]
- draw_item_name($data_weapons[@weapon[g]], x, @y + @item.size * 32)
- end
- for g in [email protected]
- draw_item_name($data_armors[@armor[g]], x, @y + @item.size * 32 + @weapon.size * 32)
- end
- end
- #Moon = difficulty[index] / DIFFICULTY::System
- #Star = difficulty[index] % DIFFICULTY::System
- #Sun = Moon / DIFFICULTY::System
- #Moon %= DIFFICULTY::System
- #Space = DIFFICULTY::Space
- #rect = Rect.new(0, 0, DIFFICULTY::Size, DIFFICULTY::Size)
- #while Sun>0
- # self.contents.blt(x + Space, 96, Sun, rect)
- # Space += DIFFICULTY::Size + DIFFICULTY::Space;Sun -= 1
- #end
- #while Moon>0
- # self.contents.blt(x + Space, 97, Moon, rect)
- # Space += DIFFICULTY::Size + DIFFICULTY::Space;Moon -= 1
- #end
- #while Star>0
- # self.contents.blt(x + Space, 98, Star, rect)
- # Space += DIFFICULTY::Size + DIFFICULTY::Space;Star -= 1
- #end
- case difficulty[index]
- when 1
- self.contents.draw_text(x + 60, 64, 280, 32, "★☆☆☆☆")
- when 2
- self.contents.draw_text(x + 60, 64, 280, 32, "★★☆☆☆")
- when 3
- self.contents.draw_text(x + 60, 64, 280, 32, "★★★☆☆")
- when 4
- self.contents.draw_text(x + 60, 64, 280, 32, "★★★★☆")
- when 5
- self.contents.draw_text(x + 60, 64, 280, 32, "★★★★★")
- end
- end
- end
- end
- end
复制代码 |
|