/*:
 * @plugindesc v1.04 LinkLook 连连看
 * @author 流逝的岁月
 *
 * @help
 * ============================================================================
 * 介绍
 * ============================================================================
 *
 *
 * 这个插件内置了一款《连连看》的小游戏
 *
 *
 *《连连看》是由黄兴武创作的一款PC端益智类游戏 。
 *《连连看》只要将相同的两张牌用三根以内的直线连在一起就可以消除，规则简单容易上手。游戏速度节奏快，画面清晰可爱，适合细心的玩家。丰富的道具和公共模式的加入，增强游戏的竞争性。多样式的地图，使玩家在各个游戏水平都可以寻找到挑战的目标，长期地保持游戏的新鲜感。
 *
 *
 *
 *
 * 注意:运行这个插件至少需要LiuYue_GameCore(v1.20版本)(流月小游戏核心)作为前置插件
 *
 *
 *---------------------------------------------------------
 *
 *使用条例：本插件完全免费，随意魔改
 *
 *---------------------------------------------------------
 *
 *
 * 以下是在写入公式时可以带入的数据信息:
 *
 *
 *
 * variables : 这个值是全局变量数组
 * v : 同上
 * V : 同上
 * switchs : 这个值是全局开关数组
 * s : 同上
 * S : 同上
 * line : 这个值是行数,如果有,则存在
 * list : 这个值是列数,如果有,则存在
 * size : 这个值是每个星星方块的尺寸,如果有,则存在
 * type : 这个值是关卡中存在的方块的种类,如果有,则存在
 * level : 这个值是目前关卡等级的数值
 * score : 这个值是目前获取的分数
 * time : 这个值是目前所消耗的时间,注意是以帧数作为单位
 * maxlevel : 这个值游戏的最大通关等级,如果有,则存在
 *
 *
 *
 * 首先是对图片资源的介绍,以下单位均以xp(像素)为单位
 * '背景'图片                                                816 * 624(默认全屏)
 * '底板'图片                                                 48 * 48
 * '取消''退出''确认'按钮图片                                 91 * 50
 * '菜单背景板'图片                                          261 * 361
 * '暂停中'图片                                              326 * 83
 * '道具图片组'图片9*4                                       432 * 192
 * '时间条'图片                                              500 * 15
 * '时间条框'图片                                            500 * 15
 *
 *
 *
 * 以下是一些插件用到的插件指令
 *
 *---------------------Plugin Command--------------------
 *
 * ZzyGCF Play x                           //填入游戏名,这将进行小游戏,游戏名要和参数中设定的一致,默认为LinkLook
 *
 *
 *
 * ZzyGLL StartLevel x                     //设置开始游戏时的关卡数值,这可以是一个公式,默认值为1
 * ZzyGLL MaxLevel x                       //这会改变最大通关数,这可以是一个公式
 * ZzyGLL Time x                           //这会改变每一关的限制时间,这可以是一个公式
 * ZzyGLL Line x                           //这会改变每一关的方块行数,这可以是一个公式
 * ZzyGLL List x                           //这会改变每一关的方块列数,这可以是一个公式
 * ZzyGLL Size x                           //这会改变每一关方块的尺寸,这可以是一个公式
 * ZzyGLL Type x                           //这会改变每一关拥有的方块的类型,这可以是一个公式
 * ZzyGLL ConnectSocre x                   //这会改变连接方块时获取的分数,这可以是一个公式 
 * ZzyGLL SurplusSocre x                   //这会改变剩余时间每秒获得的奖励分数,这可以是一个公式 
 *
 *	
 *
 *
 *
 *
 * 以下是一些插件用到的脚本函数
 *
 *---------------------Script Function--------------------
 * 
 *
 * Zzy.GLL.StartLevel(value)                     //设置开始游戏时的关卡数值,这可以是一个公式,默认值为1
 * Zzy.GLL.MaxLevel(formula)               //这会改变最大通关数,这可以是一个公式
 * Zzy.GLL.Time(formula)                   //这会改变每一关的限制时间,这可以是一个公式
 * Zzy.GLL.Line(formula)                   //这会改变每一关的方块行数,这可以是一个公式
 * Zzy.GLL.List(formula)                   //这会改变每一关的方块列数,这可以是一个公式
 * Zzy.GLL.Size(formula)                   //这会改变每一关方块的尺寸,这可以是一个公式
 * Zzy.GLL.Type(formula)                   //这会改变每一关拥有的方块的类型,这可以是一个公式
 * Zzy.GLL.ConnectSocre(formula)           //这会改变连接方块时获取的分数,这可以是一个公式 
 * Zzy.GLL.SurplusScore(formula)           //这会改变剩余时间每秒获得的奖励分数,这可以是一个公式 
 *
 *
 *
 *
 *
 *
 *
 *----------------------------------------------------------
 *
 *
 * 我叫坂本：v1.04 拓展游戏结算后的事件执行参数,添加控制开始关卡参数
 * 我叫坂本：v1.03 拓展脚本函数,优化方块自适应间距
 * 我叫坂本：v1.02 可通过参数修改图片存放路径,额外存储变量
 * 我叫坂本：v1.01 添加更多可控制参数,添加与旧存档兼容
 * 我叫坂本：v1.00 完成插件功能
 *
 *----------------------------------------------------------
 *
 * @param ---主设置---
 * @default
 *
 *
 * @param GameName
 * @text 游戏名
 * @parent ---主设置---
 * @type text
 * @desc 这是启动游戏的名称,调用Play插件命令后填写的游戏名,默认为LinkLook
 * @default LinkLook
 *
 *
 *
 * @param ---事件执行---
 * @default
 *
 *
 * @param WinCommon
 * @text 胜利事件
 * @parent ---事件执行---
 * @type Number
 * @desc 这是小游戏结束后,如果以胜利告终,将会执行的事件ID,填0则不会执行,填写优先级会高于小游戏核心
 * @default 0
 *
 * @param WinScript
 * @text 胜利脚本
 * @parent ---事件执行---
 * @type note
 * @desc 填写优先级会高于小游戏核心
 * @default ""
 *
 *
 * @param FailCommon
 * @text 失败事件
 * @parent ---事件执行---
 * @type Number
 * @desc 这是小游戏结束后,如果以胜利告终,将会执行的事件ID,填0则不会执行,填写优先级会高于小游戏核心
 * @default 0
 *
 * @param FailScript
 * @text 失败脚本
 * @parent ---事件执行---
 * @type note
 * @desc 填写优先级会高于小游戏核心
 * @default ""
 *
 *
 * @param Other1Common
 * @text 特殊情况1事件
 * @parent ---事件执行---
 * @type Number
 * @desc 除了胜利和失败外,允许出现一些特殊形况,那种自定义的终止条件,填0则不会执行,填写优先级会高于小游戏核心
 * @default 0
 *
 * @param Other1Script
 * @text 特殊情况1脚本
 * @parent ---事件执行---
 * @type note
 * @desc 填写优先级会高于小游戏核心
 * @default ""
 *
 *
 * @param Other2Common
 * @text 特殊情况2事件
 * @parent ---事件执行---
 * @type Number
 * @desc 除了胜利和失败外,允许出现一些特殊形况,那种自定义的终止条件,填0则不会执行,填写优先级会高于小游戏核心
 * @default 0
 *
 * @param Other2Script
 * @text 特殊情况2脚本
 * @parent ---事件执行---
 * @type note
 * @desc 填写优先级会高于小游戏核心
 * @default ""
 *
 * @param SaveScoreVariable
 * @text 存放分数变量
 * @parent ---事件执行---
 * @type Variable
 * @desc 这是在进行游戏后,存放分数变量的ID值,这个变量是额外对这款游戏的分数进行存储,与核心中的存放不冲突,填0则不会存储
 * @default 0
 *
 * @param SaveTimeVariable
 * @text 存放耗时变量
 * @parent ---事件执行---
 * @type Variable
 * @desc 这是在进行游戏后,存放事件变量的ID值,这个变量是额外对这款游戏的耗时进行存储,与核心中的存放不冲突,填0则不会存储
 * @default 0
 *
 * @param ---图片路径---
 * @default
 *
 * @param PicPath
 * @text 图片路径
 * @parent ---图片路径---
 * @type text
 * @desc 存储图片的路径,默认值是在pictures文件夹中,改成自定义文件夹请确保文件夹存在
 * @default img/pictures/LinkLook/
 *
 * @param ---图片资源---
 * @default
 *
 *
 * @param BackGroundPic
 * @text 背景图片
 * @parent ---图片资源---
 * @type text
 * @desc 如果填写了背景图片的文件名,则会作为背景图片,如果没有填写,会默认使用GameCore参数的背景图片
 * @default LLBk
 *
 * @param PausePic
 * @text 暂停图片
 * @parent ---图片资源---
 * @type text
 * @desc 暂停情况下显示的图片,图片放在Pictures文件夹中,如果没有填写,会默认使用GameCore参数中默认的背景图片
 * @default LLPause
 *
 * @param ItemArrPic
 * @text 道具图片组
 * @parent ---图片资源---
 * @type text
 * @desc 道具图片组的显示,请输入图片名称,图片放在Pictures文件夹中,写入正确的后缀名称
 * @default LLItems_9x4
 *
 * @param BkBlockPic
 * @text 方块底板
 * @parent ---图片资源---
 * @type text
 * @desc 方块底板的显示,请输入图片名称,图片放在Pictures文件夹中,写入正确的后缀名称
 * @default LLBlock
 *
 *
 * @param MenuBkPic
 * @text 菜单底板
 * @parent ---图片资源---
 * @type text
 * @desc 菜单底板图片的显示,请输入图片名称,图片放在Pictures文件夹中
 * @default LLMenuBk
 *
 * @param TimePic
 * @text 时间条图片
 * @parent ---图片资源---
 * @type text
 * @desc 计时器的时间条图片,图片放在Pictures文件夹中
 * @default LLTime
 *
 * @param TimeBkPic
 * @text 时间条背景图片
 * @parent ---图片资源---
 * @type text
 * @desc 计时器的时间条背景图片,图片放在Pictures文件夹中
 * @default LLTimeBk
 *
 * @param OkButtonPic
 * @text 确认按钮
 * @parent ---图片资源---
 * @type text
 * @desc 确认按钮的图片名称,图片放在Pictures文件夹中,注意按钮有3张图片,后两张后缀标注'1','2'
 * @default LLOk
 *
 * @param CancelButtonPic
 * @text 取消按钮
 * @parent ---图片资源---
 * @type text
 * @desc 取消按钮的图片名称,图片放在Pictures文件夹中,注意按钮有3张图片,后两张后缀标注'1','2'
 * @default LLCancel
 *
 * @param ExitButtonPic
 * @text 退出按钮
 * @parent ---图片资源---
 * @type text
 * @desc 退出按钮的图片名称,图片放在Pictures文件夹中,注意按钮有3张图片,后两张后缀标注'1','2'
 * @default LLExit
 *
 *
 * @param ---额外设置---
 * @default
 *
 *
 * @param ConnectSpeed
 * @text 连接速度
 * @parent ---额外设置---
 * @type number
 * @desc 两个方块连接的速度,默认值为10
 * @default 10
 *
 *
 *
 *
 * @param ---数据设置---
 * @default
 *
 * @param StartLevel
 * @parent ---数据设置---
 * @text 关卡起始数值
 * @type Text
 * @desc 这是游戏开始时的关卡值,这可以是一个公式,默认数值为1
 * @default 1
 *
 * @param MaxLevel
 * @text 最大关卡数
 * @parent ---数据设置---
 * @type text
 * @desc 这是能进行的关卡数量,关卡会从第一关开始,这可以是一个公式
 * @default 10
 *
 * @param CpTime
 * @text 关卡限制时间
 * @parent ---数据设置---
 * @type text
 * @desc 每个关卡内限制的到达的时间,单位为秒,这可以是一个公式,默认为90秒
 * @default 90
 *
 * @param CpLine
 * @text 关卡方块行数
 * @parent ---数据设置---
 * @type text
 * @desc 每个关卡内限制的关卡方块行数,单位为秒,这可以是一个公式,默认为8
 * @default 8
 *
 * @param CpList
 * @text 关卡方块列数
 * @parent ---数据设置---
 * @type text
 * @desc 每个关卡内限制的关卡方块列数,单位为秒,这可以是一个公式,默认为12
 * @default 12
 *
 * @param CpSize
 * @text 关卡方块尺寸
 * @parent ---数据设置---
 * @type text
 * @desc 每个关卡内限制的关卡方块大小,单位为像素,这可以是一个公式,默认为48
 * @default 48
 *
 * @param CpType
 * @text 关卡消除类型数
 * @parent ---数据设置---
 * @type text
 * @desc 每个关卡内的连连看类型,,这可以是一个公式,默认为Math.min(Math.max(9,Math.floor(this.level/2+9)),18);
 * @default Math.min(Math.max(9,Math.floor(this.level/2+9)),18);
 *
 *
 * @param ConnectSocre
 * @text 连接得分
 * @parent ---数据设置---
 * @type text
 * @desc 方块进行连接时,获得的分数,这可以是一个公式,默认为10
 * @default 10
 *
 * @param SurplusTimeSocre
 * @text 剩余时间得分
 * @parent ---数据设置---
 * @type text
 * @desc 通关后剩余的时间每秒数获得的额外分数,这可以是一个公式,默认为5
 * @default 5
 *
 *
 *
 *
 * @param ---特殊结束条件1---
 * @default
 *
 * @param OtherEnd1Script
 * @text 特殊情况1脚本
 * @parent ---特殊结束条件1---
 * @type note
 * @desc 
 * @default ""
 *
 *
 * @param ---特殊结束条件2---
 * @default
 *
 * @param OtherEnd2Script
 * @text 特殊情况2脚本
 * @parent ---特殊结束条件2---
 * @type note
 * @desc 
 * @default ""
 *
 *
 *
 *
 * @param ---画面调整---
 * @default
 *
 * @param LevelSprT
 * @text 关卡文本
 * @parent ---画面调整---
 * @type text
 * @desc 显示的文本内容
 * @default 关卡:
 *
 * @param LevelSprX
 * @text 关卡文本X
 * @parent ---画面调整---
 * @type text
 * @desc 显示的文本位置X,可以输入一段代码
 * @default Graphics.boxWidth/4
 *
 * @param LevelSprY
 * @text 关卡文本Y
 * @parent ---画面调整---
 * @type text
 * @desc 显示的文本位置Y,可以输入一段代码
 * @default 80
 *
 *
 * @param LevelSprTS
 * @text 关卡文本大小
 * @parent ---画面调整---
 * @type number
 * @desc 显示的文本大小
 * @default 36
 *
 *
 * @param LevelSprTC
 * @text 关卡文本颜色
 * @parent ---画面调整---
 * @type text
 * @desc 显示的文本颜色,可输入两种样式的颜色码
 * @default #ddff88
 *
 * @param LevelSprBS
 * @text 关卡文本边框大小
 * @parent ---画面调整---
 * @type number
 * @desc 显示的文本边框大小
 * @default 4
 *
 *
 * @param LevelSprBC
 * @text 关卡文本边框颜色
 * @parent ---画面调整---
 * @type text
 * @desc 显示的文本边框颜色,可输入两种样式的颜色码
 * @default rgba(0,0,0,0.5)
 *
 *
 *
 * @param ScoreSprT
 * @text 分数文本
 * @parent ---画面调整---
 * @type text
 * @desc 显示的文本内容
 * @default 分数:
 *
 * @param ScoreSprX
 * @text 分数文本X
 * @parent ---画面调整---
 * @type text
 * @desc 显示的文本位置X,可以输入一段代码
 * @default Graphics.boxWidth/2+50
 *
 * @param ScoreSprY
 * @text 分数文本Y
 * @parent ---画面调整---
 * @type text
 * @desc 显示的文本位置Y,可以输入一段代码
 * @default 80
 *
 *
 * @param ScoreSprTS
 * @text 分数文本大小
 * @parent ---画面调整---
 * @type number
 * @desc 显示的文本大小
 * @default 36
 *
 *
 * @param ScoreSprTC
 * @text 分数文本颜色
 * @parent ---画面调整---
 * @type text
 * @desc 显示的文本颜色,可输入两种样式的颜色码
 * @default #ddff88
 *
 * @param ScoreSprBS
 * @text 分数文本边框大小
 * @parent ---画面调整---
 * @type number
 * @desc 显示的文本边框大小
 * @default 4
 *
 *
 * @param ScoreSprBC
 * @text 分数文本边框颜色
 * @parent ---画面调整---
 * @type text
 * @desc 显示的文本边框颜色,可输入两种样式的颜色码
 * @default rgba(0,0,0,0.5)
 *
 *
 *
 * @param MaxScoreSprT
 * @text 最高分文本
 * @parent ---画面调整---
 * @type text
 * @desc 显示的文本内容
 * @default 最高分:
 *
 * @param MaxScoreSprX
 * @text 最高分文本X
 * @parent ---画面调整---
 * @type text
 * @desc 显示的文本位置X,可以输入一段代码
 * @default Graphics.boxWidth*3/4+120
 *
 * @param MaxScoreSprY
 * @text 最高分文本Y
 * @parent ---画面调整---
 * @type text
 * @desc 显示的文本位置Y,可以输入一段代码
 * @default 80
 *
 *
 * @param MaxScoreSprTS
 * @text 最高分文本大小
 * @parent ---画面调整---
 * @type number
 * @desc 显示的文本大小
 * @default 36
 *
 *
 * @param MaxScoreSprTC
 * @text 最高分文本颜色
 * @parent ---画面调整---
 * @type text
 * @desc 显示的文本颜色,可输入两种样式的颜色码
 * @default #ddff88
 *
 * @param MaxScoreSprBS
 * @text 最高分文本边框大小
 * @parent ---画面调整---
 * @type number
 * @desc 显示的文本边框大小
 * @default 4
 *
 *
 * @param MaxScoreSprBC
 * @text 最高分文本边框颜色
 * @parent ---画面调整---
 * @type text
 * @desc 显示的文本边框颜色,可输入两种样式的颜色码
 * @default rgba(0,0,0,0.5)
 *
 *
 *
 * @param TimeSprT
 * @text 时间文本
 * @parent ---画面调整---
 * @type text
 * @desc 显示的文本内容
 * @default 时间
 *
 * @param TimeSprX
 * @text 时间文本X
 * @parent ---画面调整---
 * @type text
 * @desc 显示的文本位置X,可以输入一段代码
 * @default Graphics.boxWidth/5-40
 *
 * @param TimeSprY
 * @text 时间文本Y
 * @parent ---画面调整---
 * @type text
 * @desc 显示的文本位置Y,可以输入一段代码
 * @default Graphics.boxHeight/5+20
 *
 *
 * @param TimeSprTS
 * @text 时间文本大小
 * @parent ---画面调整---
 * @type number
 * @desc 显示的文本大小
 * @default 36
 *
 *
 * @param TimeSprTC
 * @text 时间文本颜色
 * @parent ---画面调整---
 * @type text
 * @desc 显示的文本颜色,可输入两种样式的颜色码
 * @default #ddff88
 *
 * @param TimeSprBS
 * @text 时间文本边框大小
 * @parent ---画面调整---
 * @type number
 * @desc 显示的文本边框大小
 * @default 4
 *
 *
 * @param TimeSprBC
 * @text 时间文本边框颜色
 * @parent ---画面调整---
 * @type text
 * @desc 显示的文本边框颜色,可输入两种样式的颜色码
 * @default rgba(0,0,0,0.5)
 *
 *
 *
 * @param ScoreTotalT
 * @text 总分文本
 * @parent ---画面调整---
 * @type text
 * @desc 显示的文本内容
 * @default 总分:
 *
 * @param ScoreTotalX
 * @text 总分文本X
 * @parent ---画面调整---
 * @type text
 * @desc 显示的文本位置X,可以输入一段代码
 * @default Graphics.boxWidth/2+50
 *
 * @param ScoreTotalY
 * @text 总分文本Y
 * @parent ---画面调整---
 * @type text
 * @desc 显示的文本位置Y,可以输入一段代码
 * @default Graphics.boxHeight/2
 *
 *
 * @param ScoreTotalTS
 * @text 总分文本大小
 * @parent ---画面调整---
 * @type number
 * @desc 显示的文本大小
 * @default 36
 *
 *
 * @param ScoreTotalTC
 * @text 总分文本颜色
 * @parent ---画面调整---
 * @type text
 * @desc 显示的文本颜色,可输入两种样式的颜色码
 * @default rgba(255,220,120,1)
 *
 * @param ScoreTotalBS
 * @text 总分文本边框大小
 * @parent ---画面调整---
 * @type number
 * @desc 显示的文本边框大小
 * @default 4
 *
 *
 * @param ScoreTotalBC
 * @text 总分文本边框颜色
 * @parent ---画面调整---
 * @type text
 * @desc 显示的文本边框颜色,可输入两种样式的颜色码
 * @default rgba(180,120,120,1)
 *
 *
 *
 * @param TimeTotalT
 * @text 总耗时文本
 * @parent ---画面调整---
 * @type text
 * @desc 显示的文本内容
 * @default 耗时:
 *
 * @param TimeTotalX
 * @text 总耗时文本X
 * @parent ---画面调整---
 * @type text
 * @desc 显示的文本位置X,可以输入一段代码
 * @default Graphics.boxWidth/2+50
 *
 * @param TimeTotalY
 * @text 总耗时文本Y
 * @parent ---画面调整---
 * @type text
 * @desc 显示的文本位置Y,可以输入一段代码
 * @default Graphics.boxHeight/2+60
 *
 *
 * @param TimeTotalTS
 * @text 总耗时文本大小
 * @parent ---画面调整---
 * @type number
 * @desc 显示的文本大小
 * @default 36
 *
 *
 * @param TimeTotalTC
 * @text 总耗时文本颜色
 * @parent ---画面调整---
 * @type text
 * @desc 显示的文本颜色,可输入两种样式的颜色码
 * @default rgba(255,220,120,1)
 *
 * @param TimeTotalBS
 * @text 总耗时文本边框大小
 * @parent ---画面调整---
 * @type number
 * @desc 显示的文本边框大小
 * @default 4
 *
 *
 * @param TimeTotalBC
 * @text 总耗时文本边框颜色
 * @parent ---画面调整---
 * @type text
 * @desc 显示的文本边框颜色,可输入两种样式的颜色码
 * @default rgba(180,120,120,1)
 *
 *
 * @param TimeTileL
 * @text 时间条长度
 * @parent ---画面调整---
 * @type number
 * @desc 显示的时间条的长度值
 * @default 500
 *
 * @param TimeTileH
 * @text 时间条高度
 * @parent ---画面调整---
 * @type number
 * @desc 显示的时间条的高度
 * @default 15
 *
 *
 * @param TimeTileX
 * @text 时间条X
 * @parent ---画面调整---
 * @type text
 * @desc 时间条位置X,可以输入一段代码
 * @default Graphics.boxWidth/5
 *
 * @param TimeTileY
 * @text 时间条Y
 * @parent ---画面调整---
 * @type text
 * @desc 时间条位置Y,可以输入一段代码
 * @default Graphics.boxHeight/5
 *
 *
 * @param ExitButtonX
 * @text 退出按钮X
 * @parent ---画面调整---
 * @type text
 * @desc 推出按钮位置X,可以输入一段代码
 * @default Graphics.boxWidth-64
 *
 * @param ExitButtonY
 * @text 退出按钮Y
 * @parent ---画面调整---
 * @type text
 * @desc 显示的文本位置Y,可以输入一段代码
 * @default Graphics.boxHeight-32
 *
 *
 *
 * @param ---音效---
 * @default
 *
 * @param BkBGMName
 * @text 背景BGM名称
 * @parent ---音效---
 * @type file
 * @dir audio/bgm
 * @desc 执行小游戏时,会播放的背景bgm,BGM应放在audio/bgm文件夹中,不填写会使用GameCore插件中默认的背景音效
 * @default
 *
 * @param BkBGMVolume
 * @text 背景BGM音量
 * @parent ---音效---
 * @type Number
 * @desc 音量大小,默认100
 * @default 100
 
 * @param BkBGMPitch
 * @text 背景BGM声调
 * @parent ---音效---
 * @type Number
 * @desc 声调,默认100
 * @default 100
 
 * @param BkBGMBGSPan
 * @text 背景BGM声道
 * @parent ---音效---
 * @type Number
 * @desc 声道,默认0
 * @default 0
 *
 *
 * @param ButtonSound
 * @text 按钮时音效
 * @parent ---音效---
 * @type file
 * @dir audio/se
 * @desc 按钮时产生的声音,请填写audio/se文件夹中的文件名,不包含m4a.ogg的后缀名
 * @default Cancel2
 *
 * @param ButtonVolume
 * @text 按钮时音量
 * @parent ---音效---
 * @type number
 * @min 0
 * @desc 按钮时产生的音量,默认值100
 * @default 100
 *
 * @param ButtonPitch
 * @text 按钮时音调
 * @parent ---音效---
 * @type number
 * @min 0
 * @desc 按钮时产生的音调,默认值100
 * @default 100
 *
 * @param ButtonPan
 * @text 按钮时声道
 * @parent ---音效---
 * @type number
 * @desc 按钮时产生的声道,默认值0
 * @default 0
 *
 *
 * @param SelectSound
 * @text 选择图片时音效
 * @parent ---音效---
 * @type file
 * @dir audio/se
 * @desc 选择图片时产生的声音,请填写audio/se文件夹中的文件名,不包含m4a.ogg的后缀名
 * @default Switch1
 *
 * @param SelectVolume
 * @text 选择图片时音量
 * @parent ---音效---
 * @type number
 * @min 0
 * @desc 选择图片时产生的音量,默认值100
 * @default 100
 *
 * @param SelectPitch
 * @text 选择图片时音调
 * @parent ---音效---
 * @type number
 * @min 0
 * @desc 选择图片时产生的音调,默认值100
 * @default 100
 *
 * @param SelectPan
 * @text 选择图片时声道
 * @parent ---音效---
 * @type number
 * @desc 选择图片时产生的声道,默认值0
 * @default 0
 *
 *
 *
 * @param CancelSound
 * @text 选择失效时音效
 * @parent ---音效---
 * @type file
 * @dir audio/se
 * @desc 选择失效时产生的声音,请填写audio/se文件夹中的文件名,不包含m4a.ogg的后缀名
 * @default Crossbow
 *
 * @param CancelVolume
 * @text 选择失效时音量
 * @parent ---音效---
 * @type number
 * @min 0
 * @desc 选择失效时产生的音量,默认值100
 * @default 100
 *
 * @param CancelPitch
 * @text 选择失效时音调
 * @parent ---音效---
 * @type number
 * @min 0
 * @desc 选择失效时产生的音调,默认值100
 * @default 100
 *
 * @param CancelPan
 * @text 选择失效时声道
 * @parent ---音效---
 * @type number
 * @desc 选择失效时产生的声道,默认值0
 * @default 0
 *
 *
 * @param DestroySound
 * @text 连接消除时音效
 * @parent ---音效---
 * @type file
 * @dir audio/se
 * @desc 连接消除时产生的声音,请填写audio/se文件夹中的文件名,不包含m4a.ogg的后缀名
 * @default Item1
 *
 * @param DestroyVolume
 * @text 连接消除时音量
 * @parent ---音效---
 * @type number
 * @min 0
 * @desc 连接消除时产生的音量,默认值100
 * @default 100
 *
 * @param DestroyPitch
 * @text 连接消除时音调
 * @parent ---音效---
 * @type number
 * @min 0
 * @desc 连接消除时产生的音调,默认值100
 * @default 100
 *
 * @param DestroyPan
 * @text 连接消除时声道
 * @parent ---音效---
 * @type number
 * @desc 连接消除时产生的声道,默认值0
 * @default 0
 */
 
 
