去掉局内三选一
This commit is contained in:
@@ -22,29 +22,9 @@ const { ccclass, property } = _decorator;
|
||||
@ccclass('CardControllerComp')
|
||||
@ecs.register('CardController', false)
|
||||
export class CardControllerComp extends CCComp {
|
||||
card_level:number = 1;
|
||||
in_load:boolean = false
|
||||
touch_time:number = 0
|
||||
in_touch:boolean = false
|
||||
cards:any = {
|
||||
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},
|
||||
}
|
||||
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)
|
||||
oops.message.on("to_mission", this.to_mission, this)
|
||||
|
||||
}
|
||||
start() {
|
||||
@@ -72,123 +52,13 @@ export class CardControllerComp extends CCComp {
|
||||
}
|
||||
}
|
||||
|
||||
normal_call(){
|
||||
if(smc.vm_data.mission.coin >= smc.vm_data.mission.normal_cost){
|
||||
smc.vm_data.mission.coin -= smc.vm_data.mission.normal_cost
|
||||
oops.message.dispatchEvent("normal_call");
|
||||
}else{
|
||||
oops.gui.toast("铜币不足!");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
better_call(){
|
||||
if(smc.vm_data.mission.coin >= smc.vm_data.mission.better_cost){
|
||||
smc.vm_data.mission.coin -= smc.vm_data.mission.better_cost
|
||||
oops.message.dispatchEvent("better_call");
|
||||
}else{
|
||||
oops.gui.toast("铜币不够!");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
do_reward(){
|
||||
if(!smc.vm_data.mission.coin >= smc.vm_data.mission.enhancement_cost) return
|
||||
smc.vm_data.mission.coin -= smc.vm_data.mission.enhancement_cost
|
||||
|
||||
smc.vm_data.game_pause = true;
|
||||
|
||||
this.reward_lv+=1
|
||||
this.rewards_set=JSON.parse(JSON.stringify(RewardSet[1]));
|
||||
// console.log("rewards_set:",this.rewards_set,RewardSet[1])
|
||||
let i=RandomManager.instance.getRandomInt(0,this.rewards_set.length-1, 2)
|
||||
this.rewards[1]=this.rewards_set[i]
|
||||
this.rewards_set.splice(i,1)
|
||||
// console.log("rewards:",i,this.rewards_set)
|
||||
i=RandomManager.instance.getRandomInt(0,this.rewards_set.length-1, 2)
|
||||
this.rewards[2]=this.rewards_set[i]
|
||||
this.rewards_set.splice(i,1)
|
||||
// console.log("rewards:",i,this.rewards_set)
|
||||
i=RandomManager.instance.getRandomInt(0,this.rewards_set.length-1, 2)
|
||||
this.rewards[3]=this.rewards_set[i]
|
||||
this.rewards_set=[]
|
||||
// console.log("rewards:",i,this.rewards,this.rewards_set)
|
||||
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(value:number){
|
||||
this.node.getChildByName('rewards').active = false;
|
||||
smc.vm_data.game_pause = false;
|
||||
let reward=this.rewards[value]
|
||||
if(reward.type==1){
|
||||
smc.vm_data.mission.hero.atk += reward.atk / 100
|
||||
smc.vm_data.mission.hero.atk_cd += reward.atk_cd/100
|
||||
smc.vm_data.mission.hero.hp += reward.hp / 100;
|
||||
this.add_hero_hp_max(reward.hp / 100)
|
||||
smc.vm_data.mission.coin_reward_add += reward.coin / 100
|
||||
}
|
||||
console.log("card mission",smc.vm_data.mission)
|
||||
}
|
||||
do_reward_1(){
|
||||
this.colse_reward(1)
|
||||
}
|
||||
do_reward_2(){
|
||||
this.colse_reward(2)
|
||||
}
|
||||
do_reward_3(){
|
||||
this.colse_reward(3)
|
||||
}
|
||||
add_hero_hp_max(hp:number){
|
||||
let heros:any = ecs.query(ecs.allOf(HeroModelComp));
|
||||
if (heros.length > 0) {
|
||||
for (let i = 0; i < heros.length; i++) {
|
||||
let hero = heros[i];
|
||||
if(!hero.HeroView) continue
|
||||
hero.HeroView.add_hp_max(Math.floor(hero.HeroView.hp_max*hp))
|
||||
}
|
||||
}
|
||||
}
|
||||
protected update(dt: number): void {
|
||||
if(smc.vm_data.game_over||smc.vm_data.game_pause){
|
||||
return
|
||||
}
|
||||
this.coin_add(dt)
|
||||
|
||||
}
|
||||
|
||||
coin_add(dt: number) {
|
||||
smc.vm_data.gold.time += dt;
|
||||
if (smc.vm_data.gold.time >= smc.vm_data.gold.cd) {
|
||||
let coin =(GameSet.COIN_ADD*smc.vm_data.mission.coin_reward_add*(1+Talents[1006].bonus*smc.vm_data.talent[1006].lv)).toFixed(0)
|
||||
smc.vm_data.mission.coin += parseFloat(coin)
|
||||
smc.vm_data.gold.time = 0;
|
||||
}
|
||||
}
|
||||
to_mission(){
|
||||
oops.message.dispatchEvent("mission_end")
|
||||
this.node.getChildByName("mission_home").active=true
|
||||
|
||||
Reference in New Issue
Block a user