import { Entity, ScillaComponent, getStageSize } from 'scilla-core/src';
import { setY } from './setXY';

export default class MainController extends ScillaComponent {

    mainbottom: Entity;
    progressBarFrontBg: Entity;
    countTxtWrapper: Entity;

    onCreate() {
        super.onCreate();
        // DataManager.ins.customCfgData = window['CFG'];
        // NetManager.ins.doJoin(() => { });
    }

    onAwake() {
        super.onAwake();
        this.setProgress(0);
        let per = 0;
        setInterval(() => {
            per++;
            if (per > 100) per = 100;
            setY(this.progressBarFrontBg, -148 + 295 * (100 - per) / 100);
        }, 50);

        console.log(this.mainbottom)
        setY(this.mainbottom, -1624/2 + getStageSize().height - 146/2);
    }

    setProgress(per) {
        setY(this.progressBarFrontBg, -148 + 295 * (100 - per) / 100);
    }

    onWithdrawBtnTap() {
        alert('onWithdrawBtnTap')
    }

    onRecordBtnTap() {
        alert('onRecordBtnTap')
    }

    onRuleBtnTap() {
        alert('onRuleBtnTap')
    }

    onTasksBtnTap() {
        alert('onTasksBtnTap')
    }

    onEggsBtnTap() {
        alert('onEggsBtnTap')
    }
}