// Learn TypeScript:
//  - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html

import { asyncPlayDragonBoneAnimation } from "../util_DG23";

const { ccclass, property } = cc._decorator;

@ccclass
export default class Boy extends cc.Component {

    @property(cc.Node)
    aniBody: cc.Node

    aniNameList = ["run", "good", "cheer", "expect", "talk", "invite", "wave", "point"]

    protected onLoad(): void {


        // let index = 0;
        // this.schedule(() => {

        //     index = index % this.aniNameList.length;
        //     asyncPlayDragonBoneAnimation(this.aniBody, this.aniNameList[index], 1);
        //     cc.log("play ani name :" + this.aniNameList[index]);

        //     index++;

        // }, 3, 10000, 5)
        // this.aniBody.getComponent(dragonBones.ArmatureDisplay)

    }
    playNormal() {
        cc.log("play ani name : expect");
        asyncPlayDragonBoneAnimation(this.aniBody, "normal", -1,)
    }
    async playRun(time: number = 1) {
        cc.log("play ani name : run");
        await asyncPlayDragonBoneAnimation(this.aniBody, "run", time);
        this.playNormal();
    }

    async playCheer(time: number = 1) {
        let localTime = time;
        cc.log("play ani name : cheer");
        await asyncPlayDragonBoneAnimation(this.aniBody, "cheer", time);
        this.playNormal();
    }
    async playExpect(time: number = 1) {
        let localTime = time;
        cc.log("play ani name : expect");
        await asyncPlayDragonBoneAnimation(this.aniBody, "expect", time);
        this.playNormal();
    }
    async playtalk(time: number = 1) {
        let localTime = time;
        cc.log("play ani name : talk");
        await asyncPlayDragonBoneAnimation(this.aniBody, "talk", time,)
        this.playNormal();
    }
    async playGood(time: number = 1) {
        let localTime = time;
        cc.log("play ani name : good");
        await asyncPlayDragonBoneAnimation(this.aniBody, "good", time)
        this.playNormal();
    }
    async playWave(time: number = 1) {
        let localTime = time;
        cc.log("play ani name : wave");
        await asyncPlayDragonBoneAnimation(this.aniBody, "wave", time)
        this.playNormal();
    }
    async playPoint(time: number = 1) {
        let localTime = time;
        cc.log("play ani name : point");
        await asyncPlayDragonBoneAnimation(this.aniBody, "point", time)
        this.playNormal();
    }
    async playInvite(time: number = 1) {
        let localTime = time;
        cc.log("play ani name : invite");
        await asyncPlayDragonBoneAnimation(this.aniBody, "invite", time)
        this.playNormal();
    }


    // update (dt) {}
}
