import { NetManager } from './../../libs/tw/manager/NetManager';
import { DataManager } from './../../libs/tw/manager/DataManager';
import GameEndScene from './GameEndScene';
import GameConst from '../GameConst';
import PanelCtrl from '../ctrls/panelCtrl';
import { ModuleTypes } from '../types/sceneTypes';
export default class ExGameEndScene extends GameEndScene {

    constructor() {
        super()
    }

    public bg: eui.Image;
    public gameInfoBg: eui.Image;
    public dogAllScoreBg: eui.Image;
    public catAllScoreBg: eui.Image;
    public vsCircle: eui.Image;
    public vsCenter: eui.Image;
    public dogScoreTxt: eui.Label;
    public catScoreTxt: eui.Label;
    public infoTips: eui.Label;
    public lotteryBtn: eui.Button;



    initUI() {

    }

    start() {
        let camp = DataManager.ins.getData('getValentineInfo').data.camp;

        let dogData = { score: 0 };
        let catData = { score: 0 };
        let targetDogScore = DataManager.ins.getData('getValentineInfo') && DataManager.ins.getData('getValentineInfo').data && DataManager.ins.getData('getValentineInfo').data.dogScore ? Number(DataManager.ins.getData('getValentineInfo').data.dogScore) : 0;
        let targetCatScore = DataManager.ins.getData('getValentineInfo') && DataManager.ins.getData('getValentineInfo').data && DataManager.ins.getData('getValentineInfo').data.catScore ? Number(DataManager.ins.getData('getValentineInfo').data.catScore) : 0;

        let dogScoreTW = egret.Tween.get(dogData, {
            onChange: () => {
                this.dogScoreTxt.text = Math.floor(dogData.score) + '';
            }
        });
        dogScoreTW.to({ score: targetDogScore }, 1000);
        let catScoreTW = egret.Tween.get(catData, {
            onChange: () => {
                this.catScoreTxt.text = Math.floor(catData.score) + '';
            }
        });
        catScoreTW.to({ score: targetCatScore }, 1000);


        if (camp == 1) {
            // 猫阵营
            this.bg.x = -750;
            this.gameInfoBg.source = `catTitleBg_png`;
            this.gameInfoBg.x = 80;
            if (Number(DataManager.ins.getData('getValentineInfo').data.catScore) < Number(DataManager.ins.getData('getValentineInfo').data.dogScore)) {
                // 狗赢了
                this.infoTips.text = `我方失败`;
            } else {
                // 猫赢了
                this.infoTips.text = `我方成功`;
                this.lotteryBtn.visible = true;

            }
        } else {
            // 狗阵营
            this.bg.x = 0;
            this.gameInfoBg.source = `dogTitleBg_png`;
            this.gameInfoBg.x = 40;
            if (Number(DataManager.ins.getData('getValentineInfo').data.catScore) < Number(DataManager.ins.getData('getValentineInfo').data.dogScore)) {
                // 狗赢了
                this.infoTips.text = `我方成功`;
                this.lotteryBtn.visible = true;
            } else {
                // 猫赢了
                this.infoTips.text = `我方失败`;
            }
        }
    }

    initEvents() {
        super.initEvents();
        this.lotteryBtn.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onTap_lotteryBtn, this);
    }

    removeEvents() {
        super.removeEvents();
        this.lotteryBtn.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onTap_lotteryBtn, this);
    }

    onTap_lotteryBtn() {
    }
}