import { _decorator,sys} from "cc";
import PlatformWX from "./PlatformWX";
import PlatformTT from "./PlatformTT";
import PlatformBrowser from "./PlatformBrowser";
import PlatformDefault from "./PlatformDefault";

class PlatformSystem {
    private _platformWX = PlatformWX;
    private _platformTT = PlatformTT;
    private _platformBrowser = PlatformBrowser;
    private _platformDefault = PlatformDefault;

    public get platform(): any {
        switch (sys.platform) {
            //微信小游戏
            case sys.Platform.WECHAT_GAME:
                return this._platformWX;
                break;
            //抖音小游戏
            case sys.Platform.BYTEDANCE_MINI_GAME:
                return this._platformTT;
                break;
            //手机浏览器或者web浏览器
            case sys.Platform.MOBILE_BROWSER: 
            case sys.Platform.DESKTOP_BROWSER:
                return this._platformBrowser;
            //测试用
            default:
                return this._platformDefault;
                break;
        }
    }

    public initialize() {
        switch (sys.platform) {
            //微信小游戏
            case sys.Platform.WECHAT_GAME:
                this._platformWX.initialize();
                break;
            //抖音字节
            case sys.Platform.BYTEDANCE_MINI_GAME:
                this._platformTT.initialize();
                break;
            //手机浏览器 web浏览器
            case sys.Platform.MOBILE_BROWSER:
            case sys.Platform.DESKTOP_BROWSER:
                this._platformBrowser.initialize();
                break;
            //测试用
            default:
                this._platformDefault.initialize();
                break;
        }
    }
}

export default new PlatformSystem();