奖励到账
This commit is contained in:
@@ -19,7 +19,7 @@ export class ItemComp extends CCComp {
|
||||
}
|
||||
|
||||
show_info(){
|
||||
oops.gui.open(UIID.ItemInfo, { name:Items[this.i_uuid].name, info:Items[this.i_uuid].info});
|
||||
oops.gui.open(UIID.ItemInfo, Items[this.i_uuid]);
|
||||
}
|
||||
|
||||
/** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { EventTouch, Label, Node,_decorator } from "cc";
|
||||
import { EventTouch, Label, Node,Sprite,SpriteAtlas,_decorator, resources } from "cc";
|
||||
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
|
||||
import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
|
||||
import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
|
||||
@@ -12,6 +12,12 @@ export class ItemInfoComp extends CCComp {
|
||||
onAdded(args: any) {
|
||||
this.node.getChildByName("name").getComponent(Label).string=args.name
|
||||
this.node.getChildByName("info").getComponent(Label).string=args.info
|
||||
let url = "gui/items";
|
||||
let pathName= args.path;
|
||||
resources.load(url, SpriteAtlas, (err: any, atlas) => {
|
||||
const sprite = this.node.getChildByName("item_bg").getChildByName("icon").getComponent(Sprite);
|
||||
sprite.spriteFrame = atlas.getSpriteFrame(pathName);
|
||||
});
|
||||
}
|
||||
|
||||
private onTouchEnd(event: EventTouch) {
|
||||
|
||||
@@ -60,7 +60,7 @@ export class MissionComp extends CCComp {
|
||||
}
|
||||
|
||||
protected update(dt: number): void {
|
||||
if(!smc.vmdata.mission.play||smc.vmdata.pause){
|
||||
if(!smc.vmdata.mission.play||smc.vmdata.mission.pause){
|
||||
return
|
||||
}
|
||||
if(this.fight_start){
|
||||
@@ -99,9 +99,13 @@ export class MissionComp extends CCComp {
|
||||
this.node.getChildByName("mexp").getChildByName("hp").active = true
|
||||
this.mon_refresh()
|
||||
this.heros_call()
|
||||
}
|
||||
do_x10(){
|
||||
|
||||
}
|
||||
mission_end(){
|
||||
smc.vmdata.mission.play=false
|
||||
smc.vmdata.mission.pause=false
|
||||
let heros:any= this.get_heros();;
|
||||
let monsters:any= this.get_mons();
|
||||
let hcards:any= ecs.query(ecs.allOf(HCardComp));
|
||||
@@ -169,10 +173,6 @@ export class MissionComp extends CCComp {
|
||||
}
|
||||
}
|
||||
|
||||
do_reward(){
|
||||
console.log("do_reward")
|
||||
|
||||
}
|
||||
check_mon_num(){
|
||||
let mons:any = this.get_mons()
|
||||
let heros:any= this.get_heros()
|
||||
@@ -194,10 +194,12 @@ export class MissionComp extends CCComp {
|
||||
}
|
||||
to_end_mission(){
|
||||
if (smc.vmdata.mission.is_victory){
|
||||
this.VictoryComp.do_victiry()
|
||||
this.VictoryComp.do_victiry(true)
|
||||
smc.vmdata.mission.pause=true
|
||||
}
|
||||
if (smc.vmdata.mission.is_defeat){
|
||||
this.VictoryComp.do_defeat()
|
||||
this.VictoryComp.do_victiry(false)
|
||||
smc.vmdata.mission.pause=true
|
||||
}
|
||||
}
|
||||
get_mons(){
|
||||
|
||||
@@ -21,24 +21,18 @@ export class VictoryComp extends CCComp {
|
||||
|
||||
reward_lv:number=1
|
||||
reward_num:number=2
|
||||
rerawd_item:any={}
|
||||
rewards:any=[]
|
||||
if_show:boolean=false
|
||||
/** 视图层逻辑代码分离演示 */
|
||||
start() {
|
||||
this.rewards=[]
|
||||
}
|
||||
private do_victiry() {
|
||||
private do_victiry(is_victory:boolean) {
|
||||
if(this.if_show) return
|
||||
this.getReward(is_victory)
|
||||
this.node.getChildByName("Node").getChildByName("defeat").active = is_victory
|
||||
this.node.getChildByName("Node").getChildByName("victory").active = !is_victory;
|
||||
this.node.setPosition(0,this.node.position.y,0)
|
||||
this.getReward(true)
|
||||
this.node.getChildByName("Node").getChildByName("defeat").active = false
|
||||
this.node.getChildByName("Node").getChildByName("victory").active = true;
|
||||
}
|
||||
private do_defeat() {
|
||||
if(this.if_show) return
|
||||
this.node.setPosition(0,this.node.position.y,0)
|
||||
this.getReward(false)
|
||||
this.node.getChildByName("Node").getChildByName("victory").active = false;
|
||||
this.node.getChildByName("Node").getChildByName("defeat").active = true
|
||||
}
|
||||
getReward(is_victory:boolean){
|
||||
let conut =2
|
||||
@@ -48,19 +42,42 @@ export class VictoryComp extends CCComp {
|
||||
let parent = this.node.getChildByName("Node").getChildByName("items")
|
||||
let reward:any = RandomManager.instance.getRandomByObjectList(MissionReward[this.reward_lv], conut);
|
||||
item1.load(9001,gold,parent)
|
||||
this.rewards = [];
|
||||
this.rewards[0]={uuid:9001,num:gold}
|
||||
for (let i = 0; i < conut; i++) {
|
||||
let item=ecs.getEntity<Item>(Item)
|
||||
let im =Items[reward[i]]
|
||||
|
||||
while (Items[reward[i]]==undefined) {
|
||||
let r = RandomManager.instance.getRandomByObjectList(MissionReward[this.reward_lv], 1);
|
||||
Items[reward[i]]=r[0]
|
||||
console.log("getReward undefined",Items[reward[i]],i)
|
||||
}
|
||||
let im =Items[reward[i]]
|
||||
item.load(im.uuid,im.r_num,parent)
|
||||
this.rewards[i+1]={uuid:9001,num:gold}
|
||||
}
|
||||
this.if_show=true
|
||||
}
|
||||
do_x10(){
|
||||
console.log("x10")
|
||||
for (let i = 0; i < this.rewards.length; i++) {
|
||||
if(this.rewards[i].uuid==9001){
|
||||
smc.vmdata.role.gold+=this.rewards[i].num*10
|
||||
}else{
|
||||
smc.vmdata.items[this.rewards[i].uuid]+=this.rewards[i].num*10
|
||||
}
|
||||
}
|
||||
console.log("do_x10",smc.vmdata)
|
||||
this.end_mission()
|
||||
}
|
||||
do_x1(){
|
||||
console.log("x1")
|
||||
for (let i = 0; i < this.rewards.length; i++) {
|
||||
if(this.rewards[i].uuid==9001){
|
||||
smc.vmdata.role.gold+=this.rewards[i].num
|
||||
}else{
|
||||
smc.vmdata.items[this.rewards[i].uuid]+=this.rewards[i].num
|
||||
}
|
||||
}
|
||||
console.log("x1",smc.vmdata)
|
||||
this.end_mission()
|
||||
}
|
||||
end_mission(){
|
||||
|
||||
Reference in New Issue
Block a user