"use strict";
var __reflect = (this && this.__reflect) || function (p, c, t) {
    p.__class__ = c, t ? t.push(c) : t = [c], p.__types__ = p.__types__ ? t.concat(p.__types__) : t;
};
var __extends = this && this.__extends || function __extends(t, e) { 
 function r() { 
 this.constructor = t;
}
for (var i in e) e.hasOwnProperty(i) && (t[i] = e[i]);
r.prototype = e.prototype, t.prototype = new r();
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __generator = (this && this.__generator) || function (thisArg, body) {
    var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
    return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
    function verb(n) { return function (v) { return step([n, v]); }; }
    function step(op) {
        if (f) throw new TypeError("Generator is already executing.");
        while (_) try {
            if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t;
            if (y = 0, t) op = [0, t.value];
            switch (op[0]) {
                case 0: case 1: t = op; break;
                case 4: _.label++; return { value: op[1], done: false };
                case 5: _.label++; y = op[1]; op = [0]; continue;
                case 7: op = _.ops.pop(); _.trys.pop(); continue;
                default:
                    if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
                    if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
                    if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
                    if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
                    if (t[2]) _.ops.pop();
                    _.trys.pop(); continue;
            }
            op = body.call(thisArg, _);
        } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
        if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
    }
};
Object.defineProperty(exports, "__esModule", { value: true });
var DataManager_1 = require("./../../libs/tw/manager/DataManager");
var sceneTypes_1 = require("./../types/sceneTypes");
var Scene_1 = require("../views/Scene");
var panelCtrl_1 = require("../ctrls/panelCtrl");
var sceneCtrl_1 = require("../ctrls/sceneCtrl");
var NetManager_1 = require("../../libs/tw/manager/NetManager");
var StartScene1 = (function (_super) {
    __extends(StartScene1, _super);
    function StartScene1(data) {
        var _this = _super.call(this, data) || this;
        _this.isHarvestListGroupShow = false;
        return _this;
    }
    Object.defineProperty(StartScene1.prototype, "skinKey", {
        get: function () { return 'StartScene'; },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(StartScene1.prototype, "groupName", {
        get: function () { return 'start_scene'; },
        enumerable: true,
        configurable: true
    });
    StartScene1.prototype.initEvents = function () {
        _super.prototype.initEvents.call(this);
        // this.ruleBtn.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onTap_ruleBtn, this);
        this.harvestBtn.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onTap_harvestBtn, this);
        // this.prizeBtn.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onTap_prizeBtn, this);
        // this.musicBtn.addEventListener(egret.TouchEvent.TOUCH_BEGIN, this.onTap_musicBtn, this);
    };
    StartScene1.prototype.removeEvents = function () {
        _super.prototype.removeEvents.call(this);
        // this.ruleBtn.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onTap_ruleBtn, this);
        this.harvestBtn.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onTap_harvestBtn, this);
        // this.prizeBtn.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onTap_prizeBtn, this);
        // this.musicBtn.removeEventListener(egret.TouchEvent.TOUCH_BEGIN, this.onTap_musicBtn, this);
    };
    StartScene1.prototype.onTap_harvestBtn = function () {
        this.isHarvestListGroupShow = !this.isHarvestListGroupShow;
        this.harvestUp.visible = false;
        this.harvestDwon.visible = false;
        if (this.isHarvestListGroupShow) {
            this.harvestUp.visible = true;
            this["listShow"].play(0);
        }
        else {
            this.harvestDwon.visible = true;
            this["listHide"].play(0);
        }
    };
    StartScene1.prototype.start = function (data) {
        _super.prototype.start.call(this, data);
        this.percentHeight = 100;
    };
    StartScene1.prototype.preLoadRes = function () {
        return __awaiter(this, void 0, void 0, function () {
            var _a;
            return __generator(this, function (_b) {
                switch (_b.label) {
                    case 0:
                        //加载背景并设置背景图片
                        _a = this;
                        return [4 /*yield*/, RES.getResAsync('startBg_jpg')];
                    case 1:
                        //加载背景并设置背景图片
                        _a.bgtexture = _b.sent();
                        //   await this.sleep(10000)
                        // console.log('载背景并设置背景图片mainscene');
                        return [2 /*return*/, new Promise(function (resolve, reject) {
                                resolve();
                            })];
                }
            });
        });
    };
    StartScene1.prototype.onSkinComplete = function () {
        _super.prototype.onSkinComplete.call(this);
        this.mainbg.texture = this.bgtexture;
        this.isHarvestListGroupShow = false;
        this.harvestUp.visible = false;
        this.harvestListGroup.mask = this.harvestListMask;
        this.once(egret.Event.ADDED_TO_STAGE, this.onLoad, this);
        if (this.stage) {
            this.onLoad();
        }
        console.log("test");
        this.initPetClip();
    };
    StartScene1.prototype.initPetClip = function () {
        var _this = this;
        var parser = new window["SVGA"].Parser();
        parser.load("/petAn/pet_lv_0/auto.svga", function (videoItem) {
            var mv = new window["SVGA"].EgretMovieClip(videoItem);
            // mv.lockStep=true;
            mv.gotoAndPlay(1, true);
            // mv.play()
            // mv.gotoAndPlay(30, true)
            // mv.gotoAndStop(10)
            _this.petGroup_lv_0.addChild(mv);
            var fun;
            mv.addEventListener(egret.Event.COMPLETE, fun = function () {
                console.log("播放完成");
                mv.removeEventListener(egret.Event.COMPLETE, fun, this);
                //mv.stop()
                // mv.startAniRange(30,60);
            }, _this);
        }, function (error) {
            alert(error.message);
        });
    };
    StartScene1.prototype.sleep = function (time) {
        return __awaiter(this, void 0, void 0, function () {
            return __generator(this, function (_a) {
                return [2 /*return*/, new Promise(function (resolev) {
                        setTimeout(resolev, time);
                    })];
            });
        });
    };
    StartScene1.prototype.onLoad = function () {
        this.initUI();
    };
    StartScene1.prototype.initUI = function () {
        // egret.Tween.get(this.startBtn, {loop:true})
        //     .to({scaleX:1.05, scaleY:1.05}, 150)
        //     .to({scaleX:0.9, scaleY:0.9}, 150)
        //     .to({scaleX:1.05, scaleY:1.05}, 150)
        //     .to({scaleX:0.9, scaleY:0.9}, 150).wait(500);
    };
    StartScene1.prototype.onTap_ruleBtn = function () {
        console.log('点击rule');
        // PanelCtrl.instance.btnDelay(this.ruleBtn);
        panelCtrl_1.default.instance.show(sceneTypes_1.ModuleTypes.RULE_PANEL);
    };
    StartScene1.prototype.onTap_startBtn = function () {
        var _this = this;
        // PanelCtrl.instance.btnDelay(this.startBtn);
        NetManager_1.NetManager.ins.getHome(function (succuss) {
            if (!succuss) {
                return;
            }
            _this.showMainScene();
        }, this.getQueryString("dailyMark"), window["CFG"].activityId);
    };
    StartScene1.prototype.showMainScene = function () {
        return __awaiter(this, void 0, void 0, function () {
            return __generator(this, function (_a) {
                switch (_a.label) {
                    case 0: return [4 /*yield*/, RES.loadGroup('msg_panel')];
                    case 1:
                        _a.sent();
                        return [4 /*yield*/, RES.getResAsync('msgBg0_png')];
                    case 2:
                        _a.sent();
                        return [4 /*yield*/, RES.getResAsync('msgBg1_png')];
                    case 3:
                        _a.sent();
                        return [4 /*yield*/, RES.getResAsync('msgBg2_png')];
                    case 4:
                        _a.sent();
                        return [4 /*yield*/, RES.getResAsync('msgBg3_png')];
                    case 5:
                        _a.sent();
                        sceneCtrl_1.default.instance.change(sceneTypes_1.ModuleTypes.MAIN_SCENE);
                        return [2 /*return*/];
                }
            });
        });
    };
    StartScene1.prototype.getQueryString = function (name) {
        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
        var r = window.location.search.substr(1).match(reg);
        if (r != null)
            return unescape(r[2]);
        return null;
    };
    ;
    StartScene1.prototype.onTap_prizeBtn = function () {
        console.log('点击prizeBtn');
        // PanelCtrl.instance.btnDelay(this.prizeBtn);
        window.location.href = this.gotoRecord(); //window["recordUrl"];
    };
    //获取我的奖品
    StartScene1.prototype.gotoRecord = function () {
        var recordUrl;
        var oaId;
        if (DataManager_1.DataManager.ins.customCfgData) {
            oaId = DataManager_1.DataManager.ins.customCfgData.oaId;
            recordUrl = DataManager_1.DataManager.ins.customCfgData.recordUrl;
        }
        else {
            oaId = DataManager_1.DataManager.ins.gameCfgData.gameInfo.oaId;
            recordUrl = window['recordUrl'];
        }
        if (recordUrl.indexOf('?') != -1) {
            recordUrl += '&origins=' + oaId + '00';
        }
        else {
            recordUrl += '?origins=' + oaId + '00';
        }
        // recordUrl += ',' + (window['plugId'] ? window['plugId'] : 4500) + '01';
        // for(let i = 0; i < window['plugIdArr'].length; i++){
        //     recordUrl += ',' + window['plugIdArr'][i] + '01';
        // }
        return recordUrl;
    };
    //循环播放动画
    StartScene1.prototype.playAnimation = function (target, isLoop) {
        if (isLoop === void 0) { isLoop = true; }
        if (isLoop) {
            for (var key in target.items) {
                target.items[key].props = { loop: true };
            }
        }
        target.play();
    };
    // 用于控制全局音乐是否播放和音乐按钮状态
    StartScene1.isPlayMusic = true;
    return StartScene1;
}(Scene_1.default));
exports.default = StartScene1;
__reflect(StartScene1.prototype, "\"c:/Users/duiba/Documents/kuwo/egret/src/startScene/StartScene\".StartScene1");
//# sourceMappingURL=StartScene.js.map