import MouseEvent from "./MouseEvent";
import MoundManager from "../Manager/MoundManager";
import StreetManager from "../Manager/StreetManager";
import MateManager from "../Manager/MateManager";
import MainRoleManager from "../Manager/MainRoleManager";
import RoleManager from "../Manager/RoleManager";
import ViewManager, { ViewType } from "../game_module/ViewManager";
import CameraManager from "../Manager/CameraManager";
import { CameraState } from "./Camera";
import { Scene3DManager } from "./Scene3DManager";
import { PlayerManager } from "./PlayerManager";
import { DispatcherManager, EventType } from "./DispatcherManager";
import { WXSdk } from "../game_module/WXSdk";
import GuideController from "../Manager/GuideController";
import BannerAndVideo1 from "../game_module/BannerAndVideo1";



export default class GameManager {

    private static instance: GameManager;
    public static get Instance(): GameManager {
        return GameManager.instance || (GameManager.instance = new GameManager());
    }

    //public canshowtoptip = false;
    public GameStart() {
        this.towerCount = 0;
        this.roleCount = 0;
        this.blockCount = 0;
        //this.canshowtoptip = true;
        //this.canshowtoptip=true;
    }


    public towerCount = 0;
    public roleCount = 0;
    public blockCount = 0;
    public GameWin() {
        WXSdk.LongVibrate();

        BannerAndVideo1.Clear();
        //YouZiHuiTuiController.Instance.ClearBannerHuiTui_main();
        ViewManager.Instance.AddView(ViewType.CompleteView, true);
        MoundManager.Instance.Reset();
        StreetManager.Instance.Reset();
        MateManager.Instance.Reset();
        MainRoleManager.Instance.Reset();
        RoleManager.Instance.Reset();
    }

    ToDance(isglod = false) {
        BannerAndVideo1.CheatBanner(null);

        MainRoleManager.Instance.GoToDance();
        if (isglod) MateManager.Instance.GoToDance1();
        else MateManager.Instance.GoToDance();
        CameraManager.Instance.SetCamState(CameraState.jump, 0.03);  //TODO
        Laya.timer.once(4000, this, this.GameWin);//todo
    }

    //public gameisover=false;
    /**
     * 游戏结束
     */
    public GameOver() {
        GuideController.Instance.GameDied();
        //this.canshowtoptip = false;
        MouseEvent.Instance.OnClickUp();
        MainRoleManager.Instance.StopCreate();

        MouseEvent.Instance._Switch = false;
        WXSdk.LongVibrate();

        BannerAndVideo1.Clear();
        ViewManager.Instance.AddView(ViewType.CompleteView, false);
        MoundManager.Instance.Reset();
        StreetManager.Instance.Reset();
        MateManager.Instance.Reset();
        MainRoleManager.Instance.Reset();
        MainRoleManager.Instance.SetActiveFalse();
        RoleManager.Instance.Reset();
    }
    private easterCount = 0;
    public Pause() {
        // MouseEvent.Instance._Switch=false;
        if (this.easterCount >= 1) {
            this.GameOver();
            return;
        }
        this.easterCount++;
    }
    public Easter() {

    }

    //人物到达终点
    public Arrive() {
       // this.canshowtoptip = false;
        MoundManager.Instance.Reset();
        StreetManager.Instance.Reset();
    }

    public NextLevel() {

        PlayerManager.Instance.stage++;
        Scene3DManager.Instance.InItScene();
        ViewManager.Instance.CloseView(ViewType.CompleteView);
        DispatcherManager.event(EventType.Event.ShowMainUi);
        DispatcherManager.event(EventType.Event.SetStage);
        DispatcherManager.event(EventType.Event.SetStagePro, 0);
    }

    public ReStart() {
        MateManager.Instance.Reset();


        Scene3DManager.Instance.InItScene();
        DispatcherManager.event(EventType.Event.ShowMainUi);
        DispatcherManager.event(EventType.Event.SetStagePro, 0);
    }
  
     huituiFunc(ist){
        if(ist)  {
        }else{
            console.log("result Close huitui");
        }
    }

    ShowTopTip() {
        
    }



}