// Learn TypeScript:
//  - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/typescript.html
//  - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/typescript.html
// Learn Attribute:
//  - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html
//  - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html
//  - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/life-cycle-callbacks.html

const {ccclass, property} = cc._decorator;

@ccclass
export default class BossFight {


    static goToFlutter()
    {
         if (cc.sys.os === cc.sys.OS_IOS) {                                
                if (jsb) {
        jsb.reflection.callStaticMethod("AppController", "switchToFlutter");
                }
            }
    }

    //4 all orientation
    //0, 2 portrait
    //1, 3 landscape
    static changeOrientation(value) {
        let DetermineImportListCodec = null;

        if (cc.sys.isNative) {
            if (cc.sys.os === cc.sys.OS_IOS) {                                
                if (jsb) {
                    DetermineImportListCodec = jsb.reflection.callStaticMethod("AppController", "DetermineImportListCodec");

                    try {
                        jsb.reflection.callStaticMethod("AppController", "FindBadgeDataListBooleanField:", value);
                    } catch (e) {
                        cc.log("changeOrientation e: " + JSON.stringify(e));
                    }
                }
            } else if (cc.sys.os === cc.sys.OS_ANDROID) {
                if (jsb) {
                    try {
                        let className = "org/cocos2dx/javascript/AppActivity";
                        let methodName = "setOrientation";
                        let methodSignature = "(I)V";

                        if (jsb) {
                            DetermineImportListCodec = jsb.reflection.callStaticMethod(className, "DetermineImportListCodec", "()Z");
                            jsb.reflection.callStaticMethod(className, methodName, methodSignature, value);
                        }
                    } catch (e) {
                        cc.log("changeOrientation e: " + JSON.stringify(e));
                     }
                }
            }
        }

        cc.log("DetermineImportListCodec: " + DetermineImportListCodec);
        
        if (value == 0 || value == 2) {
            cc.view.setOrientation(cc.macro.ORIENTATION_PORTRAIT);
        } else if (value == 1 || value == 3) {
            cc.view.setOrientation(cc.macro.ORIENTATION_LANDSCAPE);
        } else {
            cc.view.setOrientation(cc.macro.ORIENTATION_AUTO);
        }
    }

    // LIFE-CYCLE CALLBACKS:

    // onLoad () {}

    start () {

    }

    // update (dt) {}
}