var LiuYue = LiuYue || {};
LiuYue.LiuYue_GameLinkLook = true;//插件启动

var Zzy = Zzy || {};
Zzy.GLL = Zzy.GLL || {};
Zzy.GLL.version = 1.04;  
Zzy.Parameters = PluginManager.parameters('LiuYue_GameLinkLook');
Zzy.Param = Zzy.Param || {};
Zzy.Param.GLLGameName = String(Zzy.Parameters['GameName']);//启动游戏的名称

Zzy.GLL.GameCorePlugin = false;
if(LiuYue.LiuYue_GameCore)//前置插件检测
{
	Zzy.GCF.GameCorePlugin = true;
}
else
{
	console.log("Error:(LiuYue_GameLinkLook):这个插件需要LiuYue_GameCore作为前置插件,请将这个插件放在核心插件下!!!");
}

//注册游戏
Zzy.GCF.RegisterGame(Zzy.Param.GLLGameName,'LinkLook');



//--------------------------------------数据----------------------------------------



Zzy.Param.GLLStartLevel = String(Zzy.Parameters['StartLevel']);//目前关卡值
Zzy.Param.GLLMaxLevel = String(Zzy.Parameters['MaxLevel']);//最大关卡数
Zzy.Param.GLLCpTime = String(Zzy.Parameters['CpTime']);//关卡限制时间
Zzy.Param.GLLCpLine = String(Zzy.Parameters['CpLine']);//关卡方块行数
Zzy.Param.GLLCpList = String(Zzy.Parameters['CpList']);//关卡方块列数
Zzy.Param.GLLCpSize = String(Zzy.Parameters['CpSize']);//关卡方块尺寸
Zzy.Param.GLLCpType = String(Zzy.Parameters['CpType']);//关卡方块类型
Zzy.Param.GLLConnectSocre = String(Zzy.Parameters['ConnectSocre']);//连接得分
Zzy.Param.GLLSurplusTimeSocre = String(Zzy.Parameters['SurplusTimeSocre']);//剩余时间得分


Zzy.Param.GLLConnectSpeed = Number(Zzy.Parameters['ConnectSpeed']);//连接速度


//可用文本
Zzy.GLL.TextArr = [
"Today’s work",
"Shall we finish?",
'',
"Work success",
"Work failed"
];




//---------------------------------------图片-----------------------------------------

Zzy.Param.GLLWinCommon = parseInt(Zzy.Parameters['WinCommon']);//胜利事件
Zzy.Param.GLLWinScript = Zzy.Parameters['WinScript'] ? new Function(JSON.parse(Zzy.Parameters['WinScript']) + '\nreturn true;') : undefined;//胜利脚本
Zzy.Param.GLLFailCommon = parseInt(Zzy.Parameters['FailCommon']);//失败事件
Zzy.Param.GLLFailScript = Zzy.Parameters['FailScript'] ? new Function(JSON.parse(Zzy.Parameters['FailScript']) + '\nreturn true;') : undefined;//失败脚本
Zzy.Param.GLLOther1Common = parseInt(Zzy.Parameters['Other1Common']);//特殊情况1事件
Zzy.Param.GLLOther1Script = Zzy.Parameters['Other1Script'] ? new Function(JSON.parse(Zzy.Parameters['Other1Script']) + '\nreturn true;') : undefined;//特殊情况1脚本
Zzy.Param.GLLOther2Common = parseInt(Zzy.Parameters['Other2Common']);//特殊情况2事件
Zzy.Param.GLLOther2Script = Zzy.Parameters['Other2Script'] ? new Function(JSON.parse(Zzy.Parameters['Other2Script']) + '\nreturn true;') : undefined;//特殊情况2脚本
Zzy.Param.GLLSaveScoreVariable = parseInt(Zzy.Parameters['SaveScoreVariable']);//变量index
Zzy.Param.GLLSaveTimeVariable = parseInt(Zzy.Parameters['SaveTimeVariable']);//变量index


Zzy.Param.GLLPicPath = String(Zzy.Parameters['PicPath']);//图片路径

Zzy.Param.GLLBackGroundPic = String(Zzy.Parameters['BackGroundPic']);//背景
Zzy.Param.GLLPausePic = String(Zzy.Parameters['PausePic']);//暂停
Zzy.Param.GLLItemArrPic = String(Zzy.Parameters['ItemArrPic']);//道具
Zzy.Param.GLLBkBlockPic = String(Zzy.Parameters['BkBlockPic']);//道具底板

Zzy.Param.GLLMenuBkPic = String(Zzy.Parameters['MenuBkPic']);//菜单背景板
Zzy.Param.GLLOkButtonPic = String(Zzy.Parameters['OkButtonPic']);//OK按钮图片
Zzy.Param.GLLCancelButtonPic = String(Zzy.Parameters['CancelButtonPic']);//取消按钮图片
Zzy.Param.GLLExitButtonPic = String(Zzy.Parameters['ExitButtonPic']);//退出按钮图片
Zzy.Param.GLLTimePic = String(Zzy.Parameters['TimePic']);//时间条图片
Zzy.Param.GLLTimeBkPic = String(Zzy.Parameters['TimeBkPic']);//时间条背景图片




//------------------------------特殊情况1,2脚本--------------------------------
Zzy.Param.GLLOtherEnd1Script = new Function(JSON.parse(Zzy.Parameters['OtherEnd1Script']));//结束情况1
Zzy.Param.GLLOtherEnd2Script = new Function(JSON.parse(Zzy.Parameters['OtherEnd2Script']));//结束情况2





//------------------------------画面调整----------------------------------------

Zzy.Param.GLLLevelSprT = String(Zzy.Parameters['LevelSprT']);
Zzy.Param.GLLLevelSprX = String(Zzy.Parameters['LevelSprX']);
Zzy.Param.GLLLevelSprY = String(Zzy.Parameters['LevelSprY']);
Zzy.Param.GLLLevelSprTS = parseInt(Zzy.Parameters['LevelSprTS']);
Zzy.Param.GLLLevelSprTC = String(Zzy.Parameters['LevelSprTC']);
Zzy.Param.GLLLevelSprBS = parseInt(Zzy.Parameters['LevelSprBS']);
Zzy.Param.GLLLevelSprBC = String(Zzy.Parameters['LevelSprBC']);



Zzy.Param.GLLScoreSprT = String(Zzy.Parameters['ScoreSprT']);
Zzy.Param.GLLScoreSprX = String(Zzy.Parameters['ScoreSprX']);
Zzy.Param.GLLScoreSprY = String(Zzy.Parameters['ScoreSprY']);
Zzy.Param.GLLScoreSprTS = parseInt(Zzy.Parameters['ScoreSprTS']);
Zzy.Param.GLLScoreSprTC = String(Zzy.Parameters['ScoreSprTC']);
Zzy.Param.GLLScoreSprBS = parseInt(Zzy.Parameters['ScoreSprBS']);
Zzy.Param.GLLScoreSprBC = String(Zzy.Parameters['ScoreSprBC']);



Zzy.Param.GLLMaxScoreSprT = String(Zzy.Parameters['MaxScoreSprT']);
Zzy.Param.GLLMaxScoreSprX = String(Zzy.Parameters['MaxScoreSprX']);
Zzy.Param.GLLMaxScoreSprY = String(Zzy.Parameters['MaxScoreSprY']);
Zzy.Param.GLLMaxScoreSprTS = parseInt(Zzy.Parameters['MaxScoreSprTS']);
Zzy.Param.GLLMaxScoreSprTC = String(Zzy.Parameters['MaxScoreSprTC']);
Zzy.Param.GLLMaxScoreSprBS = parseInt(Zzy.Parameters['MaxScoreSprBS']);
Zzy.Param.GLLMaxScoreSprBC = String(Zzy.Parameters['MaxScoreSprBC']);



