update
This commit is contained in:
@@ -1,17 +1,16 @@
|
||||
import { _decorator } from 'cc'
|
||||
import { EntityManager } from '../../Base/EntityManager'
|
||||
import { EntityTypeEnum, IVec2 } from '../../Common'
|
||||
import { EntityStateEnum } from '../../Enum'
|
||||
import { ExplosionStateMachine } from './ExplosionStateMachine'
|
||||
const { ccclass, property } = _decorator
|
||||
import { _decorator } from "cc";
|
||||
import { EntityManager } from "../../Base/EntityManager";
|
||||
import { EntityTypeEnum, IVec2 } from "../../Common";
|
||||
import { EntityStateEnum } from "../../Enum";
|
||||
import { ExplosionStateMachine } from "./ExplosionStateMachine";
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass('ExplosionManager')
|
||||
@ccclass("ExplosionManager")
|
||||
export class ExplosionManager extends EntityManager {
|
||||
|
||||
init(type: EntityTypeEnum, { x, y }: IVec2) {
|
||||
this.node.setPosition(x, y)
|
||||
this.fsm = this.addComponent(ExplosionStateMachine)
|
||||
this.fsm.init(type)
|
||||
this.state = EntityStateEnum.Idle
|
||||
this.node.setPosition(x, y);
|
||||
this.fsm = this.addComponent(ExplosionStateMachine);
|
||||
this.fsm.init(type);
|
||||
this.state = EntityStateEnum.Idle;
|
||||
}
|
||||
}
|
||||
|
@@ -1,52 +1,52 @@
|
||||
import { _decorator, Animation } from 'cc'
|
||||
import State from '../../Base/State'
|
||||
import StateMachine, { getInitParamsTrigger } from '../../Base/StateMachine'
|
||||
import { EntityTypeEnum } from '../../Common'
|
||||
import { EntityStateEnum, ParamsNameEnum } from '../../Enum'
|
||||
import ObjectPoolManager from '../../Global/ObjectPoolManager'
|
||||
const { ccclass, property } = _decorator
|
||||
import { _decorator, Animation } from "cc";
|
||||
import State from "../../Base/State";
|
||||
import StateMachine, { getInitParamsTrigger } from "../../Base/StateMachine";
|
||||
import { EntityTypeEnum } from "../../Common";
|
||||
import { EntityStateEnum, ParamsNameEnum } from "../../Enum";
|
||||
import ObjectPoolManager from "../../Global/ObjectPoolManager";
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass('ExplosionStateMachine')
|
||||
@ccclass("ExplosionStateMachine")
|
||||
export class ExplosionStateMachine extends StateMachine {
|
||||
init(type: EntityTypeEnum) {
|
||||
this.type = type
|
||||
this.animationComponent = this.node.addComponent(Animation)
|
||||
this.type = type;
|
||||
this.animationComponent = this.node.addComponent(Animation);
|
||||
|
||||
this.initParams()
|
||||
this.initStateMachines()
|
||||
this.initAnimationEvent()
|
||||
this.initParams();
|
||||
this.initStateMachines();
|
||||
this.initAnimationEvent();
|
||||
}
|
||||
|
||||
initParams() {
|
||||
this.params.set(ParamsNameEnum.Idle, getInitParamsTrigger())
|
||||
this.params.set(ParamsNameEnum.Idle, getInitParamsTrigger());
|
||||
}
|
||||
|
||||
initStateMachines() {
|
||||
this.stateMachines.set(ParamsNameEnum.Idle, new State(this, `${this.type}${EntityStateEnum.Idle}`))
|
||||
this.stateMachines.set(ParamsNameEnum.Idle, new State(this, `${this.type}${EntityStateEnum.Idle}`));
|
||||
}
|
||||
|
||||
initAnimationEvent() {
|
||||
this.animationComponent.on(Animation.EventType.FINISHED, () => {
|
||||
const whiteList = [EntityStateEnum.Idle]
|
||||
const name = this.animationComponent.defaultClip.name
|
||||
if (whiteList.some(v => name.includes(v))) {
|
||||
ObjectPoolManager.Instance.ret(this.node)
|
||||
const whiteList = [EntityStateEnum.Idle];
|
||||
const name = this.animationComponent.defaultClip.name;
|
||||
if (whiteList.some((v) => name.includes(v))) {
|
||||
ObjectPoolManager.Instance.ret(this.node);
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
run() {
|
||||
switch (this.currentState) {
|
||||
case this.stateMachines.get(ParamsNameEnum.Idle):
|
||||
if (this.params.get(ParamsNameEnum.Idle).value) {
|
||||
this.currentState = this.stateMachines.get(ParamsNameEnum.Idle)
|
||||
this.currentState = this.stateMachines.get(ParamsNameEnum.Idle);
|
||||
} else {
|
||||
this.currentState = this.currentState
|
||||
this.currentState = this.currentState;
|
||||
}
|
||||
break
|
||||
break;
|
||||
default:
|
||||
this.currentState = this.stateMachines.get(ParamsNameEnum.Idle)
|
||||
break
|
||||
this.currentState = this.stateMachines.get(ParamsNameEnum.Idle);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user