This commit is contained in:
pan
2024-08-20 18:27:34 +08:00
parent 87a445c225
commit b9edfd7001
17 changed files with 407 additions and 143 deletions

View File

@@ -28,17 +28,17 @@
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 70 "__id__": 78
}, },
{ {
"__id__": 72 "__id__": 80
}, },
{ {
"__id__": 74 "__id__": 82
} }
], ],
"_prefab": { "_prefab": {
"__id__": 76 "__id__": 84
}, },
"_lpos": { "_lpos": {
"__type__": "cc.Vec3", "__type__": "cc.Vec3",
@@ -196,18 +196,24 @@
], ],
"_active": true, "_active": true,
"_components": [ "_components": [
{
"__id__": 63
},
{
"__id__": 65
},
{ {
"__id__": 67 "__id__": 67
},
{
"__id__": 69
},
{
"__id__": 71
},
{
"__id__": 73
},
{
"__id__": 75
} }
], ],
"_prefab": { "_prefab": {
"__id__": 69 "__id__": 77
}, },
"_lpos": { "_lpos": {
"__type__": "cc.Vec3", "__type__": "cc.Vec3",
@@ -257,17 +263,17 @@
"__id__": 38 "__id__": 38
}, },
{ {
"__id__": 44 "__id__": 46
} }
], ],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 60 "__id__": 64
} }
], ],
"_prefab": { "_prefab": {
"__id__": 62 "__id__": 66
}, },
"_lpos": { "_lpos": {
"__type__": "cc.Vec3", "__type__": "cc.Vec3",
@@ -942,10 +948,13 @@
}, },
{ {
"__id__": 41 "__id__": 41
},
{
"__id__": 43
} }
], ],
"_prefab": { "_prefab": {
"__id__": 43 "__id__": 45
}, },
"_lpos": { "_lpos": {
"__type__": "cc.Vec3", "__type__": "cc.Vec3",
@@ -1022,6 +1031,24 @@
"__type__": "cc.CompPrefabInfo", "__type__": "cc.CompPrefabInfo",
"fileId": "6fzmfjcbNPK6tOzQOKJfRV" "fileId": "6fzmfjcbNPK6tOzQOKJfRV"
}, },
{
"__type__": "c0f2fdqfBtOjKCjsgH1qG9+",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 38
},
"_enabled": true,
"__prefab": {
"__id__": 44
},
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "173LGjeL9OlLaNVYt3Y+qH"
},
{ {
"__type__": "cc.PrefabInfo", "__type__": "cc.PrefabInfo",
"root": { "root": {
@@ -1045,20 +1072,23 @@
}, },
"_children": [ "_children": [
{ {
"__id__": 45 "__id__": 47
} }
], ],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 55 "__id__": 57
}, },
{ {
"__id__": 57 "__id__": 59
},
{
"__id__": 61
} }
], ],
"_prefab": { "_prefab": {
"__id__": 59 "__id__": 63
}, },
"_lpos": { "_lpos": {
"__type__": "cc.Vec3", "__type__": "cc.Vec3",
@@ -1093,17 +1123,17 @@
"__type__": "cc.Node", "__type__": "cc.Node",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 44 "__id__": 46
}, },
"_prefab": { "_prefab": {
"__id__": 46 "__id__": 48
}, },
"__editorExtras__": {} "__editorExtras__": {}
}, },
{ {
"__type__": "cc.PrefabInfo", "__type__": "cc.PrefabInfo",
"root": { "root": {
"__id__": 45 "__id__": 47
}, },
"asset": { "asset": {
"__uuid__": "63c02880-bda6-4370-bb22-46bf4f49bbfe", "__uuid__": "63c02880-bda6-4370-bb22-46bf4f49bbfe",
@@ -1111,7 +1141,7 @@
}, },
"fileId": "fdklpBwCBM/qJ4WFlQF3kT", "fileId": "fdklpBwCBM/qJ4WFlQF3kT",
"instance": { "instance": {
"__id__": 47 "__id__": 49
}, },
"targetOverrides": null "targetOverrides": null
}, },
@@ -1124,15 +1154,9 @@
"mountedChildren": [], "mountedChildren": [],
"mountedComponents": [], "mountedComponents": [],
"propertyOverrides": [ "propertyOverrides": [
{
"__id__": 48
},
{ {
"__id__": 50 "__id__": 50
}, },
{
"__id__": 51
},
{ {
"__id__": 52 "__id__": 52
}, },
@@ -1141,6 +1165,12 @@
}, },
{ {
"__id__": 54 "__id__": 54
},
{
"__id__": 55
},
{
"__id__": 56
} }
], ],
"removedComponents": [] "removedComponents": []
@@ -1148,7 +1178,7 @@
{ {
"__type__": "CCPropertyOverrideInfo", "__type__": "CCPropertyOverrideInfo",
"targetInfo": { "targetInfo": {
"__id__": 49 "__id__": 51
}, },
"propertyPath": [ "propertyPath": [
"_name" "_name"
@@ -1164,7 +1194,7 @@
{ {
"__type__": "CCPropertyOverrideInfo", "__type__": "CCPropertyOverrideInfo",
"targetInfo": { "targetInfo": {
"__id__": 49 "__id__": 51
}, },
"propertyPath": [ "propertyPath": [
"_lpos" "_lpos"
@@ -1179,7 +1209,7 @@
{ {
"__type__": "CCPropertyOverrideInfo", "__type__": "CCPropertyOverrideInfo",
"targetInfo": { "targetInfo": {
"__id__": 49 "__id__": 51
}, },
"propertyPath": [ "propertyPath": [
"_lrot" "_lrot"
@@ -1195,7 +1225,7 @@
{ {
"__type__": "CCPropertyOverrideInfo", "__type__": "CCPropertyOverrideInfo",
"targetInfo": { "targetInfo": {
"__id__": 49 "__id__": 51
}, },
"propertyPath": [ "propertyPath": [
"_euler" "_euler"
@@ -1210,7 +1240,7 @@
{ {
"__type__": "CCPropertyOverrideInfo", "__type__": "CCPropertyOverrideInfo",
"targetInfo": { "targetInfo": {
"__id__": 49 "__id__": 51
}, },
"propertyPath": [ "propertyPath": [
"_active" "_active"
@@ -1220,7 +1250,7 @@
{ {
"__type__": "CCPropertyOverrideInfo", "__type__": "CCPropertyOverrideInfo",
"targetInfo": { "targetInfo": {
"__id__": 49 "__id__": 51
}, },
"propertyPath": [ "propertyPath": [
"_lscale" "_lscale"
@@ -1238,11 +1268,11 @@
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {}, "__editorExtras__": {},
"node": { "node": {
"__id__": 44 "__id__": 46
}, },
"_enabled": true, "_enabled": true,
"__prefab": { "__prefab": {
"__id__": 56 "__id__": 58
}, },
"_contentSize": { "_contentSize": {
"__type__": "cc.Size", "__type__": "cc.Size",
@@ -1266,11 +1296,11 @@
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {}, "__editorExtras__": {},
"node": { "node": {
"__id__": 44 "__id__": 46
}, },
"_enabled": true, "_enabled": true,
"__prefab": { "__prefab": {
"__id__": 58 "__id__": 60
}, },
"light": { "light": {
"__uuid__": "319c7eb8-9826-48b6-81e4-82559dbf82a8", "__uuid__": "319c7eb8-9826-48b6-81e4-82559dbf82a8",
@@ -1282,6 +1312,28 @@
"__type__": "cc.CompPrefabInfo", "__type__": "cc.CompPrefabInfo",
"fileId": "90iY8Wt31JQZ1WhSvASP55" "fileId": "90iY8Wt31JQZ1WhSvASP55"
}, },
{
"__type__": "b7739lRGUtNE4v/zX96Czu/",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 46
},
"_enabled": true,
"__prefab": {
"__id__": 62
},
"light": {
"__uuid__": "319c7eb8-9826-48b6-81e4-82559dbf82a8",
"__expectedType__": "cc.Prefab"
},
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "7dN39sPBROo6Jp9JrguYbQ"
},
{ {
"__type__": "cc.PrefabInfo", "__type__": "cc.PrefabInfo",
"root": { "root": {
@@ -1305,7 +1357,7 @@
}, },
"_enabled": true, "_enabled": true,
"__prefab": { "__prefab": {
"__id__": 61 "__id__": 65
}, },
"_contentSize": { "_contentSize": {
"__type__": "cc.Size", "__type__": "cc.Size",
@@ -1346,7 +1398,7 @@
}, },
"_enabled": true, "_enabled": true,
"__prefab": { "__prefab": {
"__id__": 64 "__id__": 68
}, },
"_contentSize": { "_contentSize": {
"__type__": "cc.Size", "__type__": "cc.Size",
@@ -1374,7 +1426,7 @@
}, },
"_enabled": true, "_enabled": true,
"__prefab": { "__prefab": {
"__id__": 66 "__id__": 70
}, },
"camera": { "camera": {
"__id__": 3 "__id__": 3
@@ -1392,7 +1444,7 @@
"__id__": 41 "__id__": 41
}, },
"SkillLayer": { "SkillLayer": {
"__id__": 57 "__id__": 59
}, },
"isFollowPlayer": true, "isFollowPlayer": true,
"_id": "" "_id": ""
@@ -1411,7 +1463,7 @@
}, },
"_enabled": true, "_enabled": true,
"__prefab": { "__prefab": {
"__id__": 68 "__id__": 72
}, },
"_id": "" "_id": ""
}, },
@@ -1419,6 +1471,43 @@
"__type__": "cc.CompPrefabInfo", "__type__": "cc.CompPrefabInfo",
"fileId": "7eqXnRa8JJN6SutHuRICj9" "fileId": "7eqXnRa8JJN6SutHuRICj9"
}, },
{
"__type__": "c0f2fdqfBtOjKCjsgH1qG9+",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 6
},
"_enabled": true,
"__prefab": {
"__id__": 74
},
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "eanjJqiNdFCbYjTOIs36JC"
},
{
"__type__": "b7739lRGUtNE4v/zX96Czu/",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 6
},
"_enabled": true,
"__prefab": {
"__id__": 76
},
"light": null,
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "5fhe2hAPlMUbqe7oghUpNM"
},
{ {
"__type__": "cc.PrefabInfo", "__type__": "cc.PrefabInfo",
"root": { "root": {
@@ -1442,7 +1531,7 @@
}, },
"_enabled": true, "_enabled": true,
"__prefab": { "__prefab": {
"__id__": 71 "__id__": 79
}, },
"_contentSize": { "_contentSize": {
"__type__": "cc.Size", "__type__": "cc.Size",
@@ -1470,7 +1559,7 @@
}, },
"_enabled": true, "_enabled": true,
"__prefab": { "__prefab": {
"__id__": 73 "__id__": 81
}, },
"_cameraComponent": { "_cameraComponent": {
"__id__": 3 "__id__": 3
@@ -1492,7 +1581,7 @@
}, },
"_enabled": true, "_enabled": true,
"__prefab": { "__prefab": {
"__id__": 75 "__id__": 83
}, },
"_alignFlags": 45, "_alignFlags": 45,
"_target": null, "_target": null,
@@ -1531,7 +1620,7 @@
"targetOverrides": null, "targetOverrides": null,
"nestedPrefabInstanceRoots": [ "nestedPrefabInstanceRoots": [
{ {
"__id__": 45 "__id__": 47
} }
] ]
} }

View File

@@ -54,7 +54,7 @@ export class SingletonModuleComp extends ecs.Comp {
level:1, level:1,
level_max:4, level_max:4,
eid:0, eid:0,
ref_cost:2, ref_cost:1,
up_cost:4, up_cost:4,
}, },
hp: { hp: {
@@ -66,8 +66,8 @@ export class SingletonModuleComp extends ecs.Comp {
max: 30 max: 30
}, },
gold: { gold: {
min: 3, min: 20,
max: 3, max: 20,
max_limit:10, max_limit:10,
time:0, time:0,
cd:10, cd:10,

View File

@@ -9,11 +9,11 @@ export const CardType = {
2: "后排", 2: "后排",
} }
export const CardList={ export const CardList={
1:[1101,1102,1201,1202,1301,1302,], 1:[{uuid:1101,type:1},{uuid:1102,type:1},{uuid:1201,type:1},{uuid:1202,type:1},{uuid:1301,type:1},{uuid:1302,type:1},{uuid:1001,type:2}],
2:[2101,2102,2201,2202,2301,2302,], 2:[{uuid:2101,type:1},{uuid:2102,type:1},{uuid:2201,type:1},{uuid:2202,type:1},{uuid:2301,type:1},{uuid:2302,type:1},],
3:[3101,3102,3201,3202,3301,3302,], 3:[{uuid:3101,type:1},{uuid:3102,type:1},{uuid:3201,type:1},{uuid:3202,type:1},{uuid:3301,type:1},{uuid:3302,type:1},],
4:[4101,4102,4201,4202,4301,4302,], 4:[{uuid:4101,type:1},{uuid:4102,type:1},{uuid:4201,type:1},{uuid:4202,type:1},{uuid:4301,type:1},{uuid:4302,type:1},],
5:[5001,5002,5003,5004], 5:[{uuid:5001,type:1},{uuid:5002,type:1},{uuid:5003,type:1},{uuid:5004,type:1}],
// 1:[1101,1102,1103,1104,1105,1106,1201,1202,1203,1204,1205,1301,1302,1303,1304,], // 1:[1101,1102,1103,1104,1105,1106,1201,1202,1203,1204,1205,1301,1302,1303,1304,],
// 2:[2101,2102,2103,2104,2105,2201,2202,2203,2204,2301,2302,2303,2304,2305,], // 2:[2101,2102,2103,2104,2105,2201,2202,2203,2204,2301,2302,2303,2304,2305,],
// 3:[3101,3102,3103,3104,3201,3202,3203,3204,3205,3301,3302,3303,3304,], // 3:[3101,3102,3103,3104,3201,3202,3203,3204,3205,3301,3302,3303,3304,],
@@ -29,6 +29,11 @@ export const HeroSet ={
}, },
} }
export const SkillSet={
1001:{uuid: 1001,path: "1001",type: 1,level: 1,name: "火球术",atk: 4,hp: 8,atk_cd: 2,power: 50,speed: 80,}
}
export const CardSet = { export const CardSet = {
1101:{uuid: 1101,path: "1101",type: 1,level: 1,name: "守护犬",atk: 4,hp: 8,atk_cd: 2,power: 50,speed: 80,skill: "base",max_skill: "base",int1: null,int2: null,dps: 2,word: "守护", info: "自身护盾",atktype: "攻击型", mon: "狗"}, 1101:{uuid: 1101,path: "1101",type: 1,level: 1,name: "守护犬",atk: 4,hp: 8,atk_cd: 2,power: 50,speed: 80,skill: "base",max_skill: "base",int1: null,int2: null,dps: 2,word: "守护", info: "自身护盾",atktype: "攻击型", mon: "狗"},

View File

@@ -1,15 +1,5 @@
export const MissionNum = 3 export const MissionNum = 3
export const Mission= { export const MonsetList = {
// 1:[1101,1102,1201,1202,1301,1302,],
// 2:[2101,2102,2201,2202,2301,2302,],
// 3:[3101,3102,3201,3202,3301,3302,],
// 4:[4101,4102,4201,4202,4301,4302,],
// 5:[5001,5002,5003,5004],
// 1:[1101,1102,1103,1104,1105,1106,1201,1202,1203,1204,1205,1301,1302,1303,1304,],
// 2:[2101,2102,2103,2104,2105,2201,2202,2203,2204,2301,2302,2303,2304,2305,],
// 3:[3101,3102,3103,3104,3201,3202,3203,3204,3205,3301,3302,3303,3304,],
// 4:[4101,4102,4103,4104,4201,4202,4203,4204,4301,4302,4303,4304,],
// 5:[5001,5002,5003,5004],
1:{ 1:{
1:[1101,1102,], 1:[1101,1102,],
2:[1101,1102,2101,2102,], 2:[1101,1102,2101,2102,],
@@ -33,3 +23,42 @@ export const Mission= {
}, },
} }
export const MissionSet = {
1:{
lv1_num:10,
lv2_num:10,
lv3_num:10,
lv4_num:10,
lv5_num:10,
lv1_skill_num:10,
lv2_skill_num:10,
lv3_skill_num:10,
lv4_skill_num:10,
lv5_skill_num:10,
},
2:{
lv1_num:10,
lv2_num:10,
lv3_num:10,
lv4_num:10,
lv5_num:10,
lv1_skill_num:10,
lv2_skill_num:10,
lv3_skill_num:10,
lv4_skill_num:10,
lv5_skill_num:10,
},
3:{
lv1_num:10,
lv2_num:10,
lv3_num:10,
lv4_num:10,
lv5_num:10,
lv1_skill_num:10,
lv2_skill_num:10,
lv3_skill_num:10,
lv4_skill_num:10,
lv5_skill_num:10,
}
}

View File

@@ -79,7 +79,7 @@ export class CardControllerComp extends CCComp {
lists.forEach(element => { lists.forEach(element => {
let card = ecs.getEntity<HeroCard>(HeroCard); let card = ecs.getEntity<HeroCard>(HeroCard);
let pos = v3(x,y) let pos = v3(x,y)
card.load(pos,element[0],cards_node,1); card.load(pos,element[0].uuid,cards_node,element[0].type);
x=x+142 x=x+142
}); });
this.in_load = false; this.in_load = false;

View File

@@ -0,0 +1,62 @@
import { _decorator ,Vec3,v3} from "cc";
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
import { Timer } from "../../../../extensions/oops-plugin-framework/assets/core/common/timer/Timer";
import { Monster } from "../monster/Monster";
import { BoxSet } from "../common/config/BoxSet";
import { smc } from "../common/SingletonModuleComp";
import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
import { MapViewScene } from "./view/MapViewScene";
const { ccclass, property } = _decorator;
/** 视图层对象 */
@ccclass('MapMonsterComp')
@ecs.register('MapMonster', false)
export class MapMonsterComp extends CCComp {
scene: MapViewScene = null;
current_map: any;
private monster_refresh_rtimer: Timer = new Timer(1);
async onLoad(){
// 监听全局事件
oops.message.on("do_add_monster", this.on_do_add_monster, this);
}
protected update(dt: number): void {
if (this.monster_refresh_rtimer.update(dt)) {
// 刷新怪物定时器
this.monster_refresh()
}
// if (this.game_timer.update(dt)) {
// smc.vm_data.game.g_time += 1;
// }
// this.shuaxin(dt)
}
monster_refresh(){
if(smc.monsters.length > 0 ){
this.addMonster(smc.monsters[0].uuid)
}
}
private addMonster(uuid:number=1101) {
let monster = ecs.getEntity<Monster>(Monster);
let pos:Vec3 = v3(BoxSet.MONSTER_START,BoxSet.GAME_LINE)
let camp = -1
monster.load(pos,camp,uuid);
smc.monsters.splice(0,1)
}
private on_do_add_monster(event: string, args: any) {
// this.addMonster(args.uuid)
}
/** 视图层逻辑代码分离演示 */
start() {
this.scene = this.getComponent(MapViewScene);
}
/** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */
reset() {
this.node.destroy();
}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "c0f2f76a-7c1b-4e8c-a0a3-b201f5a86f7e",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -0,0 +1,53 @@
import { _decorator ,Prefab,instantiate,Node} from "cc";
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
import { BoxSet } from "../common/config/BoxSet";
const { ccclass, property } = _decorator;
/** 视图层对象 */
@ccclass('MapSkillComp')
@ecs.register('MapSkill', false)
export class MapSkillComp extends CCComp {
@property(Prefab)
light: Prefab = null;
onLoad(){
oops.message.on("monster_load", this.doMonsterLoad, this);
oops.message.on("hero_load", this.doHeroLoad, this);
oops.message.on("do_use_skill", this.doSkill, this);
}
doSkill(){
// console.log("doSkill")
}
doMonsterLoad(){
// const light = instantiate(this.light);
// light.setPosition(300,-30,0);
// this.node.addChild(light);
}
doHeroLoad(){
// console.log(this.light)
// const light = instantiate(this.light);
// light.setPosition(BoxSet.HERO_START,BoxSet.GAME_LINE,0);
// this.node.addChild(light);
}
/** 视图层逻辑代码分离演示 */
start() {
// var entity = this.ent as ecs.Entity; // ecs.Entity 可转为当前模块的具体实体对象
// this.on(ModuleEvent.Cmd, this.onHandler, this);
}
/** 全局消息逻辑处理 */
// private onHandler(event: string, args: any) {
// switch (event) {
// case ModuleEvent.Cmd:
// break;
// }
// }
/** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */
reset() {
this.node.destroy();
}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "b7739951-194b-4d13-8bff-cd7f7a0b3bbf",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -21,24 +21,18 @@ export class MapViewComp extends CCComp {
scene: MapViewScene = null!; scene: MapViewScene = null!;
current_map: any; current_map: any;
private game_timer: Timer = new Timer(1); private game_timer: Timer = new Timer(1);
private monster_refresh_rtimer: Timer = new Timer(3);
private mapLoaded() { private mapLoaded() {
} }
async onLoad(){ async onLoad(){
// 监听全局事件 // 监听全局事件
oops.message.on("do_add_monster", this.on_do_add_monster, this);
oops.message.on("do_add_hero", this.on_do_add_hero, this); oops.message.on("do_add_hero", this.on_do_add_hero, this);
} }
private on_do_add_monster(event: string, args: any) {
this.addMonster()
}
/**监听do_add_hero 添加hero,通过uuid */ /**监听do_add_hero 添加hero,通过uuid */
private on_do_add_hero(event: string, args: any) { private on_do_add_hero(event: string, args: any) {
console.log("do_add_hero",args.uuid) // console.log("do_add_hero",args.uuid)
this.addHero(args.uuid) this.addHero(args.uuid)
} }
reset(): void { reset(): void {
@@ -54,22 +48,15 @@ export class MapViewComp extends CCComp {
// console.log("heros",heros) // console.log("heros",heros)
} }
protected update(dt: number): void { protected update(dt: number): void {
if (this.monster_refresh_rtimer.update(dt)) {
// 刷新怪物定时器 // if (this.game_timer.update(dt)) {
this.monster_refresh() // smc.vm_data.game.g_time += 1;
} // }
if (this.game_timer.update(dt)) {
smc.vm_data.game.g_time += 1;
}
// this.shuaxin(dt) // this.shuaxin(dt)
this.gold_add(dt) this.gold_add(dt)
} }
// 刷新怪物 // 刷新怪物
monster_refresh(){
if(smc.monsters.length > 0 ){
this.addMonster(smc.monsters[0].uuid)
}
}
gold_add(dt: number) { gold_add(dt: number) {
smc.vm_data.gold.time += dt; smc.vm_data.gold.time += dt;
if (smc.vm_data.gold.time >= smc.vm_data.gold.cd) { if (smc.vm_data.gold.time >= smc.vm_data.gold.cd) {
@@ -94,13 +81,6 @@ export class MapViewComp extends CCComp {
let camp = 1 let camp = 1
hero.load(pos,camp,uuid); hero.load(pos,camp,uuid);
} }
private addMonster(uuid:number=1001) {
this.scene.node.active = true
let monster = ecs.getEntity<Monster>(Monster);
let pos:Vec3 = v3(BoxSet.MONSTER_START,BoxSet.GAME_LINE)
let camp = -1
monster.load(pos,camp,uuid);
smc.monsters.splice(0,1)
}
} }

View File

@@ -22,16 +22,20 @@ export default class SkillLayer extends Component {
@property(Prefab) @property(Prefab)
light: Prefab = null; light: Prefab = null;
onLoad(){ onLoad(){
oops.message.on("monster_load", this.onMonsterLoaded, this); oops.message.on("monster_load", this.doMonsterLoad, this);
oops.message.on("hero_load", this.onHeroLoaded, this); oops.message.on("hero_load", this.doHeroLoad, this);
oops.message.on("do_use_skill", this.doSkill, this);
} }
onMonsterLoaded(){ doSkill(){
// console.log("doSkill")
}
doMonsterLoad(){
// const light = instantiate(this.light); // const light = instantiate(this.light);
// light.setPosition(300,-30,0); // light.setPosition(300,-30,0);
// this.node.addChild(light); // this.node.addChild(light);
} }
onHeroLoaded(){ doHeroLoad(){
const light = instantiate(this.light); const light = instantiate(this.light);
light.setPosition(BoxSet.HERO_START,BoxSet.GAME_LINE,0); light.setPosition(BoxSet.HERO_START,BoxSet.GAME_LINE,0);
this.node.addChild(light); this.node.addChild(light);

View File

@@ -52,7 +52,7 @@ export class Hero extends ecs.Entity {
resources.load(url, SpriteAtlas, (err: any, atlas) => { resources.load(url, SpriteAtlas, (err: any, atlas) => {
const sprite = node.getChildByName("avatar").getChildByName("TNode").getChildByName("bb").getComponent(Sprite); const sprite = node.getChildByName("avatar").getChildByName("TNode").getChildByName("bb").getComponent(Sprite);
sprite.spriteFrame = atlas.getSpriteFrame(CardSet[uuid].path); sprite.spriteFrame = atlas.getSpriteFrame(smc.heros[uuid].path);
}); });
this.hero_init(uuid,node) this.hero_init(uuid,node)
oops.message.dispatchEvent("hero_load",this) oops.message.dispatchEvent("hero_load",this)
@@ -61,22 +61,22 @@ export class Hero extends ecs.Entity {
hero_init(uuid:number=1001,node:Node,pos:Vec3=v3(0,0,0)){ hero_init(uuid:number=1001,node:Node,pos:Vec3=v3(0,0,0)){
var mv = node.getComponent(MonsterViewComp)!; var mv = node.getComponent(MonsterViewComp)!;
mv.hero_uuid=uuid; mv.hero_uuid=uuid;
mv.speed =mv.ospeed = CardSet[uuid].speed; mv.speed =mv.ospeed = smc.heros[uuid].speed;
mv.hero_name= CardSet[uuid].name; mv.hero_name= smc.heros[uuid].name;
mv.hp= mv.hp_max = CardSet[uuid].hp; mv.hp= mv.hp_max = smc.heros[uuid].hp;
mv.level = CardSet[uuid].level; mv.level = smc.heros[uuid].level;
mv.atk = CardSet[uuid].atk; mv.atk = smc.heros[uuid].atk;
mv.atk_cd = CardSet[uuid].atk_cd; mv.atk_cd = smc.heros[uuid].atk_cd;
mv.power = CardSet[uuid].power; mv.power = smc.heros[uuid].power;
mv.type = CardSet[uuid].type; mv.type = smc.heros[uuid].type;
mv.Tpos = v3(0,0,0); mv.Tpos = v3(0,0,0);
mv.camp = 1; mv.camp = 1;
mv.change_name(CardSet[uuid].name,1) mv.change_name(smc.heros[uuid].name,1)
this.add(mv); this.add(mv);
this.push_monsters_in(uuid,mv.ent.eid) this.push_monsters_in(uuid,mv.ent.eid)
} }
push_monsters_in(uuid:number=1001,eid:number=0){ push_monsters_in(uuid:number=1001,eid:number=0){
smc.monsters_in.push({name:CardSet[uuid].name,eid:eid}) smc.monsters_in.push({name:smc.heros[uuid].name,eid:eid})
} }

View File

@@ -12,7 +12,7 @@ import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ec
import { UIID } from "../common/config/GameUIConfig"; import { UIID } from "../common/config/GameUIConfig";
import { smc } from "../common/SingletonModuleComp"; import { smc } from "../common/SingletonModuleComp";
import{HeroCardViewComp} from "./HeroCardViewComp"; import{HeroCardViewComp} from "./HeroCardViewComp";
import { CardSet } from "../common/config/CardSet"; import { CardSet ,SkillSet} from "../common/config/CardSet";
/** 角色实体 */ /** 角色实体 */
@ecs.register(`HeroCard`) @ecs.register(`HeroCard`)
export class HeroCard extends ecs.Entity { export class HeroCard extends ecs.Entity {
@@ -32,20 +32,28 @@ export class HeroCard extends ecs.Entity {
/** 加载角色 */ /** 加载角色 */
load(pos: Vec3 = Vec3.ZERO,uuid:number=1001,parent:Node,type:number=1) { load(pos: Vec3 = Vec3.ZERO,uuid:number=1001,parent:Node,type:number=1) {
// console.log("load hero",uuid); let path: string;
// var path = "game/monster/"+prefab_path; let url: string;
switch(type){ let pathName: string;
let name: string;
let level: number;
switch (type) {
case 1: case 1:
var path = "game/heros/hero_card"; path = "game/heros/hero_card";
url = "game/heros/heros";
({ path: pathName, name, level } = smc.heros[uuid]);
break; break;
case 2: case 2:
var path = "game/heros/skill_card"; path = "game/heros/skill_card";
url = "game/heros/skill";
({ path: pathName, name, level } = SkillSet[uuid]);
break; break;
case 3: case 3:
var path = "game/heros/item_card";
break;
default: default:
var path = "game/heros/hero_card"; path = "game/heros/hero_card";
url = "game/heros/heros";
({ path: pathName, name, level } = smc.heros[uuid]);
} }
@@ -55,20 +63,19 @@ export class HeroCard extends ecs.Entity {
// node.getChildByName("avatar").setScale(node.getChildByName("avatar").scale.x*camp, node.getChildByName("avatar").scale.y, node.getChildByName("avatar").scale.z); // node.getChildByName("avatar").setScale(node.getChildByName("avatar").scale.x*camp, node.getChildByName("avatar").scale.y, node.getChildByName("avatar").scale.z);
node.setPosition(pos) node.setPosition(pos)
const url = 'game/heros/heros';
resources.load(url, SpriteAtlas, (err: any, atlas) => { resources.load(url, SpriteAtlas, (err: any, atlas) => {
const sprite = node.getChildByName("hero").getComponent(Sprite); const sprite = node.getChildByName("hero").getComponent(Sprite);
sprite.spriteFrame = atlas.getSpriteFrame(CardSet[uuid].path); sprite.spriteFrame = atlas.getSpriteFrame(pathName);
}); });
var hcv = node.getComponent(HeroCardViewComp)!; var hcv = node.getComponent(HeroCardViewComp)!;
hcv.card_name=CardSet[uuid].name hcv.card_name=name
hcv.card_uid=uuid hcv.card_uid=uuid
hcv.card_type=type
hcv.card_level=level
this.add(hcv); this.add(hcv);
} }
} }

View File

@@ -13,11 +13,12 @@ const { ccclass, property } = _decorator;
@ecs.register('HeroCardView', false) @ecs.register('HeroCardView', false)
export class HeroCardViewComp extends CCComp { export class HeroCardViewComp extends CCComp {
card_name:string = "hero_card"; card_name:string = "hero_card";
card_type:string = "hero";
card_uid:number = 1000; card_uid:number = 1000;
in_destroy:boolean = false; in_destroy:boolean = false;
pos_x:number = 0; pos_x:number = 0;
pos_y:number = 0; pos_y:number = 0;
card_type:number = 1;
card_level:number = 1;
protected onLoad(): void { protected onLoad(): void {
this.node.on(NodeEventType.TOUCH_START, this.onTouchMove, this); this.node.on(NodeEventType.TOUCH_START, this.onTouchMove, this);
@@ -31,7 +32,7 @@ export class HeroCardViewComp extends CCComp {
start() { start() {
this.pos_x=this.node.position.x; this.pos_x=this.node.position.x;
this.pos_y=this.node.position.y; this.pos_y=this.node.position.y;
this.node.getChildByName("level").getChildByName("level").getComponent(Label).string = CardSet[this.card_uid].level.toString(); this.node.getChildByName("level").getChildByName("level").getComponent(Label).string = this.card_level.toString();
this.node.getChildByName("name").getComponent(Label).string = this.card_name this.node.getChildByName("name").getComponent(Label).string = this.card_name
} }
@@ -97,14 +98,30 @@ export class HeroCardViewComp extends CCComp {
} }
use_card(){ use_card(){
if(smc.vm_data.gold.min >= smc.vm_data.cards.ref_cost){ if(smc.vm_data.gold.min >= this.card_level){
this.in_destroy = true; this.in_destroy = true;
oops.message.dispatchEvent("do_add_hero",{uuid:this.card_uid}) this.do_use_card()
this.ent.destroy(); this.ent.destroy();
smc.vm_data.gold.min -= smc.vm_data.cards.ref_cost; smc.vm_data.gold.min -= this.card_level;
}else{ }else{
oops.gui.toast("金币不够"); oops.gui.toast("金币不够");
this.node.setPosition(this.pos_x,this.pos_y); this.node.setPosition(this.pos_x,this.pos_y);
} }
} }
do_use_card(){
switch (this.card_type) { // 添加括号并修正语法
case 1:
oops.message.dispatchEvent("do_add_hero", { uuid: this.card_uid }); // 添加分号
break;
case 2:
oops.message.dispatchEvent("do_use_skill", { uuid: this.card_uid }); // 添加分号
// console.log("do_use_skill",this.card_uid)
break;
default:
break;
}
}
} }

View File

@@ -52,29 +52,29 @@ export class Monster extends ecs.Entity {
resources.load(url, SpriteAtlas, (err: any, atlas) => { resources.load(url, SpriteAtlas, (err: any, atlas) => {
const sprite = node.getChildByName("avatar").getChildByName("TNode").getChildByName("bb").getComponent(Sprite); const sprite = node.getChildByName("avatar").getChildByName("TNode").getChildByName("bb").getComponent(Sprite);
sprite.spriteFrame = atlas.getSpriteFrame(CardSet[uuid].path); sprite.spriteFrame = atlas.getSpriteFrame(smc.heros[uuid].path);
}); });
this.hero_init(uuid,node) this.hero_init(uuid,node)
oops.message.dispatchEvent("monster_load",this) oops.message.dispatchEvent("monster_load",this)
} }
hero_init(uuid:number=1001,node:Node,pos:Vec3=v3(0,0,0)){ hero_init(uuid:number=1001,node:Node,pos:Vec3=v3(0,0,0)){
var mv = node.getComponent(MonsterViewComp)!; var mv = node.getComponent(MonsterViewComp)!;
mv.speed =mv.ospeed = CardSet[uuid].speed; mv.speed =mv.ospeed = smc.heros[uuid].speed;
mv.hero_name= CardSet[uuid].name; mv.hero_name= smc.heros[uuid].name;
mv.hp= mv.hp_max = CardSet[uuid].hp; mv.hp= mv.hp_max = smc.heros[uuid].hp;
mv.level = CardSet[uuid].level; mv.level = smc.heros[uuid].level;
mv.atk = CardSet[uuid].atk; mv.atk = smc.heros[uuid].atk;
mv.atk_cd = CardSet[uuid].atk_cd; mv.atk_cd = smc.heros[uuid].atk_cd;
mv.power = CardSet[uuid].power; mv.power = smc.heros[uuid].power;
mv.type = CardSet[uuid].type; mv.type = smc.heros[uuid].type;
mv.camp = -1; mv.camp = -1;
mv.Tpos = v3(0,0,0); mv.Tpos = v3(0,0,0);
mv.change_name(CardSet[uuid].name,-1) mv.change_name(smc.heros[uuid].name,-1)
this.add(mv); this.add(mv);
this.push_monsters_in(uuid,mv.ent.eid) this.push_monsters_in(uuid,mv.ent.eid)
} }
push_monsters_in(uuid:number=1001,eid:number=0){ push_monsters_in(uuid:number=1001,eid:number=0){
smc.monsters_in.push({name:CardSet[uuid].name,eid:eid}) smc.monsters_in.push({name:smc.heros[uuid].name,eid:eid})
} }
} }