import { director, Game, ITweenOption, Node, Sprite } from "cc";
import { DJ, DJ_TYPE, Key } from "./Enums";
import { ColorDate } from "./ColorDate";
import { LayerCatAction } from "./LayerCatAction";
import { LayerRootAction } from "./LayerRootAction";
import { LayerEmptyAction } from "./LayerEmptyAction";
import { Main } from "./Main";
import { ShowLevelAction } from "./ShowLevelAction";
import { GameOverAction } from "./GameOverAction";
import { CoinsAction } from "./CoinsAction";
import { SuccessAction } from "./SuccessAction";
import { LayerBtnAction } from "./LayerBtnAction";
import { TipsAction } from "./TipsAction";
import { BucketAction } from "./BucketAction";
import { PropsAction } from "./PropsAction";
import { PinAction } from "./PinAction";

export class Global {

    static start = false;
    static LoadingRate = 0;
    static layer_cat_action: LayerCatAction;
    static layer_root_action: LayerRootAction;
    static layer_empty_action: LayerEmptyAction;
    static main_action: Main;
    static Show_level_action: ShowLevelAction;

    static game_over_action: GameOverAction;
    static coins_action: CoinsAction;
    static success_action: SuccessAction;
    static layer_btn_action: LayerBtnAction;
    static tips_action: TipsAction;
    static bucket_action: BucketAction;
    static props_action: PropsAction;


    static Pause(isPause = true) {
        director.emit(Key.Pause, isPause);
        Global.start = !isPause;
    }


    static cur_lvl_pin_total = 0;
    static cur_lvl_pin_move_num = 0;

    public static init_pin_info(total: number) {
        Global.cur_lvl_pin_total = total;
        Global.cur_lvl_pin_move_num = 0;
    }

    public static pin_prgress_computed(num: number) {
        Global.cur_lvl_pin_move_num += num;
    }


    public static next_level(): number {
        Global.cur_lvl++;
        return Global.cur_lvl;
    }

    static sound_switch = true;

    /**
     * 当前获取的的金币
     */
    static cur_coins = 0;
    /**
     * 使用道具需要多少金币
     */
     private static need_coins = 30;   //zh:diy def =30 //zh:diy

     public static get_need_coins():number{
        return Global.need_coins*Global.cur_lvl;
     }

    public static use_coins(c: number) {
        Global.cur_coins = Global.cur_coins - c;
        if (Global.cur_coins < 0) {
            Global.cur_coins = 0;
        }
    }



    //当前等级
    static cur_lvl = 0;
    //从头开始游戏,进行默认设置
    public static restart_default(lvl = 0) {
        Global.cur_lvl = lvl;
        Global.cur_coins = 0;
    }


    /**
     * 每关开始前调用
     */
    public static every_level_default() {
        Global.cur_lvl_pin_total = 0;
        Global.cur_lvl_pin_move_num = 0;
        //clear bucket container
        Global.bucket_action.clear_container();
    }

    static our_easing: ITweenOption = { easing: 'quadInOut' };
    static ad_intersitial_id: string;
    static ad_video_id: string;

    /**
     * 是否是开发测试，zh:diy 注意！上线发布要改为false
     */
    static devMark = false;

}

