/**
 * Copyright (c) 2014,www.easygame.org
 * All rights reserved.
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 *     * Redistributions of source code must retain the above copyright
 *       notice, this list of conditions and the following disclaimer.
 *     * Redistributions in binary form must reproduce the above copyright
 *       notice, this list of conditions and the following disclaimer in the
 *       documentation and/or other materials provided with the distribution.
 *     * Neither the name of the easygame.org nor the
 *       names of its contributors may be used to endorse or promote products
 *       derived from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY EASYEGRET.COM AND CONTRIBUTORS "AS IS" AND ANY
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL EGRET-LABS.ORG AND CONTRIBUTORS BE LIABLE FOR ANY
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
module modules{

    /**
     * <p></p>
     * @date  :2020-03-27 13:34:21
     * @EasyGame.org Tools
     */ 
    export class index7  extends easy.Group{
        public resourceRoot:string = "";
        public resSpriteSheet:string = "index7";//合并材质资源名称
        public resTexture:Array<string> = ["7","page02-12"];//单材质资源名称
        public resGroup:Array<string> = ["courseware_index7"];//配置文件的Group
        public resFiles:Array<string> = ["courseware/index7_loader_200327133421.json"];//需要下载的资源group
        public spriteSheet:egret.SpriteSheet = null;//ui对应的材质集,已经分割好,方便外部读取方便

        public group:easy.Group = null;
        public imgas:easy.Image = null;
        public groupAll:easy.Group = null;
        public img1:easy.Image = null;
        public imgWord1:easy.Image = null;
        public imgWord2:easy.Image = null;
        public img2:easy.Image = null;
        public img3:easy.Image = null;
        public imgScale:easy.Image = null;
        public imgKua:easy.Image = null;
        public imgMove1:easy.Image = null;
        public imgMove2:easy.Image = null;
        public imgMove3:easy.Image = null;
        public imgMove4:easy.Image = null;
        public btnAgain:easy.Button = null;
        public btnPage:easy.Button = null;
        public temp:tempTemplate = null;

        public constructor() {
            super(true);
        }
        /**
         * 初始化主场景的组件,加入场景时,主动调用一次
         * 子类覆写该方法,添加UI逻辑
         */  
        public createChildren():void {
            super.createChildren();
            this.showBg = false;
            this.border = false;
            this.width = 640;
            this.height = 960;
            //group 
            this.group = new easy.Group(true);
            this.group.name = "group";
            this.addChild(this.group);
            this.group.bgColor = 0xffffff;
            this.group.border = false;
            this.group.width = 640;
            this.group.height = 960;
            //imgas 
            this.imgas = new easy.Image(true);
            this.imgas.name = "imgas";
            this.addChild(this.imgas);
            this.imgas.y = 26.5;
            this.imgas.width = 603;
            this.imgas.height = 907;
            this.imgas.leftEnabled = true;
            this.imgas.visible = false;
            //groupAll 
            this.groupAll = new easy.Group(true);
            this.groupAll.name = "groupAll";
            this.addChild(this.groupAll);
            this.groupAll.showBg = false;
            this.groupAll.border = false;
            this.groupAll.width = 640;
            this.groupAll.height = 960;
            this.groupAll.verticalEnabled = true;
            //img1 
            this.img1 = new easy.Image(true);
            this.img1.name = "img1";
            this.groupAll.addChild(this.img1);
            this.img1.y = 26;
            this.img1.width = 102;
            this.img1.height = 51;
            //imgWord1 
            this.imgWord1 = new easy.Image(true);
            this.imgWord1.name = "imgWord1";
            this.groupAll.addChild(this.imgWord1);
            this.imgWord1.x = 113;
            this.imgWord1.y = 37;
            this.imgWord1.width = 490;
            this.imgWord1.height = 40;
            //imgWord2 
            this.imgWord2 = new easy.Image(true);
            this.imgWord2.name = "imgWord2";
            this.groupAll.addChild(this.imgWord2);
            this.imgWord2.x = 237;
            this.imgWord2.y = 113;
            this.imgWord2.width = 168;
            this.imgWord2.height = 27;
            //img2 
            this.img2 = new easy.Image(true);
            this.img2.name = "img2";
            this.groupAll.addChild(this.img2);
            this.img2.y = 165;
            this.img2.width = 21;
            this.img2.height = 155;
            //img3 
            this.img3 = new easy.Image(true);
            this.img3.name = "img3";
            this.groupAll.addChild(this.img3);
            this.img3.y = 320;
            this.img3.width = 21;
            this.img3.height = 487;
            //imgScale 
            this.imgScale = new easy.Image(true);
            this.imgScale.name = "imgScale";
            this.groupAll.addChild(this.imgScale);
            this.imgScale.x = 112;
            this.imgScale.y = 167;
            this.imgScale.width = 486;
            this.imgScale.height = 235;
            //imgKua 
            this.imgKua = new easy.Image(true);
            this.imgKua.name = "imgKua";
            this.groupAll.addChild(this.imgKua);
            this.imgKua.x = 110;
            this.imgKua.y = 427;
            this.imgKua.width = 489;
            this.imgKua.height = 408;
            //imgMove1 
            this.imgMove1 = new easy.Image(true);
            this.imgMove1.name = "imgMove1";
            this.groupAll.addChild(this.imgMove1);
            this.imgMove1.x = 127;
            this.imgMove1.y = 434;
            this.imgMove1.width = 458;
            this.imgMove1.height = 65;
            //imgMove2 
            this.imgMove2 = new easy.Image(true);
            this.imgMove2.name = "imgMove2";
            this.groupAll.addChild(this.imgMove2);
            this.imgMove2.x = 127;
            this.imgMove2.y = 522;
            this.imgMove2.width = 458;
            this.imgMove2.height = 65;
            //imgMove3 
            this.imgMove3 = new easy.Image(true);
            this.imgMove3.name = "imgMove3";
            this.groupAll.addChild(this.imgMove3);
            this.imgMove3.x = 127;
            this.imgMove3.y = 610;
            this.imgMove3.width = 457;
            this.imgMove3.height = 65;
            //imgMove4 
            this.imgMove4 = new easy.Image(true);
            this.imgMove4.name = "imgMove4";
            this.groupAll.addChild(this.imgMove4);
            this.imgMove4.x = 127;
            this.imgMove4.y = 698;
            this.imgMove4.width = 441;
            this.imgMove4.height = 65;
            //btnAgain 
            this.btnAgain = new easy.Button(true);
            this.btnAgain.name = "btnAgain";
            this.groupAll.addChild(this.btnAgain);
            this.btnAgain.width = 133;
            this.btnAgain.height = 47;
            this.btnAgain.x = 467;
            this.btnAgain.y = 887;
            //btnPage 
            this.btnPage = new easy.Button(true);
            this.btnPage.name = "btnPage";
            this.groupAll.addChild(this.btnPage);
            this.btnPage.width = 133;
            this.btnPage.height = 47;
            this.btnPage.x = 27;
            this.btnPage.y = 887;
            //temp 
            this.temp = new modules.tempTemplate();
            this.temp.name = "temp";
            this.addChild(this.temp);
            if (this.temp.ui["resFiles"]) this.resFiles = this.resFiles.concat(this.temp.ui.resFiles);
            if (this.temp.ui["resGroup"]) this.resGroup = this.resGroup.concat(this.temp.ui.resGroup);
            this.temp.x = 540;
            this.temp.rightEnabled = true;
            this.temp.ui.rightEnabled = true;

        }
        /**
         * 获取初始化逻辑,加入场景时,主动调用一次
         * 子类覆写该方法,添加业务逻辑
         */
         public initData():void {
           super.initData();
        }
        /**
         * 进入的逻辑
         * 可以再次根据外部数据情况做一些逻辑处理
         */
        public enter():void {

        }

        /**
         * 退出的逻辑
         * 做一些数据的销毁或者初始化,保证下次进入的时候,不会残留
         */
        public outer():void {

        }
        /**
         * 刷新UI皮肤显示
         */
        public validateNow():void{
            this.drawDelay = false;
            var jsonData:any = RES.getRes("index7_json");
            if (jsonData != null) {
                this.spriteSheet = new egret.SpriteSheet(RES.getRes("index7_img"));
                for (var key in jsonData.texture){
                    this.spriteSheet.createTexture(key, jsonData.texture[key].x, jsonData.texture[key].y, jsonData.texture[key].w, jsonData.texture[key].h);
                }
            }
            this.group.drawDelay = false;
            this.imgas.texture = RES.getRes("7");
            this.imgas.drawDelay = false;
            this.groupAll.drawDelay = false;
            if (this.spriteSheet) this.img1.texture = this.spriteSheet.getTexture("page02-01");
            this.img1.drawDelay = false;
            if (this.spriteSheet) this.imgWord1.texture = this.spriteSheet.getTexture("page07-01");
            this.imgWord1.drawDelay = false;
            if (this.spriteSheet) this.imgWord2.texture = this.spriteSheet.getTexture("page07-02");
            this.imgWord2.drawDelay = false;
            if (this.spriteSheet) this.img2.texture = this.spriteSheet.getTexture("page_2_4");
            this.img2.drawDelay = false;
            if (this.spriteSheet) this.img3.texture = this.spriteSheet.getTexture("page_2_5");
            this.img3.drawDelay = false;
            if (this.spriteSheet) this.imgScale.texture = this.spriteSheet.getTexture("page07-03");
            this.imgScale.drawDelay = false;
            if (this.spriteSheet) this.imgKua.texture = this.spriteSheet.getTexture("page02-07");
            this.imgKua.drawDelay = false;
            if (this.spriteSheet) this.imgMove1.texture = this.spriteSheet.getTexture("page07-05");
            this.imgMove1.drawDelay = false;
            if (this.spriteSheet) this.imgMove2.texture = this.spriteSheet.getTexture("page07-06");
            this.imgMove2.drawDelay = false;
            if (this.spriteSheet) this.imgMove3.texture = this.spriteSheet.getTexture("page07-07");
            this.imgMove3.drawDelay = false;
            if (this.spriteSheet) this.imgMove4.texture = this.spriteSheet.getTexture("page07-08");
            this.imgMove4.drawDelay = false;
            this.btnAgain.texture = RES.getRes("page02-12");
            this.btnAgain.drawDelay = false;
            if (this.spriteSheet) this.btnPage.texture = this.spriteSheet.getTexture("page02-11");
            this.btnPage.drawDelay = false;
            //模板temp
            this.temp.validateNow();

        }
    }
}