背后载入

This commit is contained in:
2024-07-22 16:49:11 +08:00
parent e3b5f4bd05
commit 5c961f1f37
44 changed files with 1020 additions and 109 deletions

View File

@@ -3,7 +3,8 @@ import { ecs } from "../../../../../extensions/oops-plugin-framework/assets/libs
import { CCComp } from "../../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
import { smc } from "../../common/SingletonModuleComp";
import { Role } from "../../role/Role";
import { Monster } from "../../monster/monster";
import { Monster } from "../../monster/Monster";
import { Hero } from "../../heros/Hero";
// import MapRoadUtils from "./map/road/MapRoadUtils";
import { MapViewScene } from "./MapViewScene";
import { Timer } from "../../../../../extensions/oops-plugin-framework/assets/core/common/timer/Timer";
@@ -45,69 +46,28 @@ export class MapViewComp extends CCComp {
}
/** 添加玩家 */
private addHero(pos?: Vec3) {
private addHero() {
this.scene.node.active = true
// smc.monsters = ['war','magic','heath']
// smc.heros = ['war','magic','heath']
// if (smc.heros.length>0){
// let hero = ecs.getEntity<Role>(Role);
// let x = this.getRandomInt(-300, 0)
// hero.load(this.aStarToVec3(x+',60'), false, "magic");
// }
if (smc.heros.length>0){
let hero = ecs.getEntity<Hero>(Hero);
hero.load(v3(-360,-60), smc.heros[0].profession);
}
if (smc.monsters.length>0){
let monster = ecs.getEntity<Monster>(Monster);
let x = this.getRandomInt(-100, 100)
monster.load(this.aStarToVec3(x+',-60'));
monster.load(v3(360,-60));
smc.monsters.splice(0,1)
}
// smc.own.loadJoystick();
// smc.heros.forEach(element => {
// var heros$i = ecs.getEntity<Role>(Role);
// let i =1
// switch (element) {
// case "war":
// heros$i.load(this.aStarToVec3("-30,-60"), false);
// break;
// case "magic":
// heros$i.load(this.aStarToVec3("-140,-60"), false);
// break;
// case "heath":
// heros$i.load(this.aStarToVec3("-230,-60"), false)
// }
// i=i+1
// });
// let x = 1
// smc.monsters.forEach(element => {
// var monsters$x = ecs.getEntity<Role>(Role);
// switch (element) {
// case "war":
// monsters$x.load(this.aStarToVec3("30,-60"), true);
// break;
// case "magic":
// monsters$x.load(this.aStarToVec3("140,-60"), true);
// break;
// case "heath":
// monsters$x.load(this.aStarToVec3("230,-60"), true)
// }
// x=x+1
// });
}
private getRandomInt(min: number, max: number): number {
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min + 1)) + min;
}
private aStarToVec3(str: string) {
let array = str.split(",");
let x = parseInt(array[0]);
let y = parseInt(array[1]);
// let p = MapRoadUtils.instance.getPixelByDerect(x, y);
return v3(x, y);
}
}