import ViewManager, { ViewType } from "../game_module/ViewManager";
import { PlayerManager } from "../GameLogic/PlayerManager";
import GuideView from "../View/GuideView";

export default class GuideController {
    private static instance: GuideController;
    public static get Instance(): GuideController {
        return this.instance || (this.instance = new GuideController());
    }

    public isguide = false;
    public IsGuide() {
        // this.isguide = true;
        // return true;
        let t = Laya.LocalStorage.getItem("guide");
        if ( PlayerManager.Instance.stage == 1) {
            Laya.LocalStorage.setItem("guide", "1");
            this.isguide = true;
            return true;
        }
        this.isguide = false;
        return false;
    }

    public guide1pos = new Laya.Vector3(2.5, 0, 59.4);
    public guide2Pos=new Laya.Vector3(-5,2,104.4)

    private index=0;
    public SetGuidePos(p){
        if(this.index==0){
            this.guide1pos.z=p;
            this.index++;
        }else if(this.index==1){
            this.guide2Pos.z=p;
            this.index++;
        }
    }
    public StartGuide() {
        if (this.isguide) {
            Laya.timer.once(500, this, this.Guide1);
        }
    }
    public OverGuide(){
        this.isguide=false;
        ViewManager.Instance.CloseGuideView();
    }
    Guide1() {
        ViewManager.Instance.ShowGuideView();
        if(GuideView.Instance){
            GuideView.Instance.SetGuide(1);
        }
    }

    GameDied(){
        if(this.isguide){
            ViewManager.Instance.CloseGuideView();
        }
    }
}