mirror of
https://github.com/kirikayakazuto/CocosCreator_ECS
synced 2025-12-17 09:30:01 +00:00
ECS Demo
This commit is contained in:
15
assets/Script/ECS/components/ComAttackable.ts
Normal file
15
assets/Script/ECS/components/ComAttackable.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { ComType, EntityIndex } from "../lib/Const";
|
||||
import { ECSComponent } from "../lib/ECSComponent";
|
||||
|
||||
@ECSComponent(ComType.ComAttackable)
|
||||
export class ComAttackable {
|
||||
public duration: number; // 攻击持续时间
|
||||
public countDown: number; // 攻击剩余时间
|
||||
public hurtFrame: number; // 攻击帧
|
||||
public mustAttackFrame: number;
|
||||
public hurted: boolean;
|
||||
public dirty: boolean; //
|
||||
public attack: number; // 攻击力
|
||||
|
||||
public hurtArea: cc.Vec2; // 攻击区域
|
||||
}
|
||||
10
assets/Script/ECS/components/ComAttackable.ts.meta
Normal file
10
assets/Script/ECS/components/ComAttackable.ts.meta
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"ver": "1.1.0",
|
||||
"uuid": "7ee555b4-eed0-4207-81f5-41b51bb3bd73",
|
||||
"importer": "typescript",
|
||||
"isPlugin": false,
|
||||
"loadPluginInWeb": true,
|
||||
"loadPluginInNative": true,
|
||||
"loadPluginInEditor": false,
|
||||
"subMetas": {}
|
||||
}
|
||||
7
assets/Script/ECS/components/ComBeAttacked.ts
Normal file
7
assets/Script/ECS/components/ComBeAttacked.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
import { ComType } from "../lib/Const";
|
||||
import { ECSComponent } from "../lib/ECSComponent";
|
||||
|
||||
@ECSComponent(ComType.ComBeAttacked)
|
||||
export class ComBeAttacked {
|
||||
|
||||
}
|
||||
10
assets/Script/ECS/components/ComBeAttacked.ts.meta
Normal file
10
assets/Script/ECS/components/ComBeAttacked.ts.meta
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"ver": "1.1.0",
|
||||
"uuid": "c3d913ea-e619-4f5e-bb18-3fe947505dda",
|
||||
"importer": "typescript",
|
||||
"isPlugin": false,
|
||||
"loadPluginInWeb": true,
|
||||
"loadPluginInNative": true,
|
||||
"loadPluginInEditor": false,
|
||||
"subMetas": {}
|
||||
}
|
||||
9
assets/Script/ECS/components/ComBehaviorTree.ts
Normal file
9
assets/Script/ECS/components/ComBehaviorTree.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
import { BT } from "../../Common/BehaviorTree";
|
||||
import { ComType } from "../lib/Const";
|
||||
import { ECSComponent } from "../lib/ECSComponent";
|
||||
|
||||
@ECSComponent(ComType.ComBehaviorTree)
|
||||
export class ComBehaviorTree {
|
||||
public root: BT.NodeBase = null;
|
||||
public bb: BT.BlackBoard = new BT.BlackBoard();
|
||||
}
|
||||
10
assets/Script/ECS/components/ComBehaviorTree.ts.meta
Normal file
10
assets/Script/ECS/components/ComBehaviorTree.ts.meta
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"ver": "1.1.0",
|
||||
"uuid": "a529fff3-0126-4e53-a4c7-e5ddb6d76976",
|
||||
"importer": "typescript",
|
||||
"isPlugin": false,
|
||||
"loadPluginInWeb": true,
|
||||
"loadPluginInNative": true,
|
||||
"loadPluginInEditor": false,
|
||||
"subMetas": {}
|
||||
}
|
||||
10
assets/Script/ECS/components/ComCocosNode.ts
Normal file
10
assets/Script/ECS/components/ComCocosNode.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { EventBase } from "../../Struct/NodeEvent";
|
||||
import { ComType } from "../lib/Const";
|
||||
import { ECSComponent } from "../lib/ECSComponent";
|
||||
|
||||
@ECSComponent(ComType.ComCocosNode)
|
||||
export class ComCocosNode {
|
||||
public node: cc.Node = null;
|
||||
public loaded = false;
|
||||
public events: EventBase[] = [];
|
||||
}
|
||||
10
assets/Script/ECS/components/ComCocosNode.ts.meta
Normal file
10
assets/Script/ECS/components/ComCocosNode.ts.meta
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"ver": "1.1.0",
|
||||
"uuid": "e75ab1ce-3260-45cb-975a-9c4c1ab72f94",
|
||||
"importer": "typescript",
|
||||
"isPlugin": false,
|
||||
"loadPluginInWeb": true,
|
||||
"loadPluginInNative": true,
|
||||
"loadPluginInEditor": false,
|
||||
"subMetas": {}
|
||||
}
|
||||
10
assets/Script/ECS/components/ComMonitor.ts
Normal file
10
assets/Script/ECS/components/ComMonitor.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { ComType, EntityIndex } from "../lib/Const";
|
||||
import { ECSComponent } from "../lib/ECSComponent";
|
||||
|
||||
@ECSComponent(ComType.ComMonitor)
|
||||
export class ComMonitor {
|
||||
public lookLen = 0;
|
||||
public lookSize = 0;
|
||||
public aroundLen = 0;
|
||||
public others: EntityIndex[] = [];
|
||||
}
|
||||
10
assets/Script/ECS/components/ComMonitor.ts.meta
Normal file
10
assets/Script/ECS/components/ComMonitor.ts.meta
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"ver": "1.1.0",
|
||||
"uuid": "274fabed-397f-4950-b691-2c6b6b894c9f",
|
||||
"importer": "typescript",
|
||||
"isPlugin": false,
|
||||
"loadPluginInWeb": true,
|
||||
"loadPluginInNative": true,
|
||||
"loadPluginInEditor": false,
|
||||
"subMetas": {}
|
||||
}
|
||||
12
assets/Script/ECS/components/ComMovable.ts
Executable file
12
assets/Script/ECS/components/ComMovable.ts
Executable file
@@ -0,0 +1,12 @@
|
||||
import { ComType } from "../lib/Const";
|
||||
import { ECSComponent } from "../lib/ECSComponent";
|
||||
|
||||
@ECSComponent(ComType.ComMovable)
|
||||
export class ComMovable {
|
||||
public running = false;
|
||||
public speed = 0;
|
||||
public points: cc.Vec2[] = [];
|
||||
public pointIdx = 0;
|
||||
|
||||
public speedDirty = false;
|
||||
}
|
||||
10
assets/Script/ECS/components/ComMovable.ts.meta
Executable file
10
assets/Script/ECS/components/ComMovable.ts.meta
Executable file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"ver": "1.1.0",
|
||||
"uuid": "773fd91d-89d6-499e-9488-3d85f11938a1",
|
||||
"importer": "typescript",
|
||||
"isPlugin": false,
|
||||
"loadPluginInWeb": true,
|
||||
"loadPluginInNative": true,
|
||||
"loadPluginInEditor": false,
|
||||
"subMetas": {}
|
||||
}
|
||||
9
assets/Script/ECS/components/ComNodeConfig.ts
Normal file
9
assets/Script/ECS/components/ComNodeConfig.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
import { ComType } from "../lib/Const";
|
||||
import { ECSComponent } from "../lib/ECSComponent";
|
||||
|
||||
@ECSComponent(ComType.ComNodeConfig)
|
||||
export class ComNodeConfig {
|
||||
id = 0; // 唯一标识
|
||||
prefabUrl = ''
|
||||
layer = 0; // 层级
|
||||
}
|
||||
10
assets/Script/ECS/components/ComNodeConfig.ts.meta
Normal file
10
assets/Script/ECS/components/ComNodeConfig.ts.meta
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"ver": "1.1.0",
|
||||
"uuid": "ef2ff8f3-8ffa-49f6-8e55-b8ba0284a095",
|
||||
"importer": "typescript",
|
||||
"isPlugin": false,
|
||||
"loadPluginInWeb": true,
|
||||
"loadPluginInNative": true,
|
||||
"loadPluginInEditor": false,
|
||||
"subMetas": {}
|
||||
}
|
||||
16
assets/Script/ECS/components/ComRoleConfig.ts
Normal file
16
assets/Script/ECS/components/ComRoleConfig.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { ComType } from "../lib/Const";
|
||||
import { ECSComponent } from "../lib/ECSComponent";
|
||||
|
||||
|
||||
@ECSComponent(ComType.ComRoleConfig)
|
||||
export class ComRoleConfig {
|
||||
public team: number;
|
||||
public maxHP: number;
|
||||
public lastHP: number;
|
||||
public nowHP: number;
|
||||
public HPDirty: boolean;
|
||||
|
||||
public attack: number;
|
||||
|
||||
public moveSpeed: number;
|
||||
}
|
||||
10
assets/Script/ECS/components/ComRoleConfig.ts.meta
Normal file
10
assets/Script/ECS/components/ComRoleConfig.ts.meta
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"ver": "1.1.0",
|
||||
"uuid": "a0036aea-32a4-4b9b-a587-5262ea4cedf7",
|
||||
"importer": "typescript",
|
||||
"isPlugin": false,
|
||||
"loadPluginInWeb": true,
|
||||
"loadPluginInNative": true,
|
||||
"loadPluginInEditor": false,
|
||||
"subMetas": {}
|
||||
}
|
||||
11
assets/Script/ECS/components/ComTransform.ts
Normal file
11
assets/Script/ECS/components/ComTransform.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { ComType } from "../lib/Const";
|
||||
import { ECSComponent } from "../lib/ECSComponent";
|
||||
|
||||
@ECSComponent(ComType.ComTransform)
|
||||
export class ComTransform {
|
||||
public dir = cc.v2(1, 0); //方向向量
|
||||
public x = 0;
|
||||
public y = 0;
|
||||
public width = 0;
|
||||
public height = 0;
|
||||
}
|
||||
10
assets/Script/ECS/components/ComTransform.ts.meta
Normal file
10
assets/Script/ECS/components/ComTransform.ts.meta
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"ver": "1.1.0",
|
||||
"uuid": "0bb2991a-84c5-4b22-ade6-59d2e7e97252",
|
||||
"importer": "typescript",
|
||||
"isPlugin": false,
|
||||
"loadPluginInWeb": true,
|
||||
"loadPluginInNative": true,
|
||||
"loadPluginInEditor": false,
|
||||
"subMetas": {}
|
||||
}
|
||||
Reference in New Issue
Block a user