mirror of
https://github.com/kirikayakazuto/CocosCreator_ECS
synced 2025-12-19 10:30:00 +00:00
feat: upadte readme
Change-Id: I995be2b19fec8107ba5df6a04fb1f0e7b3fcae7f
This commit is contained in:
@@ -586,7 +586,7 @@ export namespace BT {
|
||||
comMovable.pointIdx = 0;
|
||||
comMovable.points.length = 0;
|
||||
let targetX = node.size.width * Math.random() - node.size.width/2;
|
||||
let targetY = node.size.height * Math.random() - node.size.height/2;
|
||||
let targetY = node.size.height * Math.random() - node.size.height/2 - 150;
|
||||
comMovable.points.push(cc.v2(comTrans.x, comTrans.y), cc.v2(targetX, targetY));
|
||||
comMovable.speed = node.speed;
|
||||
comMovable.speedDirty = true;
|
||||
|
||||
@@ -44,7 +44,7 @@ export class ECSController<T extends ECSWorld> {
|
||||
new BT.InverterNode(new BT.MonitorNode()),
|
||||
new BT.LockedSequenceNode([
|
||||
new BT.WaitNode(1.5),
|
||||
new BT.WalkToRandomPosNode(100, cc.size(view.width - 200, view.height - 200)),
|
||||
new BT.WalkToRandomPosNode(100, cc.size(view.width - 100, view.height - 300)),
|
||||
])
|
||||
], true),
|
||||
new BT.LockedSequenceNode([
|
||||
|
||||
@@ -98,8 +98,8 @@ export default class RoleEventProcess extends EventProcess {
|
||||
}
|
||||
this.graphics.lineTo(event.points[0].x, event.points[0].y);
|
||||
this.graphics.stroke();
|
||||
|
||||
|
||||
|
||||
event.points.length = 0;
|
||||
}
|
||||
|
||||
public sync(x: number, y: number, dir: cc.Vec2) {
|
||||
|
||||
@@ -35,11 +35,14 @@ export class SysAttack extends ECSSystem {
|
||||
public onUpdate(world: ECSWorld, dt: number): void {
|
||||
let filter = world.getFilter(FILTER_ATTACKABLE);
|
||||
filter.walk((entity: number) => {
|
||||
|
||||
let comTransSelf = world.getComponent(entity, ComTransform);
|
||||
let comAttackable = world.getComponent(entity, ComAttackable);
|
||||
let comRoleConfigSelf = world.getComponent(entity, ComRoleConfig);
|
||||
if(!comAttackable.dirty) return ;
|
||||
|
||||
comAttackable.debugInfo = null;
|
||||
|
||||
comAttackable.countDown -= dt;
|
||||
if(comAttackable.countDown <= 0) {
|
||||
comAttackable.dirty = false;
|
||||
@@ -67,10 +70,7 @@ export class SysAttack extends ECSSystem {
|
||||
return true
|
||||
}
|
||||
|
||||
comAttackable.debugInfo = {
|
||||
points: [cc.v2(minX, minY), cc.v2(maxX, minY), cc.v2(maxX, maxY), cc.v2(minX, maxY)],
|
||||
color: cc.Color.RED,
|
||||
};
|
||||
|
||||
|
||||
// 即将攻击未完成, 并且处于即将攻击时间段
|
||||
if(!comAttackable.willHurtFrameCompleted && comAttackable.countDown <= comAttackable.willHurtFrame) {
|
||||
@@ -84,6 +84,11 @@ export class SysAttack extends ECSSystem {
|
||||
return false;
|
||||
})
|
||||
}
|
||||
|
||||
comAttackable.debugInfo = {
|
||||
points: [cc.v2(minX, minY), cc.v2(maxX, minY), cc.v2(maxX, maxY), cc.v2(minX, maxY)],
|
||||
color: cc.Color.RED,
|
||||
};
|
||||
|
||||
if(!comAttackable.hurtFrameCompleted && comAttackable.countDown <= comAttackable.hurtFrame) {
|
||||
comAttackable.hurtFrameCompleted = true;
|
||||
|
||||
@@ -47,8 +47,6 @@ export class SysRoleState extends ECSSystem {
|
||||
comCocosNode.events.push(new EventGraphicsDraw(comAttackable.debugInfo.points, comAttackable.debugInfo.color));
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(comMovable && comMovable.speedDirty) {
|
||||
comMovable.speedDirty = false;
|
||||
if(comMovable.speed > 0) {
|
||||
|
||||
@@ -100,5 +100,19 @@ export default class Main extends cc.Component {
|
||||
}
|
||||
|
||||
|
||||
private a() {
|
||||
let map = {0: 0, 1: 0, 2: 0}; // 出现1的次数
|
||||
for(let c=0; c<10000; c++) {
|
||||
let a = [1, 2, 3];
|
||||
a = a.sort((a, b) => Math.random() - 0.5);
|
||||
for(let i=0; i<a.length; i++) {
|
||||
if(a[i] == 1) {
|
||||
map[i] ++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user