import  {ViewManager, ViewType } from "../Net/ViewManager";
import { PlayerManager } from "../Game/PlayerManager";
import GuideView from "../View/GuideView";

import Input = Laya.Input;
import Stage = Laya.Stage;
import Browser = Laya.Browser;
import WebGL = Laya.WebGL;

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

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

    public GuideOn() {
        if (this._guide) {
            Laya.timer.once(500, this, this.Guide);
        }
    }
    
    Guide() {
        // ViewManager.Instance.ShowGuideView();
        // if(GuideView.Instance){
        //     GuideView.Instance.SetGuide(1);
        // }
    }

    public GuideOff(){
        this._guide=false;
        ViewManager.Instance.CloseGuideView();
    }

    GameOver(){
        if(this._guide){
            ViewManager.Instance.CloseGuideView();
        }
    }

    /********************************************* */
    private createInput(): void {
        var inputText: Input = new Input();

        inputText.size(350, 100);
        inputText.x = Laya.stage.width - inputText.width >> 1;
        inputText.y = Laya.stage.height - inputText.height >> 1;

        inputText.text = "这段文本不可编辑，但可复制";
        inputText.editable = false;

        // 设置字体样式
        inputText.bold = true;
        inputText.bgColor = "#666666";
        inputText.color = "#ffffff";
        inputText.fontSize = 20;

        Laya.stage.addChild(inputText);
    }
    /********************************************* */

    private index=0;
    public InitGuide(p){
        if(this.index==0){
            this.guideonepos.z=p;
            this.index++;
        }else if(this.index==1){
            this.guidetwoPos.z=p;
            this.index++;
        }
    }

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