var k = new Array();
var l = new Array();
var m = new Array();
var zhiyeCurosr = 0;

function zyinit() {
    zyinitName();
    zyinitRectChoose();
    zyinitRectChoosePic();
    zyinitZhiyeIntro();
    zySetVisible(0);
    
    Laya.stage.on(laya.events.Event.KEY_DOWN,this,zyOnKeyDown);
}
function zyinitName() {
    var c1 = new laya.display.Text();
    c1.text = "战士";
    c1.x = 50;
    c1.y = 50;
    c1.color = "red";
    c1.fontSize = 20;
    Laya.stage.addChild(c1);

    var c2 = new laya.display.Text();
    c2.text = "盗墓者";
    c2.x = 50;
    c2.y = 50 + 30 * 1;
    c2.color = "red";
    c2.fontSize = 20;
    Laya.stage.addChild(c2);

    var c3 = new laya.display.Text();
    c3.text = "魔法师";
    c3.x = 50;
    c3.y = 50 + 30 * 2;
    c3.color = "red";
    c3.fontSize = 20;
    Laya.stage.addChild(c3);

    var c4 = new laya.display.Text();
    c4.text = "农名";
    c4.x = 50;
    c4.y = 50 + 30 * 3;
    c4.color = "red";
    c4.fontSize = 20;
    Laya.stage.addChild(c4);

    var c5 = new laya.display.Text();
    c5.text = "猎人";
    c5.x = 50;
    c5.y = 50 + 30 * 4;
    c5.color = "red";
    c5.fontSize = 20;
    Laya.stage.addChild(c5);

    var c6 = new laya.display.Text();
    c6.text = "魔法战士";
    c6.x = 50;
    c6.y = 50 + 30 * 5;
    c6.color = "red";
    c6.fontSize = 20;
    Laya.stage.addChild(c6); 

    var c7 = new laya.display.Text();
    c7.text = "观光客";
    c7.x = 50;
    c7.y = 50 + 30 * 6;
    c7.color = "red";
    c7.fontSize = 20;
    Laya.stage.addChild(c7); 

    var c8 = new laya.display.Text();
    c8.text = "钢琴师";
    c8.x = 50;
    c8.y = 50 + 30 * 7;
    c8.color = "red";
    c8.fontSize = 20;
    Laya.stage.addChild(c8);    

    var c9 = new laya.display.Text();
    c9.text = "神官";
    c9.x = 50;
    c9.y = 50 + 30 * 8;
    c9.color = "red";
    c9.fontSize = 20;
    Laya.stage.addChild(c9); 

    var c10 = new laya.display.Text();
    c10.text = "大剑";
    c10.x = 50;
    c10.y = 50 + 30 * 9;
    c10.color = "red";
    c10.fontSize = 20;
    Laya.stage.addChild(c10); 
}
function zyinitRectChoose() {
    for(var i = 0; i < 10; i++){
        k[i] = new laya.display.Sprite();
        if (i == 5) {
            k[i].graphics.drawRect(50, 50 + 30 * i, 4 * 20 + 5 + 10, 20, "white");
        }
        if (i == 0 || i ==  3 || i== 4 || i == 8 || i == 9) {
            k[i].graphics.drawRect(50, 50 + 30 * i, 2 * 20 + 5 + 10, 20, "white");
        }
        if (i == 1 || i == 2 || i == 6 || i == 7) {
            k[i].graphics.drawRect(50, 50 + 30 * i, 3 * 20 + 5 + 10, 20, "white");
        }
        k[i].alpha = 0.25;
        k[i].visible = true;
        Laya.stage.addChild(k[i]);
    }       
}
function zyinitRectChoosePic() {
    for(var i = 0; i < 10; i++){
        l[i] = new laya.display.Sprite();
        if (i == 5) {
            l[i].loadImage("rectChoosePic.png",50 + 4 * 20 + 5 ,50 + 30 * i + 5, 10 ,10);
        }
        if (i == 0 || i ==  3 || i== 4 || i == 8 || i == 9) {
            l[i].loadImage("rectChoosePic.png",50 + 2 * 20 + 5 ,50 + 30 * i + 5, 10 ,10);
        }
        if (i == 1 || i == 2 || i == 6 || i == 7) {
            l[i].loadImage("rectChoosePic.png",50 + 3 * 20 + 5 ,50 + 30 * i + 5, 10 ,10);
        }
        l[i].visible = true;
        Laya.stage.addChild(l[i]);
    }     
}
function zySetVisible(index) {
    for(var i = 0; i < 10 ; i++){
        if (index == i) {
            k[i].visible = true;
            l[i].visible = true;
            m[i].visible = true;
        }else{
            k[i].visible = false;
            l[i].visible = false;
            m[i].visible = false;
        }
    }     
}
function zyOnKeyDown(e) {
    switch(e.keyCode){
        case 38:{
            if ( (zhiyeCurosr - 1) <= 0 ) {
                zhiyeCurosr = 0;
            }else{
                zhiyeCurosr--;
            }
            break;
        }
        case 40:{
            if ( (zhiyeCurosr + 1) >= 9 ) {
                zhiyeCurosr = 9;
            }else{
                zhiyeCurosr++;
            }
            break;
        }
    }
    zySetVisible(zhiyeCurosr);
}
function zyinitZhiyeIntro() {
    m[0] = new laya.display.Text();
    m[0].text = "战士一自己的肉体为武器,夷平阻挡他们前进的任何障碍。战士并不适"+
                "合使用魔法,但他们仅凭高超的战斗能力就足以让人瞪目结舌。";
    m[0].x = 200;
    m[0].y = 50;
    m[0].color = "red";
    m[0].fontSize = 20;
    m[0].wordWrap = true;
    m[0].width = 640;
    Laya.stage.addChild(m[0]);

    m[1] = new laya.display.Text();
    m[1].text = "盗墓者主要靠偷取古墓和遗迹中的贵重品为生。他们战斗能力不过尔尔"+
                "但很善于和商人们讨价还价。";
    m[1].x = 200;
    m[1].y = 50;
    m[1].color = "red";
    m[1].fontSize = 20;
    m[1].wordWrap = true;
    m[1].width = 640;
    Laya.stage.addChild(m[1]);

    m[2] = new laya.display.Text();
    m[2].text =     "正如其名,魔法师是擅长使用魔法知识的职业。魔法师的生死全要取决"+
                    "于魔法师的获取和管理上。";
    m[2].x = 200;
    m[2].y = 50;
    m[2].color = "red";
    m[2].fontSize = 20;
    m[2].wordWrap = true;
    m[2].width = 640;
    Laya.stage.addChild(m[2]);

    m[3] = new laya.display.Text();
    m[3].text = "农民是善于生产的职业。他们吃苦耐劳,有一定强度的身体素质。";
    m[3].x = 200;
    m[3].y = 50;
    m[3].color = "red";
    m[3].fontSize = 20;
    m[3].wordWrap = true;
    m[3].width = 640;
    Laya.stage.addChild(m[3]);

    m[4] = new laya.display.Text();
    m[4].text = "猎人是远程攻击的专家。他们的近战能力也颇为可观,但大部分敌人都"+
                "会在接近他们之前就被打倒";
    m[4].x = 200;
    m[4].y = 50;
    m[4].color = "red";
    m[4].fontSize = 20;
    m[4].wordWrap = true;
    m[4].width = 640;
    Laya.stage.addChild(m[4]);

    m[5] = new laya.display.Text();
    m[5].text = "魔法战士同时拥有战士与魔法师的特征。在战斗上更为倾向于肉搏。为"+
                "了能更好的掌握魔法,魔法战士需要精准的成长计划";
    m[5].x = 200;
    m[5].y = 50;
    m[5].color = "red";
    m[5].fontSize = 20;
    m[5].wordWrap = true;
    m[5].width = 640;
    Laya.stage.addChild(m[5]); 

    m[6] = new laya.display.Text();
    m[6].text = "观光客是这个世界上最传统的职业,和预想一样的软弱。";


    m[6].x = 200;
    m[6].y = 50;
    m[6].color = "red";
    m[6].fontSize = 20;
    m[6].wordWrap = true;
    m[6].width = 640;
    Laya.stage.addChild(m[6]); 

    m[7] = new laya.display.Text();
    m[7].text = "钢琴师是以演奏为生的孤高的职业。他们不管走到那里都把钢琴背在身"+
                "后,因此拥有负重能力";
    m[7].x = 200;
    m[7].y = 50;
    m[7].color = "red";
    m[7].fontSize = 20;
    m[7].wordWrap = true;
    m[7].width = 640;
    Laya.stage.addChild(m[7]);    

    m[8] = new laya.display.Text();
    m[8].text = "神官拥有优秀的魔法能力和一定的近战能力。他们能从他们所信仰的神"+
                "灵身上获得最大限度地恩惠。";
    m[8].x = 200;
    m[8].y = 50;
    m[8].color = "red";
    m[8].fontSize = 20;
    m[8].wordWrap = true;
    m[8].width = 640;
    Laya.stage.addChild(m[8]); 

    m[9] = new laya.display.Text();
    m[9].text = "大剑是流着半人半妖之血的敏捷的剑士。人们都敬畏的称他们为银眼斩"+
                "杀者,他们人人都能将一把几乎和身高一样长的大剑使得出神入化。虽"+
                "然他们体质偏低,但轻盈的身体与敏锐的眼力能令他们能轻易的躲过敌"+
                "人的攻击。";
    m[9].x = 200;
    m[9].y = 50;
    m[9].color = "red";
    m[9].fontSize = 20;
    m[9].wordWrap = true;
    m[9].width = 640;
    Laya.stage.addChild(m[9]); 
}