Zzy.Param.GLLTimeSprT = String(Zzy.Parameters['TimeSprT']);
Zzy.Param.GLLTimeSprX = String(Zzy.Parameters['TimeSprX']);
Zzy.Param.GLLTimeSprY = String(Zzy.Parameters['TimeSprY']);
Zzy.Param.GLLTimeSprTS = parseInt(Zzy.Parameters['TimeSprTS']);
Zzy.Param.GLLTimeSprTC = String(Zzy.Parameters['TimeSprTC']);
Zzy.Param.GLLTimeSprBS = parseInt(Zzy.Parameters['TimeSprBS']);
Zzy.Param.GLLTimeSprBC = String(Zzy.Parameters['TimeSprBC']);


Zzy.Param.GLLScoreTotalT = String(Zzy.Parameters['ScoreTotalT']);
Zzy.Param.GLLScoreTotalX = String(Zzy.Parameters['ScoreTotalX']);
Zzy.Param.GLLScoreTotalY = String(Zzy.Parameters['ScoreTotalY']);
Zzy.Param.GLLScoreTotalTS = parseInt(Zzy.Parameters['ScoreTotalTS']);
Zzy.Param.GLLScoreTotalTC = String(Zzy.Parameters['ScoreTotalTC']);
Zzy.Param.GLLScoreTotalBS = parseInt(Zzy.Parameters['ScoreTotalBS']);
Zzy.Param.GLLScoreTotalBC = String(Zzy.Parameters['ScoreTotalBC']);



Zzy.Param.GLLTimeTotalT = String(Zzy.Parameters['TimeTotalT']);
Zzy.Param.GLLTimeTotalX = String(Zzy.Parameters['TimeTotalX']);
Zzy.Param.GLLTimeTotalY = String(Zzy.Parameters['TimeTotalY']);
Zzy.Param.GLLTimeTotalTS = parseInt(Zzy.Parameters['TimeTotalTS']);
Zzy.Param.GLLTimeTotalTC = String(Zzy.Parameters['TimeTotalTC']);
Zzy.Param.GLLTimeTotalBS = parseInt(Zzy.Parameters['TimeTotalBS']);
Zzy.Param.GLLTimeTotalBC = String(Zzy.Parameters['TimeTotalBC']);


Zzy.Param.GLLTimeTileL = parseInt(Zzy.Parameters['TimeTileL']);
Zzy.Param.GLLTimeTileH = parseInt(Zzy.Parameters['TimeTileH']);
Zzy.Param.GLLTimeTileX = String(Zzy.Parameters['TimeTileX']);
Zzy.Param.GLLTimeTileY = String(Zzy.Parameters['TimeTileY']);


Zzy.Param.GLLExitButtonX = String(Zzy.Parameters['ExitButtonX']);
Zzy.Param.GLLExitButtonY = String(Zzy.Parameters['ExitButtonY']);




//------------------------------音效-------------------------------

Zzy.GLL.MakeSE = function(seName,seVolume,sePitch,sePan)
{
	if(!seName)return undefined;
	var se = {
		name:seName,
		volume:(seVolume ? seVolume : 100),
		pitch:(sePitch ? sePitch : 100),
		pan:(sePan ? sePan : 0)
	};
	return se;
}


Zzy.Param.GLLBkBGMName = String(Zzy.Parameters['BkBGMName']);//背景BGM名称
Zzy.Param.GLLBkBGMVolume = parseInt(Zzy.Parameters['BkBGMVolume']);//背景BGM音量
Zzy.Param.GLLBkBGMPitch = parseInt(Zzy.Parameters['BkBGMPitch']);//背景BGM声调
Zzy.Param.GLLBkBGMBGSPan = parseInt(Zzy.Parameters['BkBGMPan']);//背景BGM声道
Zzy.Param.GLLBkBGM = Zzy.GLL.MakeSE(Zzy.Param.GLLBkBGMName,Zzy.Param.GLLBkBGMVolume,Zzy.Param.GLLBkBGMPitch,Zzy.Param.GLLBkBGMBGSPan);


Zzy.Param.GLLButtonSound = String(Zzy.Parameters['ButtonSound']);//按钮时音效
Zzy.Param.GLLButtonVolume = parseInt(Zzy.Parameters['ButtonVolume']);//按钮时音量
Zzy.Param.GLLButtonPitch = parseInt(Zzy.Parameters['ButtonPitch']);//按钮时音调
Zzy.Param.GLLButtonPan = parseInt(Zzy.Parameters['ButtonPan']);//按钮时声道
Zzy.Param.GLLButtonSE = Zzy.GLL.MakeSE(Zzy.Param.GLLButtonSound,Zzy.Param.GLLButtonVolume,Zzy.Param.GLLButtonPitch,Zzy.Param.GLLButtonPan);

Zzy.Param.GLLSelectSound = String(Zzy.Parameters['SelectSound']);//选择图片音效
Zzy.Param.GLLSelectVolume = parseInt(Zzy.Parameters['SelectVolume']);//选择图片音量
Zzy.Param.GLLSelectPitch = parseInt(Zzy.Parameters['SelectPitch']);//选择图片音调
Zzy.Param.GLLSelectPan = parseInt(Zzy.Parameters['SelectPan']);//选择图片声道
Zzy.Param.GLLSelectSE = Zzy.GLL.MakeSE(Zzy.Param.GLLSelectSound,Zzy.Param.GLLSelectVolume,Zzy.Param.GLLSelectPitch,Zzy.Param.GLLSelectPan);
 
Zzy.Param.GLLCancelSound = String(Zzy.Parameters['CancelSound']);//选择失效音效
Zzy.Param.GLLCancelVolume = parseInt(Zzy.Parameters['CancelVolume']);//选择失效音量
Zzy.Param.GLLCancelPitch = parseInt(Zzy.Parameters['CancelPitch']);//选择失效音调
Zzy.Param.GLLCancelPan = parseInt(Zzy.Parameters['CancelPan']);//选择失效声道
Zzy.Param.GLLCancelSE = Zzy.GLL.MakeSE(Zzy.Param.GLLCancelSound,Zzy.Param.GLLCancelVolume,Zzy.Param.GLLCancelPitch,Zzy.Param.GLLCancelPan);

Zzy.Param.GLLDestroySound = String(Zzy.Parameters['DestroySound']);//连接消除音效
Zzy.Param.GLLDestroyVolume = parseInt(Zzy.Parameters['DestroyVolume']);//连接消除音量
Zzy.Param.GLLDestroyPitch = parseInt(Zzy.Parameters['DestroyPitch']);//连接消除音调
Zzy.Param.GLLDestroyPan = parseInt(Zzy.Parameters['DestroyPan']);//连接消除声道
Zzy.Param.GLLDestroySE = Zzy.GLL.MakeSE(Zzy.Param.GLLDestroySound,Zzy.Param.GLLDestroyVolume,Zzy.Param.GLLDestroyPitch,Zzy.Param.GLLDestroyPan);



Zzy.Param.GLLAllSE = [];
Zzy.Param.GLLAllSE = [undefined,
		Zzy.Param.GLLButtonSE,
		Zzy.Param.GLLSelectSE,
		Zzy.Param.GLLCancelSE,
		Zzy.Param.GLLDestroySE
]

//声音ID
//0 - undefined
//1 - 按钮音效
//2 - 
//3 - 
//4 - 
//5 - 
//6 - 




//----------------------------临时变量-----------------------------

Zzy.GLL.WindowPointer = undefined;//最底层
Zzy.GLL.Window1Pointer = undefined;//层1,背景方块板子
Zzy.GLL.Window2Pointer = undefined;//层2,
Zzy.GLL.Window3Pointer = undefined;//层3,



Zzy.GLL.DefaultSize = 48;//默认尺寸
Zzy.GLL.PosManager = undefined;//位置管理



//==================================================================
//Game_System
//==================================================================

Zzy.GLL.Game_System_initialize = Game_System.prototype.initialize;
Game_System.prototype.initialize = function() 
{
    Zzy.GLL.Game_System_initialize.call(this);
	this.ZzyGLLInitData();//初始化数据
};

Game_System.prototype.ZzyGLLInitData = function()
{
	
	
	this._ZzyGLLStartLevel = Zzy.Param.GCSStartLevel;//开始值
	this._ZzyGLLMaxLevelFormula = Zzy.Param.GLLMaxLevel;//最大关卡数
	this._ZzyGLLCpTimeFormula = Zzy.Param.GLLCpTime;//关卡限制时间
	this._ZzyGLLCpLineFormula = Zzy.Param.GLLCpLine;//关卡方块行数
	this._ZzyGLLCpListFormula = Zzy.Param.GLLCpList;//关卡方块列数
	this._ZzyGLLCpSizeFormula = Zzy.Param.GLLCpSize;//关卡方块尺寸
	this._ZzyGLLCpTypeFormula = Zzy.Param.GLLCpType;//关卡方块类型
	this._ZzyGLLConnectSocreFormula = Zzy.Param.GLLConnectSocre;//连接得分
	this._ZzyGLLSurplusTimeSocreFormula = Zzy.Param.GLLSurplusTimeSocre;//剩余时间得分
	
	this._ZzyGLLHistroyScore = 0;//历史分
	this._ZzyGLLHistroyLevel = 0;//历史等级
}


Game_System.prototype.GetZzyGLLStartLevel = function()
{
	if(this._ZzyGLLStartLevel === undefined)
	{this._ZzyGLLStartLevel = Zzy.Param.GLLStartLevel;}
	return this._ZzyGLLStartLevel;
}


Game_System.prototype.SetZzyGLLStartLevel = function(level)
{
	this._ZzyGCSStartLevel = level;
}




Game_System.prototype.GetZzyGLLMaxLevelFormula = function()
{
	if(this._ZzyGLLMaxLevelFormula === undefined)
	{this._ZzyGLLMaxLevelFormula = Zzy.Param.GLLMaxLevel;}
	return this._ZzyGLLMaxLevelFormula;
}

Game_System.prototype.SetZzyGLLMaxLevelFormula = function(formula)
{
	this._ZzyGLLMaxLevelFormula = formula;
}

Game_System.prototype.GetZzyGLLCpTimeFormula = function()
{
	if(this._ZzyGLLCpTimeFormula === undefined)
	{this._ZzyGLLCpTimeFormula = Zzy.Param.GLLCpTime;}
	return this._ZzyGLLCpTimeFormula;
}

Game_System.prototype.SetZzyGLLCpTimeFormula = function(formula)
{
	this._ZzyGLLCpTimeFormula = formula;
}

Game_System.prototype.GetZzyGLLCpLineFormula = function()
{
	if(this._ZzyGLLCpLineFormula === undefined)
	{this._ZzyGLLCpLineFormula = Zzy.Param.GLLCpLine;}
	return this._ZzyGLLCpLineFormula;
}

Game_System.prototype.SetZzyGLLCpLineFormula = function(formula)
{
	this._ZzyGLLCpLineFormula = formula;
}

Game_System.prototype.GetZzyGLLCpListFormula = function()
{
	if(this._ZzyGLLCpListFormula === undefined)
	{this._ZzyGLLCpListFormula = Zzy.Param.GLLCpList;}
	return this._ZzyGLLCpListFormula;
}

Game_System.prototype.SetZzyGLLCpListFormula = function(formula)
{
	this._ZzyGLLCpListFormula = formula;
}



Game_System.prototype.GetZzyGLLCpSizeFormula = function()
{
	if(this._ZzyGLLCpSizeFormula === undefined)
	{this._ZzyGLLCpSizeFormula = Zzy.Param.GLLCpSize;}
	return this._ZzyGLLCpSizeFormula;
}

Game_System.prototype.SetZzyGLLCpSizeFormula = function(formula)
{
	this._ZzyGLLCpSizeFormula = formula;
}


Game_System.prototype.GetZzyGLLCpTypeFormula = function()
{
	if(this._ZzyGLLCpTypeFormula === undefined)
	{this._ZzyGLLCpTypeFormula = Zzy.Param.GLLCpType;}
	return this._ZzyGLLCpTypeFormula;
}

Game_System.prototype.SetZzyGLLCpTypeFormula = function(formula)
{
	this._ZzyGLLCpTypeFormula = formula;
}


Game_System.prototype.GetZzyGLLConnectSocreFormula = function()
{
	if(this._ZzyGLLConnectSocreFormula === undefined)
	{this._ZzyGLLConnectSocreFormula = Zzy.Param.GLLConnectSocre;}
	return this._ZzyGLLConnectSocreFormula;
}

Game_System.prototype.SetZzyGLLConnectSocreFormula = function(formula)
{
	this._ZzyGLLConnectSocreFormula = formula;
}



Game_System.prototype.GetZzyGLLSurplusTimeSocreFormula = function()
{
	if(this._ZzyGLLSurplusTimeSocreFormula === undefined)
	{this._ZzyGLLSurplusTimeSocreFormula = Zzy.Param.GLLSurplusTimeSocre;}
	return this._ZzyGLLSurplusTimeSocreFormula;
}

Game_System.prototype.SetZzyGLLSurplusTimeSocreFormula = function(formula)
{
	this._ZzyGLLSurplusTimeSocreFormula = formula;
}

Game_System.prototype.GetZzyGLLHistroyScore = function()
{
	if(this._ZzyGLLHistroyScore === undefined)
	{this._ZzyGLLHistroyScore = 0;}
	return this._ZzyGLLHistroyScore;
}

Game_System.prototype.SetZzyGLLHistroyScore = function(value)
{
	this._ZzyGLLHistroyScore = value;
}

Game_System.prototype.GetZzyGLLHistroyLevel = function()
{
	if(this._ZzyGLLHistroyLevel === undefined)
	{this._ZzyGLLHistroyLevel = 0;}
	return this._ZzyGLLHistroyLevel;
}

Game_System.prototype.SetZzyGLLHistroyLevel = function(value)
{
	this._ZzyGLLHistroyLevel = value;
}


//==================================================================
//Game_Interpreter
//==================================================================

Zzy.GLL.Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;
Game_Interpreter.prototype.pluginCommand = function(command, args)//插件命令
{
	Zzy.GLL.Game_Interpreter_pluginCommand.call(this,command,args);

	if(command === 'ZzyGLL')
	{
		this.ZzyGLLCommand(args);
	}
	

}

Game_Interpreter.prototype.ZzyGLLCommand = function(args)
{
	var command = String(args[0]);
	
	switch(command)
	{
		case 'StartLevel':
		var cLevel = String(args[1]);
			Zzy.GLL.StartLevel(cLevel);
		break;		
		
		
		case 'MaxLevel':
			var formula = String(args[1]);
			Zzy.GLL.MaxLevel(formula);
			
			//$gameSystem.SetZzyGLLMaxLevelFormula(formula);
		break;
		
		case 'Time':
			var formula = String(args[1]);
			Zzy.GLL.Time(formula);
			
			//$gameSystem.SetZzyGLLCpTimeFormula(formula);
		break;
		
		case 'Line':
			var formula = String(args[1]);
			Zzy.GLL.Line(formula);
			
			//$gameSystem.SetZzyGLLCpLineFormula(formula);
		break;
		
		case 'List':
			var formula = String(args[1]);
			Zzy.GLL.List(formula);
			
			//$gameSystem.SetZzyGLLCpListFormula(formula);
		break;
		
		case 'Size':
			var formula = String(args[1]);
			Zzy.GLL.Size(formula);
			
			//$gameSystem.SetZzyGLLCpSizeFormula(formula);
		break;
		
		case 'Type':
			var formula = String(args[1]);
			Zzy.GLL.Type(formula);
			
			//$gameSystem.SetZzyGLLCpTypeFormula(formula);
		break;
		
		case 'ConnectSocre':
			var formula = String(args[1]);
			Zzy.GLL.ConnectSocre(formula);
			
			//$gameSystem.SetZzyGLLConnectSocreFormula(formula);
		break;
		
		case 'SurplusScore':
			var formula = String(args[1]);
			Zzy.GLL.SurplusScore(formula);
			
			//$gameSystem.SetZzyGLLSurplusTimeSocreFormula(formula);
		break;
		
	}
}



//=========================================================================================
//Scene_ZzyGCFLinkLook
//=========================================================================================
function Scene_ZzyGCFLinkLook() 
{
    this.initialize.apply(this, arguments);
}

Scene_ZzyGCFLinkLook.prototype = Object.create(Scene_ZzyGCFGame.prototype);
Scene_ZzyGCFLinkLook.prototype.constructor = Scene_ZzyGCFLinkLook;

Scene_ZzyGCFLinkLook.prototype.initialize = function() 
{
    Scene_ZzyGCFGame.prototype.initialize.call(this);

};

Scene_ZzyGCFLinkLook.prototype.terminate = function()//退出时 
{
	Scene_ZzyGCFGame.prototype.terminate.call(this);
	
	this.GLLClearData();//清理数据
	
	//存储分数和时间到额外变量
	this.SettlementExGame();
};

