import Sprite3D = Laya.Sprite3D;
import Transform3D = Laya.Transform3D;
import {Camera, CameraState } from "../Game/Camera";

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

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

    public startPosTra: Transform3D;
    

    /**
     * 相机跟随移动
     */
    public CameraFollow(z:number){
        if(this.Camera)this.Camera.MoveGame(z);
    }

    public Init(cam: Laya.Camera, startPos: Sprite3D) {
        this.startPosTra = startPos.transform;
        if (cam) {
            this._maincamera = cam;
            this.Camera = this._maincamera.addComponent(Camera);
            this.Camera.Init();
        }
    }

    
    /************************************************* */
    private createSampleText(): Text {
        var text: Text = new Text();
        text.overflow = Text.HIDDEN;

        text.color = "#FFFFFF";
        text.font = "Impact";
        text.fontSize = 20;
        text.borderColor = "#FFFF00";
        text.x = 80;

        Laya.stage.addChild(text);
        text.text = "A POWERFUL HTML5 ENGINE ON FLASH TECHNICAL\n" + "A POWERFUL HTML5 ENGINE ON FLASH TECHNICAL\n" + "A POWERFUL HTML5 ENGINE ON FLASH TECHNICAL";
        return text;
    }
    /************************************************* */


    /**
     * 设置相机的跟随状态
     */
    public SetCameraAction(type, arg) {
        if (this.Camera) this.Camera.CameraAction(type, arg);
    }

    public _maincamera: Laya.Camera;
    public Camera: Camera;
    
}