完成新的 卡牌栏,完成物品使用,接下来需要英雄召唤

This commit is contained in:
2024-09-10 21:05:52 +08:00
parent 77a168628a
commit f286a2f2b2
16 changed files with 1513 additions and 6088 deletions

View File

@@ -43,7 +43,7 @@
"_lpos": { "_lpos": {
"__type__": "cc.Vec3", "__type__": "cc.Vec3",
"x": 0, "x": 0,
"y": 0, "y": -300,
"z": 0 "z": 0
}, },
"_lrot": { "_lrot": {
@@ -302,10 +302,10 @@
"a": 255 "a": 255
}, },
"_spriteFrame": { "_spriteFrame": {
"__uuid__": "f87f53f9-2fba-4a5b-968a-79a593311ab2@0b99e", "__uuid__": "f87f53f9-2fba-4a5b-968a-79a593311ab2@5a627",
"__expectedType__": "cc.SpriteFrame" "__expectedType__": "cc.SpriteFrame"
}, },
"_type": 0, "_type": 1,
"_fillType": 0, "_fillType": 0,
"_sizeMode": 0, "_sizeMode": 0,
"_fillCenter": { "_fillCenter": {

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,13 +0,0 @@
{
"ver": "1.1.50",
"importer": "prefab",
"imported": true,
"uuid": "3212dcd0-cfa0-4564-98c3-77c2fe68c9d8",
"files": [
".json"
],
"subMetas": {},
"userData": {
"syncNodeName": "hero_card"
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,13 +0,0 @@
{
"ver": "1.1.50",
"importer": "prefab",
"imported": true,
"uuid": "e92a4676-2650-4241-b991-c5f822a20372",
"files": [
".json"
],
"subMetas": {},
"userData": {
"syncNodeName": "item_card"
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,13 +0,0 @@
{
"ver": "1.1.50",
"importer": "prefab",
"imported": true,
"uuid": "da3a1b9b-4c7f-4944-9d22-75a0fc599d10",
"files": [
".json"
],
"subMetas": {},
"userData": {
"syncNodeName": "skill_card"
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 154 KiB

After

Width:  |  Height:  |  Size: 114 KiB

File diff suppressed because it is too large Load Diff

View File

@@ -20,14 +20,15 @@ export class CardControllerComp extends CCComp {
card_level:number = 1; card_level:number = 1;
in_load:boolean = false in_load:boolean = false
touch_time:number = 0
in_touch:boolean = false
cards:any = { cards:any = {
1:{uuid:1101,type:1,alive:false}, 1:{uuid:1101,type:1,lv:0,alive:false},
2:{uuid:1102,type:1,alive:false}, 2:{uuid:1102,type:1,lv:0,alive:false},
3:{uuid:1103,type:1,alive:false}, 3:{uuid:1103,type:1,lv:0,alive:false},
4:{uuid:1104,type:1,alive:false}, 4:{uuid:1104,type:1,lv:0,alive:false},
5:{uuid:1105,type:1,alive:false}, 5:{uuid:1105,type:1,lv:0,alive:false},
6:{uuid:1106,type:1,alive:false}, 6:{uuid:1106,type:1,lv:0,alive:false},
} }
protected onLoad(): void { protected onLoad(): void {
let card1 = this.node.getChildByName("cards").getChildByName("card1"); let card1 = this.node.getChildByName("cards").getChildByName("card1");
@@ -51,37 +52,19 @@ export class CardControllerComp extends CCComp {
card6.on(NodeEventType.TOUCH_START, this.touch6, this); card6.on(NodeEventType.TOUCH_START, this.touch6, this);
card6.on(NodeEventType.TOUCH_MOVE, this.touch6, this); card6.on(NodeEventType.TOUCH_MOVE, this.touch6, this);
card1.on(NodeEventType.TOUCH_END, this.onTouchEnd, this); card1.on(NodeEventType.TOUCH_END, this.end1, this);
card1.on(NodeEventType.TOUCH_CANCEL, this.onTouchEnd, this); card1.on(NodeEventType.TOUCH_CANCEL, this.end1, this);
card2.on(NodeEventType.TOUCH_END, this.onTouchEnd, this); card2.on(NodeEventType.TOUCH_END, this.end2, this);
card2.on(NodeEventType.TOUCH_CANCEL, this.onTouchEnd, this); card2.on(NodeEventType.TOUCH_CANCEL, this.end2, this);
card3.on(NodeEventType.TOUCH_END, this.onTouchEnd, this); card3.on(NodeEventType.TOUCH_END, this.end3, this);
card3.on(NodeEventType.TOUCH_CANCEL, this.onTouchEnd, this); card3.on(NodeEventType.TOUCH_CANCEL, this.end3, this);
card4.on(NodeEventType.TOUCH_END, this.onTouchEnd, this); card4.on(NodeEventType.TOUCH_END, this.end4, this);
card4.on(NodeEventType.TOUCH_CANCEL, this.onTouchEnd, this); card4.on(NodeEventType.TOUCH_CANCEL, this.end4, this);
card5.on(NodeEventType.TOUCH_END, this.onTouchEnd, this); card5.on(NodeEventType.TOUCH_END, this.end5, this);
card5.on(NodeEventType.TOUCH_CANCEL, this.onTouchEnd, this); card5.on(NodeEventType.TOUCH_CANCEL, this.end5, this);
card6.on(NodeEventType.TOUCH_END, this.onTouchEnd, this); card6.on(NodeEventType.TOUCH_END, this.end6, this);
card6.on(NodeEventType.TOUCH_CANCEL, this.onTouchEnd, this); card6.on(NodeEventType.TOUCH_CANCEL, this.end6, this);
const clickEventHandler = new EventHandler();
clickEventHandler.target = this.node; // 这个 node 节点是你的事件处理代码组件所属的节点
clickEventHandler.component = 'CardControllerComp';// 这个是脚本类名
clickEventHandler.handler = 'user_card';
clickEventHandler.customEventData = 'foobar';
const button1 = this.node.getChildByName('cards').getChildByName('card1').getComponent(Button);
const button2 = this.node.getChildByName('cards').getChildByName('card2').getComponent(Button);
const button3 = this.node.getChildByName('cards').getChildByName('card3').getComponent(Button);
const button4 = this.node.getChildByName('cards').getChildByName('card4').getComponent(Button);
const button5 = this.node.getChildByName('cards').getChildByName('card5').getComponent(Button);
const button6 = this.node.getChildByName('cards').getChildByName('card6').getComponent(Button);
button1.clickEvents.push(clickEventHandler);
button2.clickEvents.push(clickEventHandler);
button3.clickEvents.push(clickEventHandler);
button4.clickEvents.push(clickEventHandler);
button5.clickEvents.push(clickEventHandler);
button6.clickEvents.push(clickEventHandler);
} }
start() { start() {
@@ -99,27 +82,81 @@ export class CardControllerComp extends CCComp {
// } // }
touch1(event: EventTouch) { touch1(event: EventTouch) {
console.log("touch 1"); console.log("touch 1");
this.in_touch=true
if(this.in_load)return
if(!this.cards[1].alive)return
this.show_info(this.cards[1].uuid,this.cards[1].type)
} }
touch2(event: EventTouch) { touch2(event: EventTouch) {
console.log("touch 2"); console.log("touch 2");
this.in_touch=true
if(this.in_load)return
if(!this.cards[2].alive)return
this.show_info(this.cards[2].uuid,this.cards[2].type)
} }
touch3(event: EventTouch) { touch3(event: EventTouch) {
console.log("touch 3"); console.log("touch 3");
this.in_touch=true
if(this.in_load)return
if(!this.cards[3].alive)return
this.show_info(this.cards[3].uuid,this.cards[3].type)
} }
touch4(event: EventTouch) { touch4(event: EventTouch) {
console.log("touch 4"); console.log("touch 4");
this.in_touch=true
if(this.in_load)return
if(!this.cards[4].alive)return
this.show_info(this.cards[4].uuid,this.cards[4].type)
} }
touch5(event: EventTouch) { touch5(event: EventTouch) {
console.log("touch 5"); console.log("touch 5");
this.in_touch=true
if(this.in_load)return
if(!this.cards[5].alive)return
this.show_info(this.cards[5].uuid,this.cards[5].type)
} }
touch6(event: EventTouch) { touch6(event: EventTouch) {
console.log("touch 6"); console.log("touch 6");
this.in_touch=true
if(this.in_load)return
if(!this.cards[6].alive)return
this.show_info(this.cards[6].uuid,this.cards[6].type)
} }
end1(event: EventTouch) {
console.log("end1 1");
this.onTouchEnd(1)
}
end2(event: EventTouch) {
console.log("end2 2");
this.onTouchEnd(2)
}
end3(event: EventTouch) {
console.log("end3 3");
this.onTouchEnd(3)
}
end4(event: EventTouch) {
console.log("end4 4");
this.onTouchEnd(4)
}
end5(event: EventTouch) {
console.log("end5 5");
this.onTouchEnd(5)
}
end6(event: EventTouch) {
console.log("end6 6");
this.onTouchEnd(6)
}
show_info(uuid:number,type:number){ show_info(uuid:number,type:number){
console.log("show_info",uuid) console.log("show_info",uuid)
let node =this.node.getChildByName("item_box") let node =this.node.getChildByName("item_box")
@@ -150,7 +187,12 @@ export class CardControllerComp extends CCComp {
} }
} }
} }
onTouchEnd(){ onTouchEnd(index:number){
if(this.touch_time < 0.2){
this.use_card(index)
}
this.in_touch=false
this.touch_time = 0
let node = this.node.getChildByName("item_box") let node = this.node.getChildByName("item_box")
node.active=false node.active=false
node.getChildByName("data").getChildByName("shield").active=false node.getChildByName("data").getChildByName("shield").active=false
@@ -208,6 +250,7 @@ export class CardControllerComp extends CCComp {
card=RandomManager.instance.getRandomByObjectList(CardList, 1); card=RandomManager.instance.getRandomByObjectList(CardList, 1);
this.cards[index].uuid=card[0].uuid this.cards[index].uuid=card[0].uuid
this.cards[index].type=card[0].type this.cards[index].type=card[0].type
let url: string = ""; let url: string = "";
let pathName: string = ""; let pathName: string = "";
let name: string = ""; let name: string = "";
@@ -227,6 +270,8 @@ export class CardControllerComp extends CCComp {
url = "game/heros/skill"; url = "game/heros/skill";
({ path: pathName, name, level } = smc.skills[uuid]); ({ path: pathName, name, level } = smc.skills[uuid]);
} }
this.cards[index].lv=level
console.log("load_cards:",url,pathName,name,level)
let node=this.node.getChildByName('cards').getChildByName('card'+index) let node=this.node.getChildByName('cards').getChildByName('card'+index)
node.getChildByName('cost').getComponent(Label).string=level.toString() node.getChildByName('cost').getComponent(Label).string=level.toString()
node.getChildByName('name').getComponent(Label).string=name node.getChildByName('name').getComponent(Label).string=name
@@ -241,14 +286,28 @@ export class CardControllerComp extends CCComp {
// console.log("cards:",this.cards) // console.log("cards:",this.cards)
this.in_load = false this.in_load = false
} }
load_card(){ remove_card(index:number){
this.cards[index].alive=false
this.cards[index].uuid=0
this.cards[index].type=0
this.cards[index].lv=0
let url: string = "gui/gui";
let pathName: string = "129";
let node=this.node.getChildByName('cards').getChildByName('card'+index)
node.getChildByName('cost').getComponent(Label).string=""
node.getChildByName('name').getComponent(Label).string=""
// 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);
});
} }
use_card(event:Event,index: number){ use_card(index: number){
this.cards[index].alive=false
this.check_card(index) this.check_card(index)
console.log("cards:",this.cards) // console.log("cards:",this.cards)
} }
check_card(index:number){ check_card(index:number){
let heros = ecs.query(ecs.allOf(HeroModelComp)) let heros = ecs.query(ecs.allOf(HeroModelComp))
@@ -258,16 +317,21 @@ export class CardControllerComp extends CCComp {
oops.gui.toast("英雄数量达到上限"); oops.gui.toast("英雄数量达到上限");
return; return;
} }
if(smc.vm_data.gold.min >= this.card_level){ if(!this.cards[index].alive) {
// console.log("card_index:",index,"card_alive:",this.cards[index].alive)
return;
};
if(smc.vm_data.gold.min >= this.cards[index].lv){
this.cards[index].alive=false this.cards[index].alive=false
this.do_use_card(index) this.do_use_card(index)
smc.vm_data.gold.min -= this.card_level;
}else{ }else{
oops.gui.toast("金币不够"); oops.gui.toast("金币不够");
} }
} }
do_use_card(index:number){ do_use_card(index:number){
this.cards[index].alive=false
smc.vm_data.gold.min -= this.cards[index].lv;
switch (this.cards[index].type) { switch (this.cards[index].type) {
case 1: case 1:
oops.message.dispatchEvent("do_add_hero", { uuid: this.cards[index].uuid }); oops.message.dispatchEvent("do_add_hero", { uuid: this.cards[index].uuid });
@@ -278,13 +342,14 @@ export class CardControllerComp extends CCComp {
case 3: case 3:
oops.message.dispatchEvent("do_use_skill", { uuid: this.cards[index].uuid }); oops.message.dispatchEvent("do_use_skill", { uuid: this.cards[index].uuid });
break; break;
default:
break;
} }
this.remove_card(index)
} }
protected update(dt: number): void { protected update(dt: number): void {
this.shuaxin(dt) this.shuaxin(dt)
if(this.in_touch){
this.touch_time+=dt
}
} }
get_card_list(){ get_card_list(){

View File

@@ -99,7 +99,7 @@ export class CSkillComp extends CCComp {
// 94role 临时buff // 94role 临时buff
// 95role 永久buff // 95role 永久buff
let uuid= this.skill_uuid; let uuid= this.skill_uuid;
let atk:number=smc.Role.RoleView.atk let atk:number=smc.Role.RoleView.atk?smc.Role.RoleView.atk:0
let args:any = { let args:any = {
atk:atk*GameSet.ATK_TO_ATK_RATIO, atk:atk*GameSet.ATK_TO_ATK_RATIO,
hp:atk*GameSet.ATK_TO_HP_RATIO, hp:atk*GameSet.ATK_TO_HP_RATIO,