Scene_ZzyGCFLinkLook.prototype.SettlementExGame = function()
{
	var globalInfo = $gameSystem.getZzyGCFGameGlobal()
	var tempCommonId = 0;
	var tempScript = undefined;
	switch(globalInfo.result)
	{
		case 'win'://胜利时
		tempCommonId = Zzy.Param.GLLWinCommon;
		tempScript = Zzy.Param.GLLWinScript;
		break;
		case 'fail'://失败时
		tempCommonId = Zzy.Param.GLLFailCommon;
		tempScript = Zzy.Param.GLLFailScript;
		break;
		case 'other1'://特殊情况1
		tempCommonId = Zzy.Param.GLLOther1Common;
		tempScript = Zzy.Param.GLLOther1Script;
		break;
		case 'other2'://特殊情况2
		tempCommonId = Zzy.Param.GLLOther2Common;
		tempScript = Zzy.Param.GLLOther2Script;
		break;
	}
	//修改结算信息
	Zzy.GCF.tempCommonId = tempCommonId === 0 ? Zzy.GCF.tempCommonId : tempCommonId;
	Zzy.GCF.tempScript = tempScript === undefined ? Zzy.GCF.tempScript : tempScript;
	if(Zzy.Param.GLLSaveScoreVariable){$gameVariables.setValue(Zzy.Param.GLLSaveScoreVariable,globalInfo.score);}
	if(Zzy.Param.GLLSaveTimeVariable){$gameVariables.setValue(Zzy.Param.GLLSaveTimeVariable,globalInfo.time);}
}



Scene_ZzyGCFLinkLook.prototype.GLLClearData = function()
{
	Zzy.GLL.WindowPointer = undefined;//窗口指针
	Zzy.GLL.Window1Pointer = undefined;
	Zzy.GLL.Window2Pointer = undefined;
	Zzy.GLL.Window3Pointer = undefined;
	
	//清理缓存池
}

Scene_ZzyGCFLinkLook.prototype.AddLayer1 = function()//层1,
{
	Scene_ZzyGCFGame.prototype.AddLayer1.call(this);
	this._Window1 = new Window_ZzyGLLLayerWindow();
	this.addChild(this._Window1);
	Zzy.GLL.Window1Pointer = this._Window1;
}


Scene_ZzyGCFLinkLook.prototype.AddLayer2 = function()//层2显示
{
	Scene_ZzyGCFGame.prototype.AddLayer2.call(this);
	this._Window2 = new Window_ZzyGLLLayerWindow();
	this.addChild(this._Window2);
	Zzy.GLL.Window2Pointer = this._Window2;
}


Scene_ZzyGCFLinkLook.prototype.AddLayer3 = function()//层3显示,
{
	Scene_ZzyGCFGame.prototype.AddLayer3.call(this);
	this._Window3 = new Window_ZzyGLLLayerWindow();
	this.addChild(this._Window3);
	Zzy.GLL.Window3Pointer = this._Window3;
}


Scene_ZzyGCFLinkLook.prototype.requestBkBitmap = function()//申请背景图
{
	//满足条件存在图片名称同时游戏关卡名称正确
	if(!!Zzy.Param.GLLBackGroundPic)
	{
		var picName = Zzy.Param.GLLBackGroundPic;
		var hue = $gameSystem._ZzyGCFBkHue;
		//this._backgroundSprite.bitmap = ImageManager.loadPicture(picName,hue); 
		this._backgroundSprite.bitmap = ImageManager.loadBitmap(Zzy.Param.GLLPicPath,picName,hue,true);	
		this._backgroundSprite.move(0,0,Graphics.boxWidth,Graphics.boxHeight);		
	}
	else
	{
		Scene_ZzyGCFGame.prototype.requestBkBitmap.call(this);
	}
	
}


Scene_ZzyGCFLinkLook.prototype.PlayBkBGM = function()//播放音乐
{
	//修改播放声音
	if(Zzy.Param.GLLBkBGMName)
	{AudioManager.replayBgm(Zzy.Param.GLLBkBGM);}	
	else
	{Scene_ZzyGCFGame.prototype.PlayBkBGM.call(this);}
}


//=======================================================================
//Sprite_ZzyGLLBase
//=======================================================================
function Sprite_ZzyGLLBase() 
{
    this.initialize.apply(this, arguments);
}

Sprite_ZzyGLLBase.prototype = Object.create(Sprite_ZzyGCFBase.prototype);
Sprite_ZzyGLLBase.prototype.constructor = Sprite_ZzyGLLBase;

Sprite_ZzyGLLBase.prototype.initialize = function(x,y,fileName,hue) 
{
	Sprite_ZzyGCFBase.prototype.initialize.call(this,x,y,fileName,hue);
	
}

Sprite_ZzyGLLBase.prototype.loadBitmap = function(fileName,hue)//加载图片
{
	this.bitmap = ImageManager.loadBitmap(Zzy.Param.GLLPicPath, fileName, hue, true);
}


//=========================================================================================
//Sprite_ZzyGLLTileBase
//=========================================================================================
function Sprite_ZzyGLLTileBase() 
{
    this.initialize.apply(this, arguments);
}


Sprite_ZzyGLLTileBase.prototype = Object.create(Sprite_ZzyGCFTileBase.prototype);
Sprite_ZzyGLLTileBase.prototype.constructor = Sprite_ZzyGLLTileBase;

Sprite_ZzyGLLTileBase.prototype.initialize = function(width,height,value,fileName,hue) 
{
	Sprite_ZzyGCFTileBase.prototype.initialize.call(this,width,height,value,fileName,hue);

}

Sprite_ZzyGLLTileBase.prototype.loadBitmap = function(fileName,hue)//位图
{
	this.bitmap = ImageManager.loadBitmap(Zzy.Param.GLLPicPath,fileName,hue,true);
}


//=========================================================================================
//Sprite_ZzyGLLMenuBk
//=========================================================================================


function Sprite_ZzyGLLMenuBk() 
{
    this.initialize.apply(this, arguments);
}

Sprite_ZzyGLLMenuBk.prototype = Object.create(Sprite_ZzyGLLBase.prototype);
Sprite_ZzyGLLMenuBk.prototype.constructor = Sprite_ZzyGLLMenuBk;

Sprite_ZzyGLLMenuBk.prototype.initialize = function() 
{
	var x = Graphics.boxWidth/2;
	var y = Graphics.boxHeight/2;
	Sprite_ZzyGLLBase.prototype.initialize.call(this,x,y,Zzy.Param.GLLMenuBkPic,0);

	this.okSpr = undefined;
	this.cancelSpr = undefined;
	
	this.appearX = 0;
	this.appearY = 0;
	this.disAppearX = 0;
	this.disAppearY = 0;
	this.appFrame = this.DefaultMoveFrame();
	this.InitData();
}

Sprite_ZzyGLLMenuBk.prototype.InitData = function()
{
	this.appearX = Graphics.boxWidth/2;
	this.appearY = Graphics.boxHeight/2;
	this.disAppearX = Graphics.boxWidth/2;
	this.disAppearY = -Graphics.boxHeight/2;	

	this.visible = false;
	this.isOpen = false;
	this.x = this.disAppearX;
	this.y = this.disAppearY;
	
	this.result = undefined;
	this.stage = 1;//状态
}

Sprite_ZzyGLLMenuBk.prototype.DefaultMoveFrame = function()
{
	return 40;
}



Sprite_ZzyGLLMenuBk.prototype.setBindingOk = function(pointer)
{
	this.okSpr = pointer;
}

Sprite_ZzyGLLMenuBk.prototype.setBindingCancel = function(pointer)
{
	this.cancelSpr = pointer;
}

Sprite_ZzyGLLMenuBk.prototype.update = function()
{
	Sprite_ZzyGLLBase.prototype.update.call(this);
	//更新固定位置
	if(this.okSpr)
	{
		this.okSpr.y = this.y+this.bitmap.height/2-50;
		
		if(this.stage === 2)
		{this.okSpr.x = this.x;}
		else
		{this.okSpr.x = this.x-60;}
		this.okSpr.visible = true;
	}
	if(this.cancelSpr)
	{
		this.cancelSpr.y = this.y+this.bitmap.height/2-50;
		this.cancelSpr.x = this.x+60;
		if(this.stage === 2)
		{this.cancelSpr.visible = false;}
		else
		{this.cancelSpr.visible = true;}
	}	
	
	this.updateCallResult();
}

Sprite_ZzyGLLMenuBk.prototype.updateCallResult = function()
{
	if(!this.result)return;
	
	switch(this.result)
	{
		case 'win':
				this.setMoveEndCallFunction(Zzy.GLL.WindowPointer.UI.CallShowWinText);
			break;
		case 'fail':
				this.setMoveEndCallFunction(Zzy.GLL.WindowPointer.UI.CallShowFailText);
			break;
	}
	
	this.result = undefined;
}




Sprite_ZzyGLLMenuBk.prototype.Appear = function()//出现
{
	this.isOpen = true;
	this.visible = true;
	this.x = this.disAppearX;
	this.y = this.disAppearY;
	this.MoveToOfTime(this.appearX,this.appearY,this.appFrame);
	this.setMoveEndCallFunction(Zzy.GLL.WindowPointer.UI.CallShowTipsExitText);
}


Sprite_ZzyGLLMenuBk.prototype.DisAppear = function()//消失
{
	Zzy.GLL.WindowPointer.UI.CallHideTipsExitText();//隐藏文本
	this.isOpen = false;
	this.visible = true;
	this.x = this.appearX;
	this.y = this.appearY;	
	this.MoveToOfTime(this.disAppearX,this.disAppearY,this.appFrame);
	this.setMoveEndCallFunction(this.ChangeGameStage);//结束函数
	this.setMoveEndDisvisible();
}

Sprite_ZzyGLLMenuBk.prototype.ChangeGameStage = function()
{
	Zzy.GLL.WindowPointer.gameStage = 2;
}


Sprite_ZzyGLLMenuBk.prototype.GameOverAppear = function(result)//游戏结束出现
{
	this.visible = true;
	this.x = this.disAppearX;
	this.y = this.disAppearY;
	
	if(this.isOpen)
	{
	
		Zzy.GLL.WindowPointer.UI.CallHideTipsExitText();//隐藏文本
		this.isOpen = false;
		this.visible = true;
		this.x = this.appearX;
		this.y = this.appearY;
		this.MoveToOfTime(this.disAppearX,this.disAppearY,this.appFrame);//先消失
		var param = {pointer:this,p1:result};
		this.setMoveEndCallFunction(this.GameOverRAppear,param);//再出现
	}
	else
	{
		this.stage = 2;
		this.isOpen = true;
		this.visible = true;
		this.x = this.disAppearX;
		this.y = this.disAppearY;		
		this.MoveToOfTime(this.appearX,this.appearY,this.appFrame);
	
		//因为处理机制,需要延迟一帧绑定
		this.result = result;
	}

}


Sprite_ZzyGLLMenuBk.prototype.GameOverRAppear = function(param)
{
	
	param.pointer.GameOverAppear(param.p1);
}








//=========================================================================================
//Sprite_ZzyGLLButton
//=========================================================================================


function Sprite_ZzyGLLButton() 
{
    this.initialize.apply(this, arguments);
}

Sprite_ZzyGLLButton.prototype = Object.create(Sprite_ZzyGLLBase.prototype);
Sprite_ZzyGLLButton.prototype.constructor = Sprite_ZzyGLLButton;

Sprite_ZzyGLLButton.prototype.initialize = function(x,y,fileName,hue,commandId) 
{
    Sprite_ZzyGLLBase.prototype.initialize.call(this,x,y,fileName,hue);
	//激活Button
	this.isCanButton = true;//激活按钮
	//this.buttonInScopeBitmap = Zzy.GCF.LoadPicture(fileName + '1');
	//this.buttonDownBitmap = Zzy.GCF.LoadPicture(fileName + '2');
	this.buttonInScopeBitmap = ImageManager.loadBitmap(Zzy.Param.GLLPicPath,fileName + '1',undefined,true);
	this.buttonDownBitmap = ImageManager.loadBitmap(Zzy.Param.GLLPicPath,fileName + '2',undefined,true);
	
	this.commandId = commandId;
	//ID 1确认

};

Sprite_ZzyGLLButton.prototype.OnClick = function()//按下按钮
{
	if(!this.visible)return;//按钮隐形不做任何响应
	if(this.isBusy())return;//繁忙时不可操作


	if(Zzy.GLL.WindowPointer.gameStage === 1)
	{
		switch(this.commandId)
		{
			case 1://1代表退出
				
			break;
			
		}
	}
	else if(Zzy.GLL.WindowPointer.gameStage === 2)
	{
		switch(this.commandId)
		{
			case 1://1代表退出
			Zzy.GLL.WindowPointer.UI.OnExitButton();//按下退出
			Zzy.GLL.WindowPointer.gameStage = 4;//切换到4模式
			break;
		}
	}
	else if(Zzy.GLL.WindowPointer.gameStage === 3)
	{
		switch(this.commandId)
		{
			case 2:
			Zzy.GLL.WindowPointer.ExitGame();
			break;
		}
	}
	else if(Zzy.GLL.WindowPointer.gameStage === 4)
	{	
		switch(this.commandId)
		{
			case 2://确认
			Zzy.GLL.WindowPointer.UI.OnOkButton();//按下退出
			break;

			case 3://取消
			Zzy.GLL.WindowPointer.UI.OnCancelButton();//按下退出
			break;

		}
	}
	Zzy.GLL.PlaySE(1);//退出音效
}


//======================================================================
//Sprite_ZzyGLLPause
//======================================================================

function Sprite_ZzyGLLPause() 
{
    this.initialize.apply(this, arguments);
}

Sprite_ZzyGLLPause.prototype = Object.create(Sprite_ZzyGLLBase.prototype);
Sprite_ZzyGLLPause.prototype.constructor = Sprite_ZzyGLLPause;

Sprite_ZzyGLLPause.prototype.initialize = function(x,y,fileName,hue) 
{
    Sprite_ZzyGLLBase.prototype.initialize.call(this,x,y,fileName,hue);
	
	if(!fileName)
	{
		this.bitmap = new Bitmap(Graphics.boxWidth,Graphics.boxHeight);
		this.bitmap.fillAll('rgba(0,0,0,0.4)');
	}
	
	this.ignorePause = true;//激活按钮
	this.visible = false;
	
	this.isPause = Zzy.GCF.GameGlobal().isPausing;
	this.executPausing = false;//执行暂停中
};


Sprite_ZzyGLLPause.prototype.update = function()
{
	Sprite_ZzyGLLBase.prototype.update.call(this);


}

Sprite_ZzyGLLPause.prototype.startPause = function(isPause)
{
	if(isPause)
	{
		this.opacity = 0;
		this.visible = true;
		this.OpacityToOfTime(255,30);	
		this.executPausing = true;
	}
	else
	{
		this.opacity = 255;
		this.visible = true;
		this.OpacityToOfTime(0,30);
		this.setOpacityEndDisvisible();//移动结束后隐藏
		this.executPausing = true;
	}
}


Sprite_ZzyGLLPause.prototype.isExecutPausing = function()
{
	return this.executPausing;
}



//==========================================================================
//Sprite_ZzyGLLBatch
//==========================================================================

function Sprite_ZzyGLLBatch() 
{
    this.initialize.apply(this, arguments);
}


Sprite_ZzyGLLBatch.prototype = Object.create(Sprite_ZzyGCFBatchBase.prototype);
Sprite_ZzyGLLBatch.prototype.constructor = Sprite_ZzyGLLBatch;

Sprite_ZzyGLLBatch.prototype.initialize = function() //需要添加参数 精灵源 窗口指针
{
	Sprite_ZzyGCFBatchBase.prototype.initialize.call(this,Zzy.GLL.Window1Pointer);

}


Sprite_ZzyGLLBatch.prototype.CreateSpr = function()//创造内容
{
	return new Sprite_ZzyGLLBlockBk();
}


Sprite_ZzyGLLBatch.prototype.RefreshCustom = function()//创造内容
{
	
}

Sprite_ZzyGLLBatch.prototype.DefaultSizeX = function()
{
	var formula = $gameSystem.GetZzyGLLCpSizeFormula();
	return Zzy.GLL.WindowPointer.EvalTranslate(formula);
	//return 48;
}

Sprite_ZzyGLLBatch.prototype.DefaultSizeY = function()
{
	var formula = $gameSystem.GetZzyGLLCpSizeFormula();
	return Zzy.GLL.WindowPointer.EvalTranslate(formula);
	//return 48;
}

Sprite_ZzyGLLBatch.prototype.DefaultExSpaceX = function()//额外间距x
{
	return 0;
}

Sprite_ZzyGLLBatch.prototype.DefaultExSpaceY = function()//额外间距y
{
	return 0;
}

Sprite_ZzyGLLBatch.prototype.DefaultAnchorX = function()
{
	return 0.5;
}

Sprite_ZzyGLLBatch.prototype.DefaultAnchorY = function()
{
	return 0.5;
}

Sprite_ZzyGLLBatch.prototype.DefaultBitmap = function()
{
	return undefined;
}

Sprite_ZzyGLLBatch.prototype.DefaultLine = function()
{
	return 5;
}

Sprite_ZzyGLLBatch.prototype.DefaultList = function()
{
	return 5;
}

Sprite_ZzyGLLBatch.prototype.DefaultPosition = function()//默认位置
{
	this.x = Graphics.boxWidth/2;
	this.y = Graphics.boxHeight/2 + Graphics.boxHeight/10;
}

Sprite_ZzyGLLBatch.prototype.DefaultOffSprX = function()
{
	return 24;
}

Sprite_ZzyGLLBatch.prototype.DefaultOffSprY = function()
{
	return 24;
}

Sprite_ZzyGCFBatchBase.prototype.ExecuteFunction1 = function(spr)//执行函数,可以重载
{
	spr.Appear();//出现
}



//=========================================================================================
//Sprite_ZzyGLLBlockBk
//=========================================================================================
function Sprite_ZzyGLLBlockBk() 
{
    this.initialize.apply(this, arguments);
}

Sprite_ZzyGLLBlockBk.prototype = Object.create(Sprite_ZzyGLLBase.prototype);
Sprite_ZzyGLLBlockBk.prototype.constructor = Sprite_ZzyGLLBlockBk;

Sprite_ZzyGLLBlockBk.prototype.initialize = function() 
{
	Sprite_ZzyGLLBase.prototype.initialize.call(this,0,0,Zzy.Param.GLLBkBlockPic,0);
	
}

