"use strict";
cc._RF.push(module, 'ca4e5oV1txBO67LkG7QvTYD', '2');
// demo/JuanZhou/2.js

"use strict";

cc.Class({
    extends: cc.Component,

    properties: {
        hahahaha: cc.Node,
        UI: cc.Node
    },

    onLoad: function onLoad() {
        this.reels = require("data_2").reel;
        this._reelSwitch = 1;
        for (var i in this.UI.children) {
            this.UI.children[i].on(cc.Node.EventType.TOUCH_START, function (event) {
                this.time = new Date().getTime();
                cc.log(this.time);
                this.schedule(this.touchend, 0.2);
            }, this);
        }
        for (var _i in this.UI.children) {
            this.UI.children[_i].on(cc.Node.EventType.TOUCH_END, function (event) {
                this.time1 = new Date().getTime();
                this.unschedule(this.touchend);
            }, this);
        }
    },

    touchend: function touchend(event, num) {
        var time2 = new Date().getTime();
        if (num != null) this._number = num;
        if (time2 - this.time >= 1500 && Math.ceil(event) == 1) {
            cc.log(this._number);
            cc.log(111111111);
            this.unschedule(this.touchend);
        }
        if (this.time1 - this.time < 1500 && this.time1 != 0) {
            cc.log(this._number);
            cc.log(222222222);
            this.unschedule(this.touchend);
        }
        this.time1 = 0;
    },

    go: function go() {
        if (this.node.active) this.node.active = false;else {
            this.node.active = true;
            this.test();
        }
    },

    reelSwitch: function reelSwitch() {
        if (this._reelSwitch) this._reelSwitch = 0;else this._reelSwitch = 1;
        this.test();
    },

    ada: function ada(event, num) {
        cc.log(num);
    },

    test: function test(event, num) {
        if (num == null) num = 1;
        var arr = [1, 2, 3, 4, 5];
        var arr2 = ["S", "H", "T", "G", "A"];
        var arr3 = ["水系魔法", "火系魔法", "土系魔法", "光系魔法", "暗系魔法"];
        var arr4 = ["一阶魔法", "二阶魔法", "三阶魔法", "四阶魔法", "五阶魔法"];
        for (var k = 0; k < 5; k++) {
            this.node.children[7].children[k].active = false;
        }
        for (var i in arr) {
            i = parseInt(i);
            if (num - 1 == i) {
                var lastReels = new Array(),
                    lastRank = new Array(),
                    attribute = new Array();
                for (var l = 0, j = 0; j < 5; j++) {
                    if (this._reelSwitch) {
                        if (this.reels[i][j] == 0) continue;
                        lastReels[l] = this.reels[i][j];
                        attribute[l] = arr2[i];
                        lastRank[l] = j + 1;
                        this.node.children[6].getComponent(cc.Label).string = arr3[i];
                    } else {
                        if (this.reels[j][i] == 0) continue;
                        lastReels[l] = this.reels[j][i];
                        attribute[l] = arr2[j];
                        lastRank[l] = num;
                        this.node.children[6].getComponent(cc.Label).string = arr4[i];
                    }
                    l++;
                }
            }
        }
        for (var m in lastReels) {
            cc.log(lastReels);
            m = parseInt(m);
            var son = this.node.children[7].children[m];
            var Sp = son.getComponent(cc.Sprite);
            Sp.spriteFrame = new cc.SpriteFrame(cc.url.raw("resources/" + attribute[m] + lastRank[m] + ".png"));
            son.children[0].getComponent(cc.Label).string = 5 + lastRank[m] * 2 + "";
            son.children[1].getComponent(cc.Label).string = lastReels[m] + "";
            this.node.children[7].children[m].active = true;
        }
    }
});

cc._RF.pop();