'use strict';

var foreign0 = /*#__PURE__*/Object.freeze({
    __proto__: null
});

/******************************************************************************
Copyright (c) Microsoft Corporation.

Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
/* global Reflect, Promise */


function __decorate(decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
}

/**
 * AUTO GENERATE BY UI EDITOR.
 * WARNING: DO NOT MODIFY THIS FILE,MAY CAUSE CODE LOST.
 * UI: UI/DefaultUI.ui
*/
let DefaultUI_Generate = class DefaultUI_Generate extends UIScript {
    /**
    * onStart 之前触发一次
    */
    onAwake() {
    }
};
DefaultUI_Generate = __decorate([
    UIBind('UI/DefaultUI.ui')
], DefaultUI_Generate);
var DefaultUI_generate = DefaultUI_Generate;

var foreign3 = /*#__PURE__*/Object.freeze({
    __proto__: null,
    default: DefaultUI_generate
});

let UIDefault = class UIDefault extends DefaultUI_generate {
    /** 仅在游戏时间对非模板实例调用一次 */
    onStart() {
    }
    /**
     * 拖拽事件完成
     */
    onDrop(InGemotry, InDragDropEvent, InOperation) {
        console.warn("OnDrop" + InDragDropEvent.screenSpacePosition);
        //重新创建一个空白图片的自定义UI并设置位置
        let ui1 = createUIByName("NewUI");
        this.uiWidgetBase.rootContent.addChild(ui1);
        ui1.position = (new Vector2(absoluteToLocal(InGemotry, InDragDropEvent.screenSpacePosition).x - ui1.size.x * 0.5, absoluteToLocal(InGemotry, InDragDropEvent.screenSpacePosition).y - ui1.size.y * 0.5));
        console.log(ui1.position);
        //把旧的空白图片UI销毁
        const payLoad = InOperation.tryGetDragDropPayLoadAs();
        const test1 = payLoad.Test1;
        test1.destroyObject();
    }
    /**
 * 拖拽操作生成事件触发后，没有完成完成的拖拽事件而取消时触发
 */
    onDragCancelled(InGemotry, InDragDropEvent) {
        console.warn("onDragCancelled" + InDragDropEvent.screenSpacePosition);
    }
    /**
     * 构造UI文件成功后，onStart之后
     * 对于UI的根节点的添加操作，进行调用
     * 注意：该事件可能会多次调用
     */
    onAdded() {
    }
    /**
     * 构造UI文件成功后，onAdded之后
     * 对于UI的根节点的移除操作，进行调用
     * 注意：该事件可能会多次调用
     */
    onRemoved() {
    }
    /**
    * 构造UI文件成功后，UI对象再被销毁时调用
    * 注意：这之后UI对象已经被销毁了，需要移除所有对该文件和UI相关对象以及子对象的引用
    */
    onDestroy() {
    }
};
UIDefault = __decorate([
    UIBind('')
], UIDefault);
var UIDefault$1 = UIDefault;

var foreign1 = /*#__PURE__*/Object.freeze({
    __proto__: null,
    default: UIDefault$1
});

/**
 * AUTO GENERATE BY UI EDITOR.
 * WARNING: DO NOT MODIFY THIS FILE,MAY CAUSE CODE LOST.
 * UI: UI/NewUI.ui
*/
let NewUI_Generate = class NewUI_Generate extends UIScript {
    get image() {
        if (!this.image_Internal && this.uiWidgetBase) {
            this.image_Internal = this.uiWidgetBase.findChildByPath('RootCanvas/image');
        }
        return this.image_Internal;
    }
    /**
    * onStart 之前触发一次
    */
    onAwake() {
    }
};
NewUI_Generate = __decorate([
    UIBind('UI/NewUI.ui')
], NewUI_Generate);
var NewUI_generate = NewUI_Generate;

var foreign4 = /*#__PURE__*/Object.freeze({
    __proto__: null,
    default: NewUI_generate
});

//创建一个继承DragDropPayLoad的TestDragDropPayLoad类，传入newDragDrop函数作为参数payLoad，跟随拖拽事件传递一些信息
class TestDragDropPayLoad extends DragDropPayLoad {
    get Test1() {
        return this.test1;
    }
    set Test1(v) {
        this.test1 = v;
    }
}
class NewUIScript extends NewUI_generate {
    /**
     * 构造UI文件成功后，在合适的时机最先初始化一次
     */
    onStart() {
        //设置能否每帧触发onUpdate
        this.canUpdate = false;
        this.layer = UILayerMiddle;
        console.log("________");
    }
    //当玩家触摸到此UI时，开始检测是否发生拖拽操作
    onTouchStarted(InGeometry, InPointerEvent) {
        console.log("OnTouch" + InPointerEvent.screenSpacePosition);
        return this.detectDragIfPressed(InPointerEvent, Keys.AnyKey);
    }
    //当玩家触摸到此UI时，开始检测是否发生拖拽操作
    onTouchEnded(InGemetry, InPointEvent) {
        return EventReply.handled;
    }
    //当检测到发生拖拽操作时，创建一个新的拖拽事件，同时设置此拖拽事件的展示UI、tag、数据信息、锚点及偏移
    onDragDetected(InGeometry, InPointerEvent) {
        console.log("OnDrag" + InPointerEvent.screenSpacePosition);
        let ui = createUIByName("NewUI");
        //这里我们用payLoad参数传递的信息是这个UI对象，以便于在onDrop时创建一个新的UI对象并销毁旧的
        const payLoad = new TestDragDropPayLoad();
        payLoad.Test1 = this.uiWidgetBase;
        return this.newDragDrop(ui, "DragDropTag", payLoad, DragPivot.CenterCenter, new Vector2(0, 0));
    }
    /**
     * 构造UI文件成功后，onStart之后
     * 对于UI的根节点的添加操作，进行调用
     * 注意：该事件可能会多次调用
     */
    onAdded() {
    }
    /**
     * 构造UI文件成功后，onAdded之后
     * 对于UI的根节点的移除操作，进行调用
     * 注意：该事件可能会多次调用
     */
    onRemoved() {
    }
    /**
    * 构造UI文件成功后，UI对象再被销毁时调用
    * 注意：这之后UI对象已经被销毁了，需要移除所有对该文件和UI相关对象以及子对象的引用
    */
    onDestroy() {
    }
}

var foreign2 = /*#__PURE__*/Object.freeze({
    __proto__: null,
    TestDragDropPayLoad: TestDragDropPayLoad,
    default: NewUIScript
});

const MWModuleMap = { 
     'build': foreign0,
     'JavaScripts/DefaultUI': foreign1,
     'JavaScripts/NewUIScript': foreign2,
     'JavaScripts/ui-generate/DefaultUI_generate': foreign3,
     'JavaScripts/ui-generate/NewUI_generate': foreign4,
};

exports.MWModuleMap = MWModuleMap;
//# sourceMappingURL=data:application/json;charset=utf-8;base64,[encoded data, 35332 characters]