Sprite_ZzyGLLBlockBk.prototype.ResetInfo = function()
{
	this.visible = true;
}

Sprite_ZzyGLLBlockBk.prototype.Appear = function()
{
	var tScale = Zzy.GLL.WindowPointer.sizeScale;
	this.setScale(0,0);
	this.ScaleToOfTime(tScale,tScale,20);
}

Sprite_ZzyGLLBlockBk.prototype.DisAppear = function()
{
	var tScale = Zzy.GLL.WindowPointer.sizeScale;
	this.setScale(tScale,tScale);
	this.ScaleToOfTime(0,0,20);	
	this.setScaleEndDisvisible(0);//隐藏
}



//==================================================================================
//Particle_ZzyGLLEffect
//==================================================================================
//粒子播放器
function Particle_ZzyGLLEffect() {
    this.initialize.apply(this, arguments);
}

Particle_ZzyGLLEffect.prototype = Object.create(Particle_ZzyGCFBase.prototype);
Particle_ZzyGLLEffect.prototype.constructor = Particle_ZzyGLLEffect;

Particle_ZzyGLLEffect.prototype.initialize = function(windowPointer,fileName)//指针,粒子图片名称
{
	Particle_ZzyGCFBase.prototype.initialize.call(this,Zzy.GLL.Window2Pointer,'');
	
	this.beingFrame = 0;
	this.isBeingFrame = false;
}


Particle_ZzyGLLEffect.prototype.CreateBitmap = function()
{
	this.partBitmap = new Bitmap(5,5);
	this.partBitmap.drawCircle(4,4,4,'#ffffff');
}

Particle_ZzyGLLEffect.prototype.setPartSpriteInfo = function()//设置信息,这个函数可以用来重写
{
	this.partSpeed = 3;//移动速度
	this.partSpeedRandPer = 20;//移动速度扰乱
	//角度:移动
	this.partRotateDir = 0;//角度方向
	this.partRotateArea = 360;//角度区间
	//角度:图片精灵
	this.partSprRotateDir = 0;
	this.partSprRotateArea = 360;//角度区间
	this.partIsfollowDir = true;//是否跟随移动角度
	//缩放
	this.partScaleX = 1;
	this.partScaleY = 1;
	this.partScaleRandPer = 20;
	this.partIsEqualScale = true;//是否等比缩放
	//透明
	this.partOpacity = 255;
	this.partOpacityRandPer = 0;//透明值扰乱
	//时长-帧数
	this.partTime = 60;
	this.partTimeRandPer = 0;//时长扰乱
}


Particle_ZzyGLLEffect.prototype.CreateAParticleSpr = function()
{
	return new PSprite_ZzyGLLEffect(this);
}


Particle_ZzyGLLEffect.prototype.ResetInfo = function(blockSpr)
{
	this.visible = true;
	this.setCreaterPos(blockSpr.x,blockSpr.y);
	
	this.beingFrame = 10;
	this.isBeingFrame = true;
	this.setContinue();
}

Particle_ZzyGLLEffect.prototype.updateDestroy = function()
{
	if(!this.isBeingFrame)return;
	
	if(this.beingFrame > 0)
	{this.beingFrame--;}
	else
	{
		this.isBeingFrame = false;
		this.beingFrame = 0;
		
		this.setStop();
		this.visible = false;
	}
	
}
	

Particle_ZzyGLLEffect.prototype.update = function()
{
	Particle_ZzyGCFBase.prototype.update.call(this);
	this.updateDestroy();
}




Particle_ZzyGLLEffect.prototype.defaultCreaterOffsetX = function()//默认偏移位置,锚点
{
	return Math.round(Graphics.boxWidth/2);
}

Particle_ZzyGLLEffect.prototype.defaultCreaterOffsetY = function()//默认偏移位置
{
	return Math.round(Graphics.boxHeight/2);
}

Particle_ZzyGLLEffect.prototype.defaultCreaterFrame = function()
{
	return 1;
}

Particle_ZzyGLLEffect.prototype.defaultCreaterCount = function()
{
	return 3;
}



//==========================================================================
//Sprite_ZzyGLLTimer
//==========================================================================

function Sprite_ZzyGLLTimer() 
{
    this.initialize.apply(this, arguments);
}


Sprite_ZzyGLLTimer.prototype = Object.create(Sprite_ZzyGLLTileBase.prototype);
Sprite_ZzyGLLTimer.prototype.constructor = Sprite_ZzyGLLTimer;

Sprite_ZzyGLLTimer.prototype.initialize = function(width,height,value,fileName,hue) 
{
	Sprite_ZzyGLLTileBase.prototype.initialize.call(this,width,height,value,Zzy.Param.GLLTimePic,0);
}


Sprite_ZzyGLLTimer.prototype.update = function()
{
	Sprite_ZzyGLLTileBase.prototype.update.call(this);
	
	var time = Zzy.GLL.WindowPointer.getCPTime();
	
	this.setValue(time);
}



//==========================================================================
//Sprite_ZzyGLLTimerBk
//==========================================================================

function Sprite_ZzyGLLTimerBk() 
{
    this.initialize.apply(this, arguments);
}

Sprite_ZzyGLLTimerBk.prototype = Object.create(Sprite_ZzyGLLBase.prototype);
Sprite_ZzyGLLTimerBk.prototype.constructor = Sprite_ZzyGLLTimerBk;

Sprite_ZzyGLLTimerBk.prototype.initialize = function(x,y) 
{
	Sprite_ZzyGLLBase.prototype.initialize.call(this,x,y,Zzy.Param.GLLTimeBkPic,0);
	this.anchor.x = 0;
	this.anchor.y = 0;
}




//=========================================================================================
//Sprite_ZzyGLLNumber
//=========================================================================================

function Sprite_ZzyGLLNumber() 
{
    this.initialize.apply(this, arguments);
}

Sprite_ZzyGLLNumber.prototype = Object.create(Sprite_ZzyGCFNumber.prototype);
Sprite_ZzyGLLNumber.prototype.constructor = Sprite_ZzyGLLNumber;

Sprite_ZzyGLLNumber.prototype.initialize = function(prefix,color,w,h) 
{
	var tw = w ? w : 256;
	var th = h ? h : 64;

    Sprite_ZzyGCFNumber.prototype.initialize.call(this,tw,th,0);

	this.GLLPrefixText = prefix ? prefix : '';//前缀

	this.borderWidth(4);
	this.setNumberColor(color);
};


Sprite_ZzyGLLNumber.prototype.defaultFontSize = function()
{
	return 36;
}

Sprite_ZzyGLLNumber.prototype.DefaultBorderColor = function()
{
	return 'rgba(0,0,0,0.5)';
}





Sprite_ZzyGLLNumber.prototype.refresh = function()//这将会主动的去刷新
{
	this.bitmap.clear();
	this.ExecuteDynNumber();//执行动态增粉

	if(this.GLLPrefixText != '')
	{
		this.bitmap.drawText(this.GLLPrefixText,10,0,this.bWidth,this.bHeight,'left');
		this.bitmap.drawText(this.showNumber,0,0,this.bWidth,this.bHeight,'center');
	}
	else
	{
		this.bitmap.drawText(this.showNumber,0,0,this.bWidth,this.bHeight,this.drawPos);
	}

	
}

Sprite_ZzyGLLNumber.prototype.Appear = function(delay,x,y)
{
	delay = delay ? delay : 0;
	if(x){this.x = x;}
	if(y){this.y = y;}
	this.visible = true;
	this.setScale(0,0);
	this.setDelay(delay);//延迟
	this.ScaleToOfTime(1,1,20);

}

Sprite_ZzyGLLNumber.prototype.DeAppear = function(delay)
{
	delay = delay ? delay : 0;
	this.visible = true;
	this.setScale(1,1);
	this.setDelay(delay);//延迟
	this.ScaleToOfTime(0,0,20);
	this.setScaleEndDisvisible();//隐身
}



Sprite_ZzyGLLNumber.prototype.ExecuteDynNumber = function()
{
	if(this.isBusy())return;
	Sprite_ZzyGCFNumber.prototype.ExecuteDynNumber.call(this);
}








//=========================================================================================
//PSprite_ZzyGLLEffect
//=========================================================================================


function PSprite_ZzyGLLEffect() 
{
    this.initialize.apply(this, arguments);
}


PSprite_ZzyGLLEffect.prototype = Object.create(PSprite_ZzyGCFBase.prototype);
PSprite_ZzyGLLEffect.prototype.constructor = PSprite_ZzyGLLEffect;

PSprite_ZzyGLLEffect.prototype.initialize = function(creater) 
{
	PSprite_ZzyGCFBase.prototype.initialize.call(this,creater);
	
	
}

PSprite_ZzyGLLEffect.prototype.updateOpacity = function()
{
	//透明度小于50%时开始进入渐变
	this.opacity = this.startOpactiy * this.CdestroyTime / this.temp1 * Math.random();

}



//=========================================================================================
//Sprite_ZzyGLLGameBlock
//=========================================================================================
function Sprite_ZzyGLLGameBlock() 
{
    this.initialize.apply(this, arguments);
}

Sprite_ZzyGLLGameBlock.prototype = Object.create(Sprite_ZzyGLLBase.prototype);
Sprite_ZzyGLLGameBlock.prototype.constructor = Sprite_ZzyGLLGameBlock;

Sprite_ZzyGLLGameBlock.prototype.initialize = function() 
{
	Sprite_ZzyGLLBase.prototype.initialize.call(this,0,0,'',0);
	this.colorId = 0;
	this.gID = 0;
	this.isFlash = false;
	this.CFlash = 0;
	this.isFlashOnce = false;
	this.CFlashOnce = 0;
	
	this.routeArr = [];//路线	
	this.routeIndex = 0;
	this.isRouting = false;
	this.connectTarget = undefined;//连接目标
}




Sprite_ZzyGLLGameBlock.prototype.ChangeColorId = function(colorId)
{
	this.colorId = colorId;
	this.bitmap = Zzy.GLL.WindowPointer.ItemsBitmapArr[colorId];
}

Sprite_ZzyGLLGameBlock.prototype.ResetInfo = function(gID,colorId,xIndex,yIndex)
{
	this.isFlash = false;
	this.CFlash = 0;
	this.visible = true;
	this.ChangeColorId(colorId);
	this.gID = gID;
	
	//确认位置
	this.x = Zzy.GLL.PosManager.sprArr2[yIndex][xIndex].x;
	this.y = Zzy.GLL.PosManager.sprArr2[yIndex][xIndex].y;
	
	this.routeArr = [];//路线	
	this.routeIndex = 0;
	this.isRouting = false;
	this.connectTarget = undefined;//连接目标
	this.opacity = 255;
	var tScale = Zzy.GLL.WindowPointer.sizeScale;
	this.setScale(tScale,tScale);	

}

Sprite_ZzyGLLGameBlock.prototype.update = function()//执行闪烁
{
	Sprite_ZzyGLLBase.prototype.update.call(this);
	this.updateBlockFlash();
	this.updateRouteMoving();//移动
	this.updateBlockFlashOnce();
}


Sprite_ZzyGLLGameBlock.prototype.updateRouteMoving = function()
{
	if(!this.isRouting)return;
	if(!this.isBusy())
	{
		if(this.routeIndex >= this.routeArr.length)
		{
			//移动结束
			this.MoveEndAfter();//移动结束

			this.isRouting = false;
			return ;
		}
		
		
		this.MoveToOfSpeed(this.routeArr[this.routeIndex].x,this.routeArr[this.routeIndex].y,Zzy.Param.GLLConnectSpeed);
		this.routeIndex++;
	}
}

Sprite_ZzyGLLGameBlock.prototype.MoveEndAfter = function()
{
	//同时播放消失内容动画
	this.DeAppear();
	this.connectTarget.DeAppear();
	
	var spr = Zzy.GLL.WindowPointer.RequestEffectSprArr();
	spr.ResetInfo(this);//初始化信息
	
	
	//增加分数
	Zzy.GLL.WindowPointer.AddConnectScore();//加分
	this.setOpacityEndCallFunction(Zzy.GLL.WindowPointer.CheckIsPassCP,Zzy.GLL.WindowPointer,15);//回调检测
}

Sprite_ZzyGLLGameBlock.prototype.DeAppear = function()
{
	this.visible = true;
	var tScale = Zzy.GLL.WindowPointer.sizeScale;
	this.setScale(tScale,tScale);
	this.ScaleToOfTime(tScale*1.2,tScale*1.2,10);
	this.opacity = 255;
	this.OpacityToOfTime(0,15);
	this.setOpacityEndDisvisible();
	
	Zzy.GLL.PlaySE(4);
}

Sprite_ZzyGLLGameBlock.prototype.Appear = function()
{
	this.visible = true;
	this.setScale(0,0);
	var tScale = Zzy.GLL.WindowPointer.sizeScale;
	this.ScaleToOfTime(tScale,tScale,10);
	this.setDelay(this.gID+20);
}

Sprite_ZzyGLLGameBlock.prototype.StartFlash = function()
{
	this.isFlash = true;
}


Sprite_ZzyGLLGameBlock.prototype.StartOnce = function()
{
	this.isFlashOnce = true;
}


Sprite_ZzyGLLGameBlock.prototype.StopFlash = function()
{
	this.isFlash = false;
	this.setColorTone([0,0,0,0]);
}



Sprite_ZzyGLLGameBlock.prototype.updateBlockFlashOnce = function()
{
	if(!this.isFlashOnce)return;
	if(this.CFlashOnce < 20)
	{
		this.CFlashOnce++;
		var tempV = 0;
		if(this.CFlashOnce >= 10)
		{
			tempV = 255 * (10-(this.CFlashOnce-10))/10;
		}
		else if(this.CFlashOnce >= 10)
		{
			tempV = 255 * (this.CFlashOnce-10) / 10;
		}
		
		this.setColorTone([tempV*0.6,tempV*0.6,tempV*0.6,0.5]);
	}
	else
	{
		this.CFlashOnce = 0;
		this.isFlashOnce = false;
	}

	
	
}

Sprite_ZzyGLLGameBlock.prototype.updateBlockFlash = function()
{
	
	if(!this.isFlash)return;
	if(this.CFlash < 30)
	{
		this.CFlash++;
		var tempV = 0;
		if(this.CFlash >= 20)
		{
			tempV = 255 * (10-(this.CFlash-20))/10;
		}
		else if(this.CFlash >= 10)
		{
			tempV = 255 * (this.CFlash-10) / 10;
		}
		
		this.setColorTone([tempV*0.6,tempV*0.6,tempV*0.6,0.5]);
	}
	else
	{this.CFlash = 0;}

}


Sprite_ZzyGLLGameBlock.prototype.MoveToOfRoute = function(posArr)//跟随路线移动
{
	//自身跟随路线移动
	this.isRouting = true;
	this.routeArr = posArr;
	this.routeIndex = 0;
}


Sprite_ZzyGLLGameBlock.prototype.setConnectTarget = function(target)
{
	this.connectTarget = target;
}


//==========================================================================
//Sprite_ZzyGLLText
//==========================================================================
//显示文字操作

function Sprite_ZzyGLLText() 
{
    this.initialize.apply(this, arguments);
}


Sprite_ZzyGLLText.prototype = Object.create(Sprite_ZzyGCFTextBase.prototype);
Sprite_ZzyGLLText.prototype.constructor = Sprite_ZzyGLLText;

Sprite_ZzyGLLText.prototype.initialize = function(prefix) 
{
    Sprite_ZzyGCFTextBase.prototype.initialize.call(this,prefix,30,2);
	this.setTextColor('#ddff88');
}









//=========================================================================================
//Window_ZzyGLLLayerWindow
//=========================================================================================

function Window_ZzyGLLLayerWindow() 
{
    this.initialize.apply(this, arguments);
}

Window_ZzyGLLLayerWindow.prototype = Object.create(Window_ZzyGCFLayerBase.prototype);
Window_ZzyGLLLayerWindow.prototype.constructor = Window_ZzyGLLLayerWindow;

Window_ZzyGLLLayerWindow.prototype.initialize = function()
{
    Window_ZzyGCFLayerBase.prototype.initialize.call(this);
	
};


//=========================================================================================
//Window_ZzyGCFLinkLook
//=========================================================================================

function Window_ZzyGCFLinkLook() 
{
    this.initialize.apply(this, arguments);
}

Window_ZzyGCFLinkLook.prototype = Object.create(Window_ZzyGCFBase.prototype);
Window_ZzyGCFLinkLook.prototype.constructor = Window_ZzyGCFLinkLook;


Window_ZzyGCFLinkLook.prototype.initialize = function() 
{
	//初始化
    Window_ZzyGCFBase.prototype.initialize.call(this);

	//获得游戏数据
	// this.gameData = $gameSystem.getZzyGCFGameData();
	// this.gameGlobal = $gameSystem.getZzyGCFGameGlobal();
	// this.scene = SceneManager._scene;//获取全部的数值
	// this.UI							//UI窗口

	//Zzy.GLL.ReloadGLLBitmapArr();//加载位图缓存
	Zzy.GLL.WindowPointer = this;//赋予窗口指针

	this.gameStage = 0;//游戏阶段
	this.installSpr = true;//这个值是在确保所有位图全部加载成功后,在所有窗口也确认加载时,在进行位图安装
	this.centerX = Graphics.boxWidth / 2;
	this.centerY = Graphics.boxHeight / 2;

	this.InitialAllData();//初始化数据
	this.CreateAllSprite();//加载位图
	
	this.startUpGame();//启动游戏
	
	this.isNeedLoadNextCP = false;
};



Window_ZzyGCFLinkLook.prototype.startUpGame = function()
{
	this.level = parseInt(this.EvalTranslate($gameSystem.GetZzyGLLStartLevel()))-1;
	this.gameStage = 1;
}

Window_ZzyGCFLinkLook.prototype.InitialAllData = function()
{
	this.score = 0;//分数对象
	this.time = 0;//时间
	
	this.maxLevel = 0;//最大关卡数
	
	this.cpTime = 0;//关卡限定时间
	this.CcpTime = 0;//计数
	this.maxCPTime = 0;//关卡最大时间
	this.level = 0;//关卡等级
	this.list = 0;//列数
	this.line = 0;//函数
	this.size = 0;//尺寸
	this.type = 0;//类型数量
	this.sizeScale = 0;//尺寸比例
	this.maxCount = 0;//数量
	this.connectScore = 0;
	this.surplusSocre = 0;
	this.surplusCount = 0;
	

	
	this.bkBlockManager = undefined;
	this.gameBlockSpr = [];//游戏方块对象池
	this.cpBlockSpr = [];//关卡尺
	this.cpBlockPosRect = [];//位置
	
	this.effectSprArr = [];//粒子管理器
	
	this.gameState = 'init';//游戏状态
	
	this.selectInfo = {};
	this.connectType = 0;//连接类型
	
	this.isCPPass = false;//是否通关
	this.CPPassTime = 50;
	this.CCPPassTime = 0;
}

Window_ZzyGCFLinkLook.prototype.CreateAllSprite = function()
{
	//this.ItemsBitmapGroup = ImageManager.loadPicture(Zzy.Param.GLLItemArrPic);//图集
	this.ItemsBitmapGroup = ImageManager.loadBitmap(Zzy.Param.GLLPicPath,Zzy.Param.GLLItemArrPic,undefined,true);
	this.ItemsBitmapArr = [];//存储位图信息

}


Window_ZzyGCFLinkLook.prototype.RequestGameBlockSpr = function()
{
	var len = this.gameBlockSpr.length;
	
	for(var i=0;i<len;i++)
	{
		if(this.gameBlockSpr[i] && !this.gameBlockSpr[i].visible)
		{
			this.gameBlockSpr[i].visible = true;
			return this.gameBlockSpr[i];
		}
	}
	
	var spr = new Sprite_ZzyGLLGameBlock();
	Zzy.GLL.Window2Pointer.addChild(spr);
	this.gameBlockSpr.push(spr);
	return spr;
}




Window_ZzyGCFLinkLook.prototype.NextCheckPointer = function()//进行下一关
{
	if(this.level >= this.maxLevel)
	{return false;}
	
	this.level++;
	if(this.level > $gameSystem.GetZzyGLLHistroyLevel())
	{$gameSystem.SetZzyGLLHistroyLevel(this.level)}
	
	
	
	
	this.InitCPData();
	this.InitBkBlock();
	this.InitGameBlock();
	
	this.gameState = 'wait';
	return true;
}

Window_ZzyGCFLinkLook.prototype.InitGameBlock = function()
{
	this.cpBlockSpr = [];
	this.cpBlockPosRect = [];//位置
	for(var i=0;i<this.line;i++)
	{
		this.cpBlockSpr[i] = [];
		this.cpBlockPosRect[i] = [];
	}
	
	
	//通过长宽获取存在数量
	var tMaxCount = this.line * this.list;
	this.maxCount = Math.floor(tMaxCount/2)*2;//保持偶数
	var xIndex = 0;
	var yIndex = 0;
	var colorIdArr = [];
	var colorGIDArr = [];
	
	for(var i=0;i<this.maxCount;i++)
	{
		var colorId = this.GetBlockColorId(i);//获取ID值
		colorGIDArr[i] = i;
		colorIdArr[i] = colorId;
	}
	
	colorIdArr = Zzy.GCF.RandomArr1Element(colorIdArr);//打乱位置
	colorGIDArr = Zzy.GCF.RandomArr1Element(colorGIDArr);//打乱位置
	var haSize = this.size/2;
	
	for(var i=0;i<this.maxCount;i++)
	{
		var spr = this.RequestGameBlockSpr();
		
		xIndex = i % this.list;
		yIndex = Math.floor(i/this.list);
		spr.ResetInfo(colorGIDArr[i],colorIdArr[i],xIndex,yIndex);//初始化
		this.cpBlockSpr[yIndex][xIndex] = spr;//确认位置
		this.cpBlockPosRect[yIndex][xIndex] = {};
		this.cpBlockPosRect[yIndex][xIndex].x = spr.x;
		this.cpBlockPosRect[yIndex][xIndex].y = spr.y;
		this.cpBlockPosRect[yIndex][xIndex].rect = {};
		this.cpBlockPosRect[yIndex][xIndex].rect.left = spr.x-haSize;
		this.cpBlockPosRect[yIndex][xIndex].rect.right = spr.x+haSize;
		this.cpBlockPosRect[yIndex][xIndex].rect.up = spr.y-haSize;
		this.cpBlockPosRect[yIndex][xIndex].rect.down = spr.y+haSize;	
		spr.Appear();//启动
	}
	
	

}

Window_ZzyGCFLinkLook.prototype.GetBlockColorId = function(ID)
{
	//通过ID偶数化来循环遍历申请
	var colorId = Math.floor(ID/2);
	colorId = colorId % this.type;
	return colorId;
}

Window_ZzyGCFLinkLook.prototype.InitBkBlock = function()
{
	if(!this.bkBlockManager)
	{this.bkBlockManager = this.CreateBkBlockManager();}
	this.bkBlockManager.ResetInfo(this.line,this.list);
	this.bkBlockManager.ExecuteSprArrFunction1();//刷新Appear出现	
	
	Zzy.GLL.PosManager = this.bkBlockManager;
}

Window_ZzyGCFLinkLook.prototype.InitCPData = function()
{
	
	//计算list和line
	this.maxLevel = this.EvalTranslate($gameSystem.GetZzyGLLMaxLevelFormula());
	this.line = this.EvalTranslate($gameSystem.GetZzyGLLCpLineFormula());
	this.list = this.EvalTranslate($gameSystem.GetZzyGLLCpListFormula());
	this.cpTime = this.EvalTranslate($gameSystem.GetZzyGLLCpTimeFormula());
	this.size = this.EvalTranslate($gameSystem.GetZzyGLLCpSizeFormula());
	this.type = this.EvalTranslate($gameSystem.GetZzyGLLCpTypeFormula());
	this.sizeScale = this.size / Zzy.GLL.DefaultSize;//尺寸比例	 
	this.connectScore = this.EvalTranslate($gameSystem.GetZzyGLLConnectSocreFormula());
	this.surplusSocre = this.EvalTranslate($gameSystem.GetZzyGLLSurplusTimeSocreFormula());
	this.connectInfo = {};//连接信息
		
	this.maxCPTime = this.cpTime;
	//设置UI时间线的长度
	this.UI.timeTileSpr.setMaxValue(this.cpTime);
	this.UI.timeTileSpr.setValue(0);
	this.UI.timeTileSpr.setPerOfSpeed(100,1);
	
}

Window_ZzyGCFLinkLook.prototype.RequestEffectSprArr = function()
{
	var len = this.effectSprArr.length;
	for(var i=0;i<len;i++)
	{
		if(this.effectSprArr[i] && !this.effectSprArr[i].visible)
		{
			this.effectSprArr[i].visible = true;
			return this.effectSprArr[i];
		}
	}
	var spr = new Particle_ZzyGLLEffect();
	this.addChild(spr);
	this.effectSprArr.push(spr);
	return spr;
}




Window_ZzyGCFLinkLook.prototype.CreateBkBlockManager = function()
{
	return new Sprite_ZzyGLLBatch();
}



Window_ZzyGCFLinkLook.prototype.EvalTranslate = function(formula)//转换
{
	var variables = $gameVariables._data;//全局变量
	var v = $gameVariables._data;
	var V = v;
	var switchs = $gameSwitches._data;//全局开关
	var s = $gameSwitches._data;
	var S = s;
	var score = this.score;
	var time = this.time;
	var level = this.level;
	var list = this.list;
	var line = this.line;
	var size = this.size;
	var type = this.type;
	var maxlevel = this.maxLevel;
	

	return eval(formula);
}

Window_ZzyGCFLinkLook.prototype.update = function()
{
	Window_ZzyGCFBase.prototype.update.call(this);
	if(this.isPauseDown)return;//暂停不会更新

	this.updateData();//更新数据
	this.drawData();//绘制数据

}


Window_ZzyGCFLinkLook.prototype.updateData = function()
{
	switch(this.gameStage)//不同阶段刷新情况
	{
		case 1:this.Stage1();break;//游戏开始时
		case 2:this.Stage2();break;//游戏运行中
		case 3:this.Stage3();break;
		case 4:this.Stage4();break;//暂停时
	}
}

Window_ZzyGCFLinkLook.prototype.drawData = function()
{
	
	
	
}


Window_ZzyGCFLinkLook.prototype.IsReadyWindowPointer = function()
{
	if(Zzy.GLL.WindowPointer && 
	Zzy.GLL.WindowPointer.UI &&
	Zzy.GLL.Window1Pointer &&
	Zzy.GLL.Window2Pointer &&
	Zzy.GLL.Window3Pointer)
	{return true;}
	return false;
	
}


Window_ZzyGCFLinkLook.prototype.IsReadyLoadPicture = function()//图片合集
{
	
	if(this.ItemsBitmapGroup && this.ItemsBitmapGroup.width && this.ItemsBitmapGroup.height)
	{
		return true;
	}
	
	return false;	
}


Window_ZzyGCFLinkLook.prototype.Stage1 = function()
{
	if(this.installSpr)//加载图片检测
	{
		if(this.IsReadyWindowPointer() && this.IsReadyLoadPicture())
		{
			this.installSpr = false;
			this.Stage1ToStage2();//进入第二阶段
		}
		
	}
	
}


Window_ZzyGCFLinkLook.prototype.Stage1ToStage2 = function()
{
	this.gameStage = 2;
	this.ItemsBitmapArr = Zzy.GCF.SplitPictureToArr1(Zzy.Param.GLLItemArrPic,this.ItemsBitmapGroup);//切分图片
	this.InitGameDate();
}



Window_ZzyGCFLinkLook.prototype.Stage2 = function()
{
	this.updateGameStage();//游戏状态	
	this.updateNextCP();//更新进入下一关
	this.updateCPPass();//更新通关


	this.updateGameTime();//更新游戏时间
	if(this.isSpecial1())//特殊情况结束
	{
		this.gameGlobal.result = 'other1';
		this.Stage2ToStage3();//跳到游戏结束界面
		this.UI.CallGameOverInterface('win');
	}
	else if(this.isSpecial2())
	{
		this.gameGlobal.result = 'other2';
		this.Stage2ToStage3();//跳到游戏结束界面
		this.UI.CallGameOverInterface('win');
	}	
	
}


Window_ZzyGCFLinkLook.prototype.InitGameDate = function()
{
	this.isNeedLoadNextCP = true;//加载下一关标记
	this.maxLevel = this.EvalTranslate($gameSystem.GetZzyGLLMaxLevelFormula());	
}


Window_ZzyGCFLinkLook.prototype.updateCPPass = function()
{
	if(!this.isCPPass)return;
	
	//进入下一关
	if(this.CCPPassTime < this.CPPassTime)
	{
		this.CCPPassTime++;
	}
	else//进入下一关
	{
		this.CCPPassTime = 0;
		this.isCPPass = false;
		var result = this.NextCheckPointer();
		
		if(!result)//到达最大关卡,代表游戏胜利
		{
			//游戏通关
			this.gameState = 'win';
			this.UI.CallGameOverInterface('win');
			this.Stage2ToStage3();
		}
	}
}


Window_ZzyGCFLinkLook.prototype.SettlementGameDate = function()
{
	this.gameGlobal.score = this.score;
	this.gameGlobal.time = this.time;
	
}


Window_ZzyGCFLinkLook.prototype.updateGameStage = function()
{
	if(!this.TheReturnGameState())return;
	
	if(this.isCPPass){this.gameState = 'pass';}
	
	for(var i=0;i<this.line;i++)
	{
		for(var j=0;j<this.list;j++)
		{
			if(!this.cpBlockSpr[i][j])continue;
			if(!this.cpBlockSpr[i][j].visible)continue;
			
			if(this.cpBlockSpr[i][j].isBusy())
			{
				this.gameState = 'wait';
				return;
			}
			
		}
	}
	
	
	this.gameState = 'play';
	return;
	
}

Window_ZzyGCFLinkLook.prototype.TheReturnGameState = function()
{
	switch(this.gameState)
	{
		case 'init':case 'win':case 'lose':return false;
	}
	return true;
}






Window_ZzyGCFLinkLook.prototype.updateNextCP = function()
{
	if(!this.isNeedLoadNextCP)return;
	this.NextCheckPointer();//进入下一关
	this.isNeedLoadNextCP = false;
}



Window_ZzyGCFLinkLook.prototype.Stage2ToStage3 = function()
{
	this.gameStage = 3;
	this.SettlementGameDate();//结算游戏信息
}



Window_ZzyGCFLinkLook.prototype.Stage3 = function()
{

	
}



Window_ZzyGCFLinkLook.prototype.Stage4 = function()//暂停时
{
	
	
}



Window_ZzyGCFLinkLook.prototype.isSpecial1 = function()
{
	return Zzy.Param.GLLOtherEnd1Script();
}

Window_ZzyGCFLinkLook.prototype.isSpecial2 = function()
{
	return Zzy.Param.GLLOtherEnd2Script();
}


Window_ZzyGCFLinkLook.prototype.updateGameTime = function()//刷新游戏时间
{

	this.time++;
	if(this.gameState === 'play')
	{
		if(this.CcpTime < 60)
		{this.CcpTime++;}
		else
		{
			this.CcpTime = 0;
			this.cpTime--;//减少时间
			
			
			if(this.cpTime <= 0)//游戏失败
			{
				this.gameState = 'lose';
				//呼叫游戏结束界面
				this.UI.CallGameOverInterface('fail');
				this.Stage2ToStage3();
			}			
		}			
	}
	
}




Window_ZzyGCFLinkLook.prototype.IsOperation = function()//可以操作
{
	//不处于等待操控和按下暂停时
	if(this.isPauseDown)return false;
	
	
	return true;
}


Window_ZzyGCFLinkLook.prototype.OnKeyP = function()
{
	var isPause = Window_ZzyGCFBase.prototype.OnKeyP.call(this);
	this.isPauseDown = isPause;
	this.UI.setPause(isPause);//执行暂停图片
}




Window_ZzyGCFLinkLook.prototype.ExecutePase = function()//暂停
{
	this.gameStage = 4;
}

Window_ZzyGCFLinkLook.prototype.ExitGame = function()
{
	
	Zzy.GCF.exitGame(this.gameGlobal.result);
}


//一般用于绑定数字位图的显示
Window_ZzyGCFLinkLook.prototype.getScore = function()//返回目前分数
{
	return Zzy.GLL.WindowPointer.score;
}

Window_ZzyGCFLinkLook.prototype.getTime = function()//返回目前时间
{
	return Zzy.GLL.WindowPointer.time;
}

Window_ZzyGCFLinkLook.prototype.getGlobalScore = function()//返回目前分数
{
	return Zzy.GLL.WindowPointer.gameGlobal.score;
}

Window_ZzyGCFLinkLook.prototype.getGlobalTime = function()//返回目前分数
{
	return Math.floor(Zzy.GLL.WindowPointer.gameGlobal.time / 60);
}


Window_ZzyGCFLinkLook.prototype.getCPTime = function()
{
	return Zzy.GLL.WindowPointer.cpTime;
}

Window_ZzyGCFLinkLook.prototype.getLevel = function()//返回目前时间
{
	return Zzy.GLL.WindowPointer.level;
}

Window_ZzyGCFLinkLook.prototype.getHistroyScore = function()//返回目前时间
{
	return $gameSystem.GetZzyGLLHistroyScore();//获取历史分数
}

Window_ZzyGCFLinkLook.prototype.getHistroyLevel = function()
{
	return $gameSystem.GetZzyGLLHistroyLevel();//历史等级
}


Window_ZzyGCFLinkLook.prototype.ClearGameGlobal = function()
{
	this.gameGlobal.score = 0;
	this.gameGlobal.time = 0;
	this.gameGlobal.result = '';
}

Window_ZzyGCFLinkLook.prototype.OnTouch = function()//移动中
{
	Window_ZzyGCFBase.prototype.OnTouch.call(this)
	
	if(!this.IsCanPlayTouch())return;
	
	
	var info = this.ReturnClickIndex();
	if(info.x === -1 || info.y === -1 || info.spr === undefined)return;//忽略
	if(info.spr.visible === false)return;
	
	//选中了

	if(this.selectInfo.spr === undefined)//不存在时视为第一次选择
	{
		this.selectInfo.x = info.x;
		this.selectInfo.y = info.y;
		this.selectInfo.spr = info.spr;
		//被选中目标进行闪烁
		this.selectInfo.spr.StartFlash();//开始闪烁
		
		Zzy.GLL.PlaySE(2);
	}
	else if(this.selectInfo.x === info.x && this.selectInfo.y === info.y)//第二次选择相同内容时
	{
		//同时选中一个目标
		this.selectInfo.spr.StopFlash();
		this.ClearSelectInfo();
		Zzy.GLL.PlaySE(2);
	}
	else
	{
		this.selectInfo.spr.StartOnce();
		info.spr.StartOnce();
		this.selectInfo.spr.StopFlash();

		
		//判断两个的碰撞情况
		if(this.JudgIsConnect(this.selectInfo,info))
		{
			//连接成功
			var routeArr = this.MapTheRouteArr(this.connectInfo.pos);
			this.connectInfo.src.MoveToOfRoute(routeArr);//点击源开始移动
			this.connectInfo.src.setConnectTarget(this.connectInfo.tar);//绑定
			
			Zzy.GLL.PlaySE(2);
		}
		else
		{
			Zzy.GLL.PlaySE(3);
		}
		
		this.ClearSelectInfo();		
	}
	
	
}


Window_ZzyGCFLinkLook.prototype.MapTheRouteArr = function(routeArr)
{
	//映射
	var posArr = this.cpBlockPosRect;
	var newRouteArr = [];
	var x = 0;
	var y = 0;
	var resX = 0;
	var resY = 0;

	for(var i=0;i<routeArr.length;i++)
	{
		x = routeArr[i].x;
		y = routeArr[i].y;
		
		if(x >= 0 && x <= this.list-1 && y >= 0 && y <= this.line-1)
		{
			resX = posArr[y][x].x;
			resY = posArr[y][x].y;		
		}		
		else
		{
			var correctX = x;
			correctX = Math.max(0,Math.min(correctX,this.list-1));
			
			var correctY = y;
			correctY = Math.max(0,Math.min(correctY,this.line-1));
			
			
			if(x === -1)
			{
				resX = posArr[correctY][correctX].x - this.size;
			}
			else if(x === this.list)
			{
				resX = posArr[correctY][correctX].x + this.size;
			}
			else
			{
				resX = posArr[correctY][correctX].x;
			}
		
			if(y === -1)
			{
				resY = posArr[correctY][correctX].y - this.size;
			}
			else if(y === this.line)
			{
				resY = posArr[correctY][correctX].y + this.size;
			}
			else
			{
				resY = posArr[correctY][correctX].y;
			}
		}
		var point = {x:resX,y:resY};
		newRouteArr.push(point);
	}
	return newRouteArr;
}



Window_ZzyGCFLinkLook.prototype.ClearSelectInfo = function()
{
	this.selectInfo.x = -1;
	this.selectInfo.y = -1;
	this.selectInfo.spr = undefined;	
	
}

Window_ZzyGCFLinkLook.prototype.AddConnectScore = function(value)
{
	value = value ? value : this.connectScore;
	this.score += value;
	
	if(this.score > $gameSystem.GetZzyGLLHistroyScore())
	{
		$gameSystem.SetZzyGLLHistroyScore(this.score);//修改历史最高分
	}
	
}

Window_ZzyGCFLinkLook.prototype.AddCPTimeScore = function()
{
	this.AddConnectScore(this.cpTime * this.surplusSocre);
}



Window_ZzyGCFLinkLook.prototype.CheckIsPassCP = function(pointer)//检测是否通过本关
{
	for(var i=0;i<pointer.line;i++)
	{
		for(var j=0;j<pointer.list;j++)
		{
			if(pointer.cpBlockSpr[i][j].visible)
			{
				return;
			}
		}
	}
	
	//全部消灭
	pointer.isCPPass = true;//通关
	pointer.AddCPTimeScore();
}





Window_ZzyGCFLinkLook.prototype.JudgIsConnect = function(srcInfo,tarInfo)//判断是否连接
{
	if(srcInfo.spr.colorId !== tarInfo.spr.colorId)return false;//颜色不同

	this.connectInfo.src = srcInfo.spr;
	this.connectInfo.tar = tarInfo.spr;
	this.connectInfo.pos = [];


	
	this.connectType = 0;//连接类型	
	if(this.IsConnect1(srcInfo,tarInfo))//方法一相连接
	{
		this.connectType = 1;
		return true;
	}
	if(this.IsConnect2(srcInfo,tarInfo))//方法二相连接:直线
	{
		this.connectType = 2;
		return true;
	}
	if(this.IsConnect3(srcInfo,tarInfo))//方法三相连接:存在一个转角
	{
		this.connectType = 3;
		return true;		
	}
	if(this.IsConnect4(srcInfo,tarInfo))//方法四相连接:存在两个转角
	{
		this.connectType = 4;
		return true;		
	}
	
	return false;
}	


Window_ZzyGCFLinkLook.prototype.PushPos = function(tx,ty)
{
	var pos = {x:tx,y:ty};
	this.connectInfo.pos.push(pos);
}


	
Window_ZzyGCFLinkLook.prototype.IsConnect1 = function(srcInfo,tarInfo)//第一种情况,相邻
{
	//判断是否为临近
	
	var disX = Math.abs(srcInfo.x - tarInfo.x);
	var disY = Math.abs(srcInfo.y - tarInfo.y);
	
	if(srcInfo.x === tarInfo.x)
	{
		if(disY === 1)
		{
			this.PushPos(tarInfo.x,tarInfo.y);	
			return true;
		}
	}
	if(srcInfo.y === tarInfo.y)
	{
		if(disX === 1)
		{
			this.PushPos(tarInfo.x,tarInfo.y);
			return true;
		}
	}
	
	return false;
}
	
Window_ZzyGCFLinkLook.prototype.IsConnect2 = function(srcInfo,tarInfo)//第二种情况,处于一条直线内,中间不存在阻拦
{
	var isConnect = false;
	var pos1 = {};
	var pos2 = {};
	pos1.x = srcInfo.x;
	pos1.y = srcInfo.y;
	pos2.x = tarInfo.x;
	pos2.y = tarInfo.y;
	

	if(this.JudgRouteIsPass(pos1,pos2))
	{
		this.PushPos(tarInfo.x,tarInfo.y);	
		return true;
	}
	
	return false;
}


Window_ZzyGCFLinkLook.prototype.IsConnect3 = function(srcInfo,tarInfo)//第三种情况,存在一个转角
{
	//计算存在一个角的情况
	//从x到y  和  从y到x
	var dir = 0;
	dir = this.JudgValueDir(srcInfo.x,tarInfo.x);


	//x->y
	var pos1 = {};
	var pos2 = {};
	
	pos1.x = srcInfo.x;
	pos1.y = srcInfo.y;
	pos2.x = srcInfo.x;
	pos2.y = tarInfo.y;
	
	if(this.JudgRouteIsPass(pos1,pos2))
	{
		if(!this.cpBlockSpr[tarInfo.y][srcInfo.x].visible)
		{
			pos1.x = srcInfo.x;
			pos1.y = tarInfo.y;
			pos2.x = tarInfo.x;
			pos2.y = tarInfo.y;			
			if(this.JudgRouteIsPass(pos1,pos2))
			{
				this.PushPos(srcInfo.x,tarInfo.y);
				this.PushPos(tarInfo.x,tarInfo.y);
				return true;
			}
		}	
	}
	
	pos1.x = srcInfo.x;
	pos1.y = srcInfo.y;
	pos2.x = tarInfo.x;
	pos2.y = srcInfo.y;	
	
	//y->x
	if(this.JudgRouteIsPass(pos1,pos2))
	{
		if(!this.cpBlockSpr[srcInfo.y][tarInfo.x].visible)
		{
			pos1.x = tarInfo.x;
			pos1.y = srcInfo.y;
			pos2.x = tarInfo.x;
			pos2.y = tarInfo.y;			
			if(this.JudgRouteIsPass(pos1,pos2))
			{
				this.PushPos(tarInfo.x,srcInfo.y);
				this.PushPos(tarInfo.x,tarInfo.y);
				return true;
			}			
		}
		
	}
	
	return false;
	
}

	
Window_ZzyGCFLinkLook.prototype.IsConnect4 = function(srcInfo,tarInfo)//第四种情况,存在两个转角
{
	//两个转角存在的情况是比价横向和纵向的连接情况
	if(this.JudgLineConnect4(srcInfo,tarInfo))
	{
		return true;
	}
	if(this.JudgListConnect4(srcInfo,tarInfo))
	{
		return true;
	}
	return false;
}



Window_ZzyGCFLinkLook.prototype.JudgLineConnect4 = function(srcInfo,tarInfo)
{
	var centerY = Math.floor((srcInfo.y+tarInfo.y)/2);
	var up = centerY;
	var down = centerY+1;
	var upEnd = false;
	var downEnd = false;
	var pos1 = {};
	var pos2 = {};		
	
	while(true)//3层路线判断
	{
		//左遍历
		pos1.x = srcInfo.x;
		pos1.y = srcInfo.y;
		pos2.x = srcInfo.x;
		pos2.y = up;
			
		if(!upEnd && this.JudgRouteIsPass(pos1,pos2))//正确路线
		{
			if(up === -1)
			{
				pos1.x = tarInfo.x;
				pos1.y = up;
				pos2.x = tarInfo.x;
			    pos2.y = tarInfo.y;	
				if(this.JudgRouteIsPass(pos1,pos2))
				{
					this.PushPos(srcInfo.x,up);
					this.PushPos(tarInfo.x,up);
					this.PushPos(tarInfo.x,tarInfo.y);							
					return true;					
				}
			}
			else if(!this.cpBlockSpr[pos2.y][pos2.x].visible)
			{
				pos1.x = pos2.x;
				pos1.y = pos2.y;
				pos2.x = tarInfo.x;
			    pos2.y = up;
				if(this.JudgRouteIsPass(pos1,pos2))//正确路线
				{
					if(!this.cpBlockSpr[pos2.y][pos2.x].visible)
					{
						pos1.x = pos2.x;
						pos1.y = pos2.y;
						pos2.x = tarInfo.x;
						pos2.y = tarInfo.y;
						if(this.JudgRouteIsPass(pos1,pos2))//正确路线
						{
							this.PushPos(srcInfo.x,up);
							this.PushPos(tarInfo.x,up);
							this.PushPos(tarInfo.x,tarInfo.y);							
							return true;
						}
					}
				}	
			}	
		}
		

		pos1.x = srcInfo.x;
		pos1.y = srcInfo.y;
		pos2.x = srcInfo.x;
		pos2.y = down;
			
		if(!downEnd && this.JudgRouteIsPass(pos1,pos2))//正确路线
		{
			if(down === this.line)
			{
				pos1.x = tarInfo.x;
				pos1.y = down;
				pos2.x = tarInfo.x;
			    pos2.y = tarInfo.y;	
				if(this.JudgRouteIsPass(pos1,pos2))
				{
					this.PushPos(srcInfo.x,down);
					this.PushPos(tarInfo.x,down);
					this.PushPos(tarInfo.x,tarInfo.y);							
					return true;					
				}
			}
			else if(!this.cpBlockSpr[pos2.y][pos2.x].visible)
			{
				pos1.x = pos2.x;
				pos1.y = pos2.y;
				pos2.x = tarInfo.x;
			    pos2.y = down;
				if(this.JudgRouteIsPass(pos1,pos2))//正确路线
				{
					if(!this.cpBlockSpr[pos2.y][pos2.x].visible)
					{
						pos1.x = pos2.x;
						pos1.y = pos2.y;
						pos2.x = tarInfo.x;
						pos2.y = tarInfo.y;
						if(this.JudgRouteIsPass(pos1,pos2))//正确路线
						{
							this.PushPos(srcInfo.x,down);
							this.PushPos(tarInfo.x,down);
							this.PushPos(tarInfo.x,tarInfo.y);							
							return true;
						}
					}
				}	
			}	
		}

		if(up <= -1)
		{upEnd = true;}
		else
		{up--;}
	
		if(down >= this.line)
		{downEnd = true;}
		else
		{down++;}	
	
		if(upEnd && downEnd)
		{return false;}
	}
	return false;
}




Window_ZzyGCFLinkLook.prototype.JudgListConnect4 = function(srcInfo,tarInfo)
{
	var centerX = Math.floor((srcInfo.x+tarInfo.x)/2);
	var left = centerX;
	var right = centerX+1;
	var leftEnd = false;
	var rightEnd = false;
	var pos1 = {};
	var pos2 = {};		
	
	while(true)//3层路线判断
	{
		//左遍历
		pos1.x = srcInfo.x;
		pos1.y = srcInfo.y;
		pos2.x = left;
		pos2.y = srcInfo.y;
			
		if(!leftEnd && this.JudgRouteIsPass(pos1,pos2))//正确路线
		{
			if(left === -1)
			{
				pos1.x = left;
				pos1.y = tarInfo.y;
				pos2.x = tarInfo.x;
			    pos2.y = tarInfo.y;	
				if(this.JudgRouteIsPass(pos1,pos2))
				{
					this.PushPos(left,srcInfo.y);
					this.PushPos(left,tarInfo.y);
					this.PushPos(tarInfo.x,tarInfo.y);							
					return true;					
				}
			}
			else if(!this.cpBlockSpr[pos2.y][pos2.x].visible)
			{
				pos1.x = pos2.x;
				pos1.y = pos2.y;
				pos2.x = left;
			    pos2.y = tarInfo.y;
				if(this.JudgRouteIsPass(pos1,pos2))//正确路线
				{
					if(!this.cpBlockSpr[pos2.y][pos2.x].visible)
					{
						pos1.x = pos2.x;
						pos1.y = pos2.y;
						pos2.x = tarInfo.x;
						pos2.y = tarInfo.y;
						if(this.JudgRouteIsPass(pos1,pos2))//正确路线
						{
							this.PushPos(left,srcInfo.y);
							this.PushPos(left,tarInfo.y);
							this.PushPos(tarInfo.x,tarInfo.y);							
							return true;
						}
					}
				}	
			}	
		}
		
		pos1.x = srcInfo.x;
		pos1.y = srcInfo.y;
		pos2.x = right;
		pos2.y = srcInfo.y;		
		
		if(!rightEnd && this.JudgRouteIsPass(pos1,pos2))//正确路线
		{
			if(right === this.list)
			{
				pos1.x = right;
				pos1.y = tarInfo.y;
				pos2.x = tarInfo.x;
			    pos2.y = tarInfo.y;	
				if(this.JudgRouteIsPass(pos1,pos2))
				{
					this.PushPos(right,srcInfo.y);
					this.PushPos(right,tarInfo.y);
					this.PushPos(tarInfo.x,tarInfo.y);							
					return true;					
				}
			}
			else if(!this.cpBlockSpr[pos2.y][pos2.x].visible)
			{
				pos1.x = pos2.x;
				pos1.y = pos2.y;
				pos2.x = right;
			    pos2.y = tarInfo.y;
				if(this.JudgRouteIsPass(pos1,pos2))//正确路线
				{
					if(!this.cpBlockSpr[pos2.y][pos2.x].visible)
					{
						pos1.x = pos2.x;
						pos1.y = pos2.y;
						pos2.x = tarInfo.x;
						pos2.y = tarInfo.y;
						if(this.JudgRouteIsPass(pos1,pos2))//正确路线
						{
							this.PushPos(right,srcInfo.y);
							this.PushPos(right,tarInfo.y);
							this.PushPos(tarInfo.x,tarInfo.y);							
							return true;
						}
					}
				}	
			}	
		}		

		if(left <= -1)
		{leftEnd = true;}
		else
		{left--;}
	
		if(right >= this.list)
		{rightEnd = true;}
		else
		{right++;}	
	
		if(leftEnd && rightEnd)
		{return false;}
	}
	return false;
}



Window_ZzyGCFLinkLook.prototype.JudgRouteIsPass = function(route1,route2)
{
	if(route1.x === route2.x && route1.y === route2.y)return true;
	

	if(route1.x === route2.x)//横向相同
	{
		var dir = this.JudgValueDir(route1.y,route2.y);
		for(var i=route1.y+dir;i !== route2.y;i += dir)
		{
			if(this.cpBlockSpr[i][route1.x].visible)//不通过
			{return false;}
		}
		return true;
	}
	if(route1.y === route2.y)//纵向相同
	{
		var dir = this.JudgValueDir(route1.x,route2.x);
		for(var j=route1.x+dir;j !== route2.x;j += dir)
		{
			if(this.cpBlockSpr[route1.y][j].visible)//不通过
			{return false;}
		}
		return true;
	}
	
	return false;
}

Window_ZzyGCFLinkLook.prototype.IsSameRoute = function(route1,route2)
{
	if(route1.x === route2.x && route1.y === route2.y)
	{return true;}
return false;
}




Window_ZzyGCFLinkLook.prototype.JudgRouteIsPassArr = function(routeArr)//断点线路测试
{
	var len = routeArr.length;
	var startPos = undefined;
	var endPos = undefined;
	var index = 0;
	var dir = 0;
	
	while(index < len-1)
	{
		startPos = routeArr[index];
		endPos = routeArr[index+1];
		
		if(startPos.x === -1 || startPos.y === -1 || endPos.x === -1 || endPos.y === -1){continue;}//满足屏幕外部的情况
		
		if(startPos.x === endPos.x)//x相同比较y
		{
			dir = this.JudgValueDir(startPos.y,endPos.y);
			
			for(var i=startPos.y+dir;i !== endPos.y;i += dir)
			{
				if(this.cpBlockSpr[i][startPos.x].visible)
				{return false;}
			}
			
			if(index < len-2)//并非最后一个点
			{
				if(this.cpBlockSpr[endPos.y][endPos.x].visible){return false;}
			}
			
			
		}
		else//y相同比较x
		{
			dir = this.JudgValueDir(startPos.x,endPos.x);
			for(var j=startPos.x+dir;j !== endPos.x;j += dir)
			{
				if(this.cpBlockSpr[startPos.y][j].visible)
				{return false;}				
			}
			
			if(index < len-2)//并非最后一个点
			{
				if(this.cpBlockSpr[endPos.y][endPos.x].visible){return false;}
			}
		}
		index++;
	}
	return true;
}





Window_ZzyGCFLinkLook.prototype.JudgValueDir = function(v1,v2)
{
	if(v1 < v2)
	{return 1;}
	else if(v1 > v2)
	{return -1;}
	else
	{return 0;}
}






Window_ZzyGCFLinkLook.prototype.IsCanPlayTouch = function()//是否可以点击
{
	if(this.gameStage !== 2)return false;
	if(this.gameState !== 'play')return false;
	
	
	return true;
}


