假期修改

This commit is contained in:
2024-09-18 12:45:05 +08:00
parent 2095393757
commit cd0dc9fe7c
79 changed files with 7383 additions and 1449 deletions

View File

@@ -20,12 +20,12 @@ export class CardControllerComp extends CCComp {
touch_time:number = 0
in_touch:boolean = false
cards:any = {
1:{uuid:1101,type:1,lv:0,alive:false},
2:{uuid:1102,type:1,lv:0,alive:false},
3:{uuid:1103,type:1,lv:0,alive:false},
4:{uuid:1104,type:1,lv:0,alive:false},
5:{uuid:1105,type:1,lv:0,alive:false},
6:{uuid:1106,type:1,lv:0,alive:false},
1:{uuid:1101,type:1,lv:0,cost:0,alive:false},
2:{uuid:1102,type:1,lv:0,cost:0,alive:false},
3:{uuid:1103,type:1,lv:0,cost:0,alive:false},
4:{uuid:1104,type:1,lv:0,cost:0,alive:false},
5:{uuid:1105,type:1,lv:0,cost:0,alive:false},
6:{uuid:1106,type:1,lv:0,cost:0,alive:false},
}
protected onLoad(): void {
let card1 = this.node.getChildByName("cards").getChildByName("card1");
@@ -146,27 +146,18 @@ export class CardControllerComp extends CCComp {
// console.log("show_info",uuid)
let node =this.node.getChildByName("item_box")
if(type == 2){
smc.vm_data.item_box.info = SkillSet[uuid].info
smc.vm_data.item_box.name = SkillSet[uuid].name
smc.vm_data.item_box.skillcd = SkillSet[uuid].cd
smc.vm_data.item_box.skillsd = SkillSet[uuid].sd
smc.vm_data.item_box.atk = SkillSet[uuid].atk
smc.vm_data.item_box.hp = SkillSet[uuid].hp
smc.vm_data.item_box.info = smc.items[uuid].info
smc.vm_data.item_box.name = smc.items[uuid].name
smc.vm_data.item_box.skillcd = smc.items[uuid].cd
smc.vm_data.item_box.skillsd = smc.items[uuid].sd
smc.vm_data.item_box.atk = smc.items[uuid].atk
smc.vm_data.item_box.hp = smc.items[uuid].hp
smc.vm_data.item_box.shield = smc.items[uuid].shield
node.active=true
}
if(type == 3){
smc.vm_data.item_box.info = SkillSet[uuid].info
smc.vm_data.item_box.name = SkillSet[uuid].name
smc.vm_data.item_box.skillcd = SkillSet[uuid].cd
smc.vm_data.item_box.skillsd = SkillSet[uuid].sd
smc.vm_data.item_box.atk = SkillSet[uuid].atk
smc.vm_data.item_box.hp = SkillSet[uuid].hp
smc.vm_data.item_box.shield = SkillSet[uuid].shield
node.active=true
if(SkillSet[uuid].shield > 0){
if(smc.items[uuid].shield > 0){
node.getChildByName("data").getChildByName("shield").active=true
}
if(SkillSet[uuid].hp > 0){
if(smc.items[uuid].hp > 0){
node.getChildByName("data").getChildByName("hp").active=true
}
}
@@ -231,8 +222,9 @@ export class CardControllerComp extends CCComp {
load_cards() {
this.in_load = true
let card:any=null
for (let index = 1; index <= 4; index++) {
for (let index = 1; index <= 6; index++) {
card=RandomManager.instance.getRandomByObjectList(smc.cards, 1);
this.cards[index].uuid=card[0].uuid
this.cards[index].type=card[0].type
@@ -241,35 +233,15 @@ export class CardControllerComp extends CCComp {
let pathName: string = "";
let name: string = "";
let level: number = 0;
let cost: number = 0;
let { uuid, type } = card[0];
url = "game/hero/hero_icon";
({ uuid: pathName, name, level } = smc.heros[uuid]);
({ uuid: pathName, name, level ,cost} = smc.heros[uuid]);
this.cards[index].lv=level
this.cards[index].cost = cost
let node=this.node.getChildByName('cards').getChildByName('card'+index)
node.getChildByName('cost').getComponent(Label).string=level.toString()
node.getChildByName('name').getComponent(Label).string=name
// const sprite = node.getChildByName("item").getComponent(Sprite);
// console.log(this['card'+index],url,pathName,sprite)
resources.load(url, SpriteAtlas, (err: any, atlas) => {
const sprite = node.getChildByName("item").getComponent(Sprite);
sprite.spriteFrame = atlas.getSpriteFrame(pathName);
});
this.cards[index].alive=true
}
for (let index = 5; index <= 6; index++) {
card=RandomManager.instance.getRandomByObjectList(smc.items, 1);
this.cards[index].uuid=card[0].uuid
this.cards[index].type=card[0].type
let url: string = "";
let pathName: string = "";
let name: string = "";
let level: number = 0;
let { uuid, type } = card[0];
url = "game/heros/skill";
({ path: pathName, name, level } = smc.skills[uuid]);
this.cards[index].lv=level
let node=this.node.getChildByName('cards').getChildByName('card'+index)
node.getChildByName('cost').getComponent(Label).string=level.toString()
node.getChildByName('cost').getComponent(Label).string=cost.toString()
node.getChildByName('lv').getChildByName('lv').getComponent(Label).string=level.toString()
node.getChildByName('name').getComponent(Label).string=name
// const sprite = node.getChildByName("item").getComponent(Sprite);
// console.log(this['card'+index],url,pathName,sprite)
@@ -279,6 +251,29 @@ export class CardControllerComp extends CCComp {
});
this.cards[index].alive=true
}
// for (let index = 5; index <= 6; index++) {
// card=RandomManager.instance.getRandomByObjectList(smc.item_list, 1);
// this.cards[index].uuid=card[0].uuid
// this.cards[index].type=card[0].type
// let url: string = "";
// let pathName: string = "";
// let name: string = "";
// let level: number = 0;
// let { uuid, type } = card[0];
// url = "game/heros/skill";
// ({ path: pathName, name, level } = smc.items[uuid]);
// this.cards[index].lv=level
// let node=this.node.getChildByName('cards').getChildByName('card'+index)
// node.getChildByName('cost').getComponent(Label).string=level.toString()
// node.getChildByName('name').getComponent(Label).string=name
// // const sprite = node.getChildByName("item").getComponent(Sprite);
// // console.log(this['card'+index],url,pathName,sprite)
// resources.load(url, SpriteAtlas, (err: any, atlas) => {
// const sprite = node.getChildByName("item").getComponent(Sprite);
// sprite.spriteFrame = atlas.getSpriteFrame(pathName);
// });
// this.cards[index].alive=true
// }
// console.log("cards:",this.cards)
this.in_load = false
}
@@ -317,7 +312,7 @@ export class CardControllerComp extends CCComp {
// console.log("card_index:",index,"card_alive:",this.cards[index].alive)
return;
};
if(smc.vm_data.gold.min >= this.cards[index].lv){
if(smc.vm_data.gold.min >= this.cards[index].cost){
this.cards[index].alive=false
this.do_use_card(index)
}else{
@@ -327,18 +322,19 @@ export class CardControllerComp extends CCComp {
}
do_use_card(index:number){
this.cards[index].alive=false
smc.vm_data.gold.min -= this.cards[index].lv;
switch (this.cards[index].type) {
case 1:
oops.message.dispatchEvent("do_add_hero", { uuid: this.cards[index].uuid });
break;
case 2:
oops.message.dispatchEvent("do_use_skill", { uuid: this.cards[index].uuid });
break;
case 3:
oops.message.dispatchEvent("do_use_skill", { uuid: this.cards[index].uuid });
break;
}
smc.vm_data.gold.min -= this.cards[index].cost;
oops.message.dispatchEvent("do_add_hero", { uuid: this.cards[index].uuid });
// switch (this.cards[index].type) {
// case 1:
// oops.message.dispatchEvent("do_add_hero", { uuid: this.cards[index].uuid });
// break;
// case 2:
// oops.message.dispatchEvent("do_use_item", { uuid: this.cards[index].uuid });
// break;
// case 3:
// oops.message.dispatchEvent("do_use_item", { uuid: this.cards[index].uuid });
// break;
// }
this.remove_card(index)
}
protected update(dt: number): void {

View File

@@ -36,7 +36,9 @@ export class MapMonsterComp extends CCComp {
target_timer: Timer = new Timer(0.1);
setp_num:number = 5;
game_over:boolean = false;
start_ys:any[] = [100,50,0,-50,-100];
start_ys:any[] = [70,0,-70];
hero_start_ys:any[] = [35,-35];
onLoad(){
// 监听全局事件
oops.message.on("other_add_monster", this.on_other_add_monster, this);
@@ -95,11 +97,26 @@ export class MapMonsterComp extends CCComp {
private addHero(uuid:number=1001) {
let hero = ecs.getEntity<Hero>(Hero);
var scene = smc.map.MapView.scene;
let oy=RandomManager.instance.getRandomByObjectList(this.start_ys,1)
let pos:Vec3 = v3(BoxSet.HERO_START,BoxSet.GAME_LINE+oy[0]);
let oy=RandomManager.instance.getRandomInt(-70,70,1)
let pos = v3(0,0);
let less=0
let index =0
for(let i=0; i <= 11;i++){
if(smc.role_heros[i].eid==0){
pos=v3(smc.role_heros[i].x,smc.role_heros[i].y)
less += 1
index = i
smc.role_heros[i].eid=hero.eid
break
}
}
if(less <= 0){
oops.gui.toast("人数已满");
return false
}
let monster_layer = scene.entityLayer!.node!
let scale = 1
hero.load(pos,scale,uuid,monster_layer);
hero.load(pos,scale,uuid,monster_layer,index);
}
monster_refresh(){
if (this.setp_num <= 0){
@@ -107,8 +124,8 @@ export class MapMonsterComp extends CCComp {
}
let m:any = RandomManager.instance.getRandomByObjectList(this.mission_list[this.monster_level],1)
var scene = smc.map.MapView.scene;
let oy=RandomManager.instance.getRandomByObjectList(this.start_ys,1)
let pos:Vec3 = v3(BoxSet.MONSTER_START,BoxSet.GAME_LINE+oy[0])
let oy=RandomManager.instance.getRandomInt(-70,70,1)
let pos:Vec3 = v3(BoxSet.MONSTER_START,BoxSet.GAME_LINE+oy)
let monster_layer = scene.entityLayer!.node!
this.addMonster(m[0],monster_layer,pos)
this.setp_num -= 1

View File

@@ -4,7 +4,7 @@ import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/modu
import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
import { BoxSet } from "../common/config/BoxSet";
import { MapViewScene } from "./view/MapViewScene";
import { CSkill } from "../skills/CSkill";
import { smc } from "../common/SingletonModuleComp";
const { ccclass, property } = _decorator;
/** 视图层对象 */
@@ -18,6 +18,7 @@ export class MapSkillComp extends CCComp {
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);
oops.message.on("do_use_item", this.useItem, this);
}
doSkill(event: string, args: any){
this.addCSkill(args.uuid);
@@ -26,14 +27,7 @@ export class MapSkillComp extends CCComp {
}
addCSkill(uuid:number=1001,args:any=null){
let csk =ecs.getEntity<CSkill>(CSkill);
let scale = 1
let pos = v3(BoxSet.CSKILL_X*-scale,BoxSet.CSKILL_Y)
if(args){
pos = v3(args.x,args.y)
scale = args.scale
}
csk.load(pos,scale,uuid);
}
doMonsterLoad(){
const light = instantiate(this.light);
@@ -45,6 +39,18 @@ export class MapSkillComp extends CCComp {
light.setPosition(BoxSet.HERO_START,BoxSet.GAME_LINE,0);
this.node.addChild(light);
}
useItem(event: string, args: any){
console.log("useItem");
if(smc.items[args.uuid].hp > 0){ //buff加血
smc.Role.RoleView.add_hp(smc.items[args.uuid].hp)
}
if(smc.items[args.uuid].atk > 0){ //buff加攻击
smc.Role.RoleView.add_atk(smc.items[args.uuid].atk,smc.items[args.uuid].sd)
}
if(smc.items[args.uuid].shield > 0){ //buff护盾
smc.Role.RoleView.add_shield(smc.items[args.uuid].shield,smc.items[args.uuid].sd)
}
}
/** 视图层逻辑代码分离演示 */
start() {
// var entity = this.ent as ecs.Entity; // ecs.Entity 可转为当前模块的具体实体对象

View File

@@ -42,7 +42,7 @@ export class MapViewComp extends CCComp {
// smc.vm_data.game.g_time += 1;
// }
// this.shuaxin(dt)
this.gold_add(dt)
// this.gold_add(dt)
}
// 刷新怪物