|
@@ -3,6 +3,7 @@ import { ConfigConst, EConfigConst } from "../cfg/ConfigDef";
|
|
|
import { ConfigMgr } from "../cfg/configMgr";
|
|
|
import { NestItem } from "../cfg/nestItem";
|
|
|
import { Utils } from "../common/utils";
|
|
|
+import { MonsterModel } from "../monster/monsterModel";
|
|
|
|
|
|
const patternArr = [
|
|
|
'monster',
|
|
@@ -53,8 +54,13 @@ export class NestPlay extends cc.Component {
|
|
|
monster: cc.Prefab;
|
|
|
aniClip: cc.AnimationClip[];
|
|
|
time: number;
|
|
|
+ pattern: any;
|
|
|
+ private _id: string;
|
|
|
+ private _level: number;
|
|
|
|
|
|
- async init(id: string){
|
|
|
+ async init(id: string, level: number){
|
|
|
+ this._id = id;
|
|
|
+ this._level = level;
|
|
|
|
|
|
let nestItem = ConfigMgr.inst.getCfgClassById<NestItem>(EConfigConst.nest, id, NestItem);
|
|
|
let shapeId = Utils.intDefault(nestItem.data.shape);
|
|
@@ -62,10 +68,10 @@ export class NestPlay extends cc.Component {
|
|
|
this.num = Utils.intDefault(nestItem.data.num, 1);
|
|
|
let delay = Utils.intDefault(nestItem.data.delay);
|
|
|
this.time = Utils.intDefault(nestItem.data.time) / 100;
|
|
|
-
|
|
|
let type = Utils.intDefault(nestItem.data.type, 1);
|
|
|
- let aniName = aniArr[type-1].map(v=>{return 'level/'+v});
|
|
|
+ this.pattern = Utils.strToJson(nestItem.data.pattern);
|
|
|
|
|
|
+ let aniName = aniArr[type-1].map(v=>{return 'level/'+v});
|
|
|
let posJson = Utils.pos2vec2(nestItem.data.pos);
|
|
|
this.node.setPosition(posJson);
|
|
|
this.aniClip = await ResMgr.inst.loadAniArr(aniName, this.node);
|
|
@@ -98,6 +104,31 @@ export class NestPlay extends cc.Component {
|
|
|
this.createMonster2();
|
|
|
}
|
|
|
|
|
|
+ setPattern(monsterNode: cc.Node){
|
|
|
+ let arr = [];
|
|
|
+ this.pattern.forEach(v => {
|
|
|
+ for (let index = 0; index < v[0]; index++) {
|
|
|
+ arr.push(v[1]);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ if(arr.length == 0){
|
|
|
+ cc.error('[nestPlay] [pattern] 配置空',`[nestId:${this._id}]`);
|
|
|
+ arr.push('1001');
|
|
|
+ }
|
|
|
+ let models = monsterNode.getComponentsInChildren(MonsterModel);
|
|
|
+ models.forEach((v, k)=>{
|
|
|
+ let id = '1001';
|
|
|
+ if(k < arr.length){
|
|
|
+ id = arr[k];
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ id = arr[arr.length-1];
|
|
|
+ }
|
|
|
+
|
|
|
+ v.init(id, this._level);
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
createMonster2(){
|
|
|
this.monsterCnt = 0;
|
|
|
for (let index = 0; index < this.num; index++) {
|
|
@@ -106,6 +137,9 @@ export class NestPlay extends cc.Component {
|
|
|
|
|
|
cc.log('[nestPlay] [create]',`[num:${this.monsterCnt} / ${this.num}]`);
|
|
|
let monsterNode = ResMgr.inst.createNode(this.monster, this.monsterNode);
|
|
|
+
|
|
|
+ this.setPattern(monsterNode);
|
|
|
+
|
|
|
let cnt = 0;
|
|
|
let callAni = ()=>{
|
|
|
|