dd
This commit is contained in:
@@ -6,6 +6,7 @@ import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/O
|
||||
import { RandomManager } from "../../../../extensions/oops-plugin-framework/assets/core/common/random/RandomManager";
|
||||
import { SkillSet } from "../common/config/SkillSet";
|
||||
import { HeroModelComp } from "../hero/HeroModelComp";
|
||||
import { RewardSet } from "../common/config/RewardSet";
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
/** 视图层对象 */
|
||||
@@ -27,7 +28,17 @@ export class CardControllerComp extends CCComp {
|
||||
5:{uuid:1105,type:1,lv:0,cost:0,alive:false},
|
||||
6:{uuid:1106,type:1,lv:0,cost:0,alive:false},
|
||||
}
|
||||
rewards:any = {
|
||||
1:{uuid: 5001,path: "5001",type: 1,lv: 1,name: "",info:"",atk:0,hp:0,atk_cd:0,},
|
||||
2:{uuid: 5001,path: "5001",type: 1,lv: 1,name: "",info:"",atk:0,hp:0,atk_cd:0,},
|
||||
3:{uuid: 5001,path: "5001",type: 1,lv: 1,name: "",info:"",atk:0,hp:0,atk_cd:0,},
|
||||
}
|
||||
rewards_set:any = []
|
||||
reward_lv = 0;
|
||||
|
||||
protected onLoad(): void {
|
||||
oops.message.on("do_reward", this.do_reward, this);
|
||||
|
||||
let card1 = this.node.getChildByName("cards").getChildByName("card1");
|
||||
let card2 = this.node.getChildByName("cards").getChildByName("card2");
|
||||
let card3 = this.node.getChildByName("cards").getChildByName("card3");
|
||||
@@ -337,14 +348,83 @@ export class CardControllerComp extends CCComp {
|
||||
// }
|
||||
this.remove_card(index)
|
||||
}
|
||||
|
||||
do_reward(){
|
||||
smc.vm_data.game_pause = true;
|
||||
this.reward_lv+=1
|
||||
this.rewards_set=RewardSet[this.reward_lv]
|
||||
let i=RandomManager.instance.getRandomInt(0,this.rewards_set.length-1, 1)
|
||||
console.log("rewards:",i)
|
||||
this.rewards[1]=this.rewards_set[i]
|
||||
this.rewards_set.splice(i,1)
|
||||
i=RandomManager.instance.getRandomInt(0,this.rewards_set.length-1, 1)
|
||||
console.log("rewards:",i)
|
||||
this.rewards[2]=this.rewards_set[i]
|
||||
this.rewards_set.splice(i,1)
|
||||
i=RandomManager.instance.getRandomInt(0,this.rewards_set.length-1, 1)
|
||||
console.log("rewards:",i)
|
||||
this.rewards[3]=this.rewards_set[i]
|
||||
this.rewards_set=[]
|
||||
console.log("rewards:",this.rewards)
|
||||
let re1=this.node.getChildByName('rewards').getChildByName('reward1')
|
||||
let re2=this.node.getChildByName('rewards').getChildByName('reward2')
|
||||
let re3=this.node.getChildByName('rewards').getChildByName('reward3')
|
||||
|
||||
re1.getChildByName('name').getComponent(Label).string=this.rewards[1].name
|
||||
re2.getChildByName('name').getComponent(Label).string=this.rewards[2].name
|
||||
re3.getChildByName('name').getComponent(Label).string=this.rewards[3].name
|
||||
|
||||
re1.getChildByName('info').getComponent(Label).string=this.rewards[1].info
|
||||
re2.getChildByName('info').getComponent(Label).string=this.rewards[2].info
|
||||
re3.getChildByName('info').getComponent(Label).string=this.rewards[3].info
|
||||
|
||||
resources.load("gui/rewards", SpriteAtlas, (err: any, atlas) => {
|
||||
let pathName: string = this.rewards[1].path;
|
||||
let node=re1.getChildByName('icon')
|
||||
node.getComponent(Sprite).spriteFrame = atlas.getSpriteFrame(pathName);
|
||||
pathName=this.rewards[2].path;
|
||||
node=re2.getChildByName('icon')
|
||||
node.getComponent(Sprite).spriteFrame = atlas.getSpriteFrame(pathName);
|
||||
pathName=this.rewards[3].path;
|
||||
node=re3.getChildByName('icon')
|
||||
node.getComponent(Sprite).spriteFrame = atlas.getSpriteFrame(pathName);
|
||||
})
|
||||
|
||||
|
||||
this.node.getChildByName('rewards').active = true;
|
||||
}
|
||||
colse_reward(){
|
||||
this.node.getChildByName('rewards').active = false;
|
||||
smc.vm_data.game_pause = false;
|
||||
}
|
||||
do_reward_1(value:number=1){
|
||||
this.colse_reward()
|
||||
}
|
||||
do_reward_2(value:number=2){
|
||||
this.colse_reward()
|
||||
}
|
||||
do_reward_3(value:number=3){
|
||||
this.colse_reward()
|
||||
}
|
||||
protected update(dt: number): void {
|
||||
if(smc.vm_data.game_over||smc.vm_data.game_pause){
|
||||
return
|
||||
}
|
||||
this.shuaxin(dt)
|
||||
// this.gold_add(dt)
|
||||
|
||||
if(this.in_touch){
|
||||
this.touch_time+=dt
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
gold_add(dt: number) {
|
||||
smc.vm_data.gold.time += dt;
|
||||
if (smc.vm_data.gold.time >= smc.vm_data.gold.cd) {
|
||||
smc.vm_data.gold.min += 1;
|
||||
smc.vm_data.gold.time = 0;
|
||||
}
|
||||
}
|
||||
/** 视图对象通过 ecs.Entity.remove(ControllerComp) 删除组件是触发组件处理自定义释放逻辑 */
|
||||
reset() {
|
||||
this.node.destroy();
|
||||
|
||||
Reference in New Issue
Block a user