import { GPetAminEnum } from "../../anim/GPetAnim";
import { GFSMAnimBase, GFSMProcessAnimInfo } from "../GFSMAnimBase";

//流程枚举
enum ProcessEnum {
    //等待
    Wait = 0,
    //移动
    Move = 1,
    //攻击
    Attack = 2,
    //死亡
    Die = 3,
}

//动画状态机基类
export class GFSMDefaultAnim extends GFSMAnimBase{

    //是否攻击
    isAttack:boolean = false;

    //是否移动
    isMove:boolean = false;

    //是否死亡
    isDie:boolean = false;

    // 流程图
    process: { [key: number]: GFSMProcessAnimInfo; } = {
        [ProcessEnum.Wait]:{
            title:"等待",
            isLoop:true,
            animName:GPetAminEnum.Wait,
            mixs:[0.1,0.1],
            to:[ProcessEnum.Move,ProcessEnum.Attack,ProcessEnum.Die],
            ifTo:[
                () => this.isMove, //前往移动
                () => this.isAttack, //前往攻击
                () => this.isDie,
            ],
        },
        [ProcessEnum.Move]:{
            title:"移动",
            animName:GPetAminEnum.Walk,
            isLoop:true,
            mixs:[0.1,0.1],
            to:[ProcessEnum.Wait,ProcessEnum.Attack,ProcessEnum.Die],
            ifTo:[
                () => !this.isMove, //前往等待
                () => this.isAttack, //前往攻击
                () => this.isDie,
            ],
        },
        [ProcessEnum.Attack]:{
            title:"攻击",
            animName:GPetAminEnum.Attack,
            isLoop:true,
            mixs:[0.1,0.1],
            to:[ProcessEnum.Wait,ProcessEnum.Move,ProcessEnum.Die],
            ifTo:[
                () => !this.isAttack, //前往等待
                () => !this.isAttack && this.isMove, //前往移动
                () => this.isDie,
            ],
        },
        [ProcessEnum.Die]:{
            title:"死亡",
            animName:GPetAminEnum.Fly,
            isLoop:true,
            mixs:[0.1,0.1],
        }
    }

}