Window_ZzyGCFLinkLook.prototype.ReturnClickIndex = function()
{
	//判断点中了哪个位置
	var pt = {x:this.scene.OnTouchX,y:this.scene.OnTouchY};
	
	
	for(var i=0;i<this.line;i++)
	{
		for(var j=0;j<this.list;j++)
		{
			if(Zzy.GCF.PtInRect2(pt,this.cpBlockPosRect[i][j].rect))
			{
				var info = {};
				info.x = j;
				info.y = i;
				info.spr = this.cpBlockSpr[i][j];
				return info;
			}
		}
	}
	var info = {};
	info.x = -1;
	info.y = -1;
	info.spr = undefined;
	return info;
}



Window_ZzyGCFLinkLook.prototype.OutTouch = function()//移动中
{
	Window_ZzyGCFBase.prototype.OutTouch.call(this);

}






//=======================================================================
//Window_ZzyGCFLinkLookUI
//=======================================================================

function Window_ZzyGCFLinkLookUI() 
{
    this.initialize.apply(this, arguments);
}

Window_ZzyGCFLinkLookUI.prototype = Object.create(Window_ZzyGCFBaseUI.prototype);
Window_ZzyGCFLinkLookUI.prototype.constructor = Window_ZzyGCFLinkLookUI;

Window_ZzyGCFLinkLookUI.prototype.initialize = function() 
{
	//初始化
    var width = this.Width();
    var height = this.Height();
	
    Window_ZzyGCFBaseUI.prototype.initialize.call(this, 0, 0, width, height);

	this.centerX = Graphics.boxWidth / 2;
	this.centerY = Graphics.boxHeight / 2;
	
	this.CreateAllSprite();
	this.InitAllSprite();//初始化
	

};	


Window_ZzyGCFLinkLookUI.prototype.InitAllSprite = function()
{
	//绑定位置
	this.MenuBkSpr.setBindingOk(this.OkButtonSpr);
	this.MenuBkSpr.setBindingCancel(this.CancelButtonSpr);
}




Window_ZzyGCFLinkLookUI.prototype.OnExitButton = function()
{
	switch(Zzy.GLL.WindowPointer.gameStage)
	{
		case 2:
			//召唤退出窗口
			this.MenuBkSpr.Appear();
		break;
		
		case 4:

		break;
	}
}




Window_ZzyGCFLinkLookUI.prototype.CallGameOverInterface = function(result)
{
	Zzy.GLL.WindowPointer.gameGlobal.result = result;
	this.MenuBkSpr.GameOverAppear(result);	
	
}

Window_ZzyGCFLinkLookUI.prototype.CallRGameOverInterface = function(result)
{
	Zzy.GLL.WindowPointer.gameGlobal.result = result;
	this.MenuBkSpr.GameOverAppear(result);		

}


Window_ZzyGCFLinkLookUI.prototype.OnCancelButton = function()//取消
{
	this.MenuBkSpr.DisAppear();	
}

Window_ZzyGCFLinkLookUI.prototype.OnOkButton = function()
{
	Zzy.GLL.WindowPointer.Stage2ToStage3();
	this.CallRGameOverInterface('fail');
}




Window_ZzyGCFLinkLookUI.prototype.BackGameRunning = function()//返回游戏界面
{
	Zzy.GLL.WindowPointer.gameStage = 2;//回到游戏运行状态
}


Window_ZzyGCFLinkLookUI.prototype.CreateAllSprite = function()
{
	this.CreateInfoAndText();//创造文字和数字
	this.CreateAllButton();//创造按钮
	this.CreatePauseSpr();//暂停
}


Window_ZzyGCFLinkLookUI.prototype.CreateInfoAndText = function()
{
	


	
	this.levelSpr = new Sprite_ZzyGLLNumber(Zzy.Param.GLLLevelSprT,Zzy.Param.GLLLevelSprTC);
	this.levelSpr.x = eval(Zzy.Param.GLLLevelSprX);
	this.levelSpr.y = eval(Zzy.Param.GLLLevelSprY);
	this.levelSpr.setFontSize(Zzy.Param.GLLLevelSprTS);
	this.levelSpr.setBorderColor(Zzy.Param.GLLLevelSprBC);
	this.levelSpr.setBorderWidth(Zzy.Param.GLLLevelSprBS);
	

	this.scoreSpr = new Sprite_ZzyGLLNumber(Zzy.Param.GLLScoreSprT,Zzy.Param.GLLScoreSprTC,320);
	this.scoreSpr.x = eval(Zzy.Param.GLLScoreSprX);
	this.scoreSpr.y = eval(Zzy.Param.GLLScoreSprY);
	this.scoreSpr.setFontSize(Zzy.Param.GLLScoreSprTS);
	this.scoreSpr.setBorderColor(Zzy.Param.GLLScoreSprBC);
	this.scoreSpr.setBorderWidth(Zzy.Param.GLLScoreSprBS);	
	
	
	this.maxScoreSpr = new Sprite_ZzyGLLNumber(Zzy.Param.GLLMaxScoreSprT,Zzy.Param.GLLMaxScoreSprTC,400);
	this.maxScoreSpr.x = eval(Zzy.Param.GLLMaxScoreSprX);
	this.maxScoreSpr.y = eval(Zzy.Param.GLLMaxScoreSprY);
	this.maxScoreSpr.setFontSize(Zzy.Param.GLLMaxScoreSprTS);
	this.maxScoreSpr.setBorderColor(Zzy.Param.GLLMaxScoreSprBC);
	this.maxScoreSpr.setBorderWidth(Zzy.Param.GLLMaxScoreSprBS);		
	
	
	this.timeSpr = new Sprite_ZzyGLLText(Zzy.Param.GLLTimeSprT);
	this.timeSpr.x = eval(Zzy.Param.GLLTimeSprX);
	this.timeSpr.y = eval(Zzy.Param.GLLTimeSprY);
	this.timeSpr.setTextColor(Zzy.Param.GLLTimeSprTC);
	this.timeSpr.setFontSize(Zzy.Param.GLLTimeSprTS);
	this.timeSpr.setBorderColor(Zzy.Param.GLLTimeSprBC);
	this.timeSpr.setBorderWidth(Zzy.Param.GLLTimeSprBS);		
	

	this.scoreTotalSpr = new Sprite_ZzyGLLNumber(Zzy.Param.GLLScoreTotalT,Zzy.Param.GLLScoreTotalTC,320);
	this.scoreTotalSpr.setBorderColor('rgba(180,120,120,1)');
	this.scoreTotalSpr.x = eval(Zzy.Param.GLLScoreTotalX);
	this.scoreTotalSpr.y = eval(Zzy.Param.GLLScoreTotalY);
	this.scoreTotalSpr.setFontSize(Zzy.Param.GLLScoreTotalTS);
	this.scoreTotalSpr.setBorderColor(Zzy.Param.GLLScoreTotalBC);
	this.scoreTotalSpr.setBorderWidth(Zzy.Param.GLLScoreTotalBS);	



	this.timeTotalSpr = new Sprite_ZzyGLLNumber(Zzy.Param.GLLTimeTotalT,Zzy.Param.GLLTimeTotalTC,320);
	this.timeTotalSpr.setBorderColor('rgba(180,120,120,1)');
	this.timeTotalSpr.x = eval(Zzy.Param.GLLTimeTotalX);
	this.timeTotalSpr.y = eval(Zzy.Param.GLLTimeTotalY);
	this.timeTotalSpr.setFontSize(Zzy.Param.GLLTimeTotalTS);
	this.timeTotalSpr.setBorderColor(Zzy.Param.GLLTimeTotalBC);
	this.timeTotalSpr.setBorderWidth(Zzy.Param.GLLTimeTotalBS);	
	

	this.addChild(this.levelSpr);
	this.addChild(this.scoreSpr);
	this.addChild(this.maxScoreSpr);
	this.addChild(this.timeSpr);

	
	//创建时间条
	this.timeTileSpr = new Sprite_ZzyGLLTimer(Zzy.Param.GLLTimeTileL,Zzy.Param.GLLTimeTileH,100);
	this.timeTileSpr.setPostion(eval(Zzy.Param.GLLTimeTileX),eval(Zzy.Param.GLLTimeTileY));
	this.addChild(this.timeTileSpr);



	//创建时间条背景
	this.timeTileSprBk = new Sprite_ZzyGLLTimerBk(this.timeTileSpr.x,this.timeTileSpr.y+1);
	
	this.MenuBkSpr = new Sprite_ZzyGLLMenuBk();
		
		
	this.addChild(this.timeTileSprBk);
	this.addChild(this.MenuBkSpr);	
	this.addChild(this.scoreTotalSpr);
	this.addChild(this.timeTotalSpr);	
		

	//进行绑定
	this.levelSpr.setBindNumberFunction(Zzy.GLL.WindowPointer.getLevel);
	this.scoreSpr.setBindNumberFunction(Zzy.GLL.WindowPointer.getScore);
	this.maxScoreSpr.setBindNumberFunction(Zzy.GLL.WindowPointer.getHistroyScore);
	this.scoreTotalSpr.setBindNumberFunction(Zzy.GLL.WindowPointer.getGlobalScore);
	this.timeTotalSpr.setBindNumberFunction(Zzy.GLL.WindowPointer.getGlobalTime);
	
	
	
	
	//创建文本
	this.tipsSpr = new Sprite_ZzyGLLText(Zzy.GLL.TextArr[0]);
	this.tipsSpr.x = Graphics.boxWidth/2;
	this.tipsSpr.y = Graphics.boxHeight/2-90;
	this.tipsSpr.setFontSize(46);
	this.tipsSpr.setTextColor('rgba(255,220,120,1)');
	this.tipsSpr.setBorderColor('rgba(180,120,120,1)');
	this.addChild(this.tipsSpr);
	//创建文本
	this.gameOverTSpr = new Sprite_ZzyGLLText(Zzy.GLL.TextArr[1]);
	this.gameOverTSpr.x = Graphics.boxWidth/2;
	this.gameOverTSpr.y = Graphics.boxHeight/2-15;
	this.gameOverTSpr.setFontSize(46);
	this.gameOverTSpr.setTextColor('rgba(255,220,120,1)');
	this.gameOverTSpr.setBorderColor('rgba(180,120,120,1)');
	this.addChild(this.gameOverTSpr);	
	//创建文本
	this.mokSpr = new Sprite_ZzyGLLText(Zzy.GLL.TextArr[2]);
	this.mokSpr.x = Graphics.boxWidth/2;
	this.mokSpr.y = Graphics.boxHeight/2+60;
	this.mokSpr.setFontSize(46);
	this.mokSpr.setTextColor('rgba(255,220,120,1)');
	this.mokSpr.setBorderColor('rgba(180,120,120,1)');
	this.addChild(this.mokSpr);
	
	this.winTextSpr = new Sprite_ZzyGLLText(Zzy.GLL.TextArr[3]);
	this.winTextSpr.x = Graphics.boxWidth/2;
	this.winTextSpr.y = Graphics.boxHeight/2-90;
	this.winTextSpr.setFontSize(46);
	this.winTextSpr.setTextColor('rgba(255,220,120,1)');
	this.winTextSpr.setBorderColor('rgba(180,120,120,1)');
	this.winTextSpr.setBorderWidth(4);
	this.addChild(this.winTextSpr);
	
	
	this.failTextSpr = new Sprite_ZzyGLLText(Zzy.GLL.TextArr[4]);
	this.failTextSpr.x = Graphics.boxWidth/2;
	this.failTextSpr.y = Graphics.boxHeight/2-90;
	this.failTextSpr.setFontSize(46);
	this.failTextSpr.setTextColor('rgba(255,220,120,1)');
	this.failTextSpr.setBorderColor('rgba(180,120,120,1)');
	this.failTextSpr.setBorderWidth(4);
	this.addChild(this.failTextSpr);	
	
	
	
	this.HideGameOverText();
	this.HideTipsExitText();
}


Window_ZzyGCFLinkLookUI.prototype.HideGameOverText = function()
{
	this.scoreTotalSpr.visible = false;
	this.timeTotalSpr.visible = false;
	this.winTextSpr.visible = false;
	this.failTextSpr.visible = false;
}



Window_ZzyGCFLinkLookUI.prototype.CallShowWinText = function()
{
	Zzy.GLL.WindowPointer.UI.scoreTotalSpr.visible = true;
	Zzy.GLL.WindowPointer.UI.timeTotalSpr.visible = true;
	Zzy.GLL.WindowPointer.UI.winTextSpr.visible = true;	
}

Window_ZzyGCFLinkLookUI.prototype.CallShowFailText = function()
{
	Zzy.GLL.WindowPointer.UI.scoreTotalSpr.visible = true;
	Zzy.GLL.WindowPointer.UI.timeTotalSpr.visible = true;
	Zzy.GLL.WindowPointer.UI.failTextSpr.visible = true;
}


Window_ZzyGCFLinkLookUI.prototype.ShowTipsExitText = function()
{
	this.tipsSpr.visible = true;
	this.gameOverTSpr.visible = true;
	this.mokSpr.visible = true;	
}

Window_ZzyGCFLinkLookUI.prototype.HideTipsExitText = function()
{
	this.tipsSpr.visible = false;
	this.gameOverTSpr.visible = false;
	this.mokSpr.visible = false;	
}


Window_ZzyGCFLinkLookUI.prototype.CallHideTipsExitText = function()
{
	Zzy.GLL.WindowPointer.UI.tipsSpr.visible = false;
	Zzy.GLL.WindowPointer.UI.gameOverTSpr.visible = false;
	Zzy.GLL.WindowPointer.UI.mokSpr.visible = false;	
}


Window_ZzyGCFLinkLookUI.prototype.CallShowTipsExitText = function()
{
	Zzy.GLL.WindowPointer.UI.tipsSpr.visible = true;
	Zzy.GLL.WindowPointer.UI.gameOverTSpr.visible = true;
	Zzy.GLL.WindowPointer.UI.mokSpr.visible = true;	
}




Window_ZzyGCFLinkLookUI.prototype.CreateAllButton = function()//创造按钮
{
	var ex = eval(Zzy.Param.GLLExitButtonX);
	var ey = eval(Zzy.Param.GLLExitButtonY);

	this.ExitButtonSpr = new Sprite_ZzyGLLButton(ex,ey,Zzy.Param.GLLExitButtonPic,0,1);//1代表退出
	this.OkButtonSpr = new Sprite_ZzyGLLButton(this.centerX-60,this.centerY,Zzy.Param.GLLOkButtonPic,0,2);//2代表确认
	this.CancelButtonSpr = new Sprite_ZzyGLLButton(this.centerX+60,this.centerY,Zzy.Param.GLLCancelButtonPic,0,3);//3代表取消
	
	
	this.addChild(this.ExitButtonSpr);
	this.addChild(this.OkButtonSpr);
	this.addChild(this.CancelButtonSpr);
}




Window_ZzyGCFLinkLookUI.prototype.CreatePauseSpr = function()//创建暂停
{
	if(!Zzy.Param.GLLPausePic)
	{
		this.PauseSpr = new Sprite_ZzyGLLPause(this.centerX,this.centerY);//创造默认暂停
	}
	else
	{
		this.PauseSpr = new Sprite_ZzyGLLPause(this.centerX,this.centerY,Zzy.Param.GLLPausePic);		
	}

	
	this.addChild(this.PauseSpr);
}






Window_ZzyGCFLinkLookUI.prototype.OpenResultInterface = function()//召唤结算界面
{
	switch(this.gameGlobal.result)
	{
		case 'win':

			this.OpenWinInterface();//游戏胜利
		break;
			
		case 'fail':

			this.OpenFailInterface();//游戏失败
		break;
		default:

			this.OpenWinInterface();//游戏胜利
	}

	
}



Window_ZzyGCFLinkLookUI.prototype.OpenWinInterface = function()//胜利界面
{

}



Window_ZzyGCFLinkLookUI.prototype.OpenFailInterface = function()//失败界面
{

}


Window_ZzyGCFLinkLookUI.prototype.setPause = function(isPause)//执行暂停
{
	if(isPause)
	{
		this.PauseSpr.visible = true;
	}
	else
	{
		this.PauseSpr.visible = false;
	}
	
}



//----------------------------------Zzy.GLL.Function--------------------------------

Zzy.GLL.PlaySE = function(soundID)//播放声音
{
	var se = Zzy.Param.GLLAllSE[soundID];
	
	if(se && se.name)
	{
		AudioManager.playSe(se);
	}
	
}


//----------------------------------Zzy.GLL.Function--------------------------------


Zzy.GLL.MaxLevel = function(formula)
{
	$gameSystem.SetZzyGLLMaxLevelFormula(formula);
}

Zzy.GLL.Time = function(formula)
{
	$gameSystem.SetZzyGLLCpTimeFormula(formula);
}

Zzy.GLL.Line = function(formula)
{
	$gameSystem.SetZzyGLLCpLineFormula(formula);
}

Zzy.GLL.List = function(formula)
{
	$gameSystem.SetZzyGLLCpListFormula(formula);
}

Zzy.GLL.Size = function(formula)
{
	$gameSystem.SetZzyGLLCpSizeFormula(formula);
}

Zzy.GLL.Type = function(formula)
{
	$gameSystem.SetZzyGLLCpTypeFormula(formula);
}

Zzy.GLL.ConnectSocre = function(formula)
{
	$gameSystem.SetZzyGLLConnectSocreFormula(formula);
}

Zzy.GLL.SurplusScore = function(formula)
{
	$gameSystem.SetZzyGLLSurplusTimeSocreFormula(formula);
}

Zzy.GLL.StartLevel = function(value)
{
	$gameSystem.SetZzyGLLStartLevel(value);
}

