改了很多

This commit is contained in:
2024-12-15 23:13:00 +08:00
parent 8bf3cc2a5d
commit 73ad199bfc
21 changed files with 40518 additions and 18376 deletions

View File

@@ -1,4 +1,4 @@
import { _decorator, Label } from "cc";
import { _decorator, Label ,v3} 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";
@@ -21,69 +21,92 @@ export class VictoryComp extends CCComp {
reward_lv:number=1
reward_num:number=2
rewards:any=[]
if_show:boolean=false
/** 视图层逻辑代码分离演示 */
start() {
this.rewards=[]
}
private do_victiry(is_victory:boolean) {
if(this.if_show) return
this.getReward(is_victory)
this.node.getChildByName("Node").getChildByName("victory").active = is_victory;
this.node.getChildByName("Node").getChildByName("defeat").active = !is_victory
this.node.setPosition(0,this.node.position.y,0)
}
getReward(is_victory:boolean){
let conut =3
if(!is_victory) conut=conut-1
let item1=ecs.getEntity<Item>(Item)
let gold: number = Math.floor(RandomManager.instance.getRandomInt((3000 + smc.mission.lv * 100) / 3 * 2, 3000 + smc.mission.lv * 100));
let parent = this.node.getChildByName("Node").getChildByName("items")
item1.load(9001,gold,parent)
this.rewards = [];
this.rewards[0]={uuid:9001,num:gold}
for (let x = 1; x <= conut; x++) {
let item=ecs.getEntity<Item>(Item)
let r_i:any = RandomManager.instance.getRandomInt(0,MissionReward[this.reward_lv].length-1);
let ii = MissionReward[this.reward_lv][r_i];
let im = Items[ii];
console.log("reward",r_i,ii,im)
item.load(im.uuid,im.r_num,parent)
this.rewards[x]={uuid:im.uuid,num:im.r_num}
}
this.if_show=true
}
do_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(){
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(){
this.node.setPosition(2000,this.node.position.y,0)
this.if_show=false
onAdded(args: any) {
console.log("VictoryComp onAdded",args)
let items=smc.vmdata.items
if(items[9001].x1 > 0) this.node.getChildByName("items").getChildByName("9001").active=true
if(items[1001].x1 > 0) this.node.getChildByName("items").getChildByName("1001").active=true
if(items[1002].x1 > 0) this.node.getChildByName("items").getChildByName("1002").active=true
if(items[1003].x1 > 0) this.node.getChildByName("items").getChildByName("1003").active=true
if(items[1004].x1 > 0) this.node.getChildByName("items").getChildByName("1004").active=true
if(items[1005].x1 > 0) this.node.getChildByName("items").getChildByName("1005").active=true
if(items[1006].x1 > 0) this.node.getChildByName("items").getChildByName("1006").active=true
if(items[1007].x1 > 0) this.node.getChildByName("items").getChildByName("1007").active=true
if(items[1008].x1 > 0) this.node.getChildByName("items").getChildByName("1008").active=true
if(items[1009].x1 > 0) this.node.getChildByName("items").getChildByName("1009").active=true
if(items[1010].x1 > 0) this.node.getChildByName("items").getChildByName("1010").active=true
if(items[1011].x1 > 0) this.node.getChildByName("items").getChildByName("1011").active=true
if(items[1012].x1 > 0) this.node.getChildByName("items").getChildByName("1012").active=true
if(items[1013].x1 > 0) this.node.getChildByName("items").getChildByName("1013").active=true
if(items[1014].x1 > 0) this.node.getChildByName("items").getChildByName("1014").active=true
if(items[1015].x1 > 0) this.node.getChildByName("items").getChildByName("1015").active=true
if(items[1016].x1 > 0) this.node.getChildByName("items").getChildByName("1016").active=true
}
do_x10(){
console.log("do_x10",smc.vmdata)
smc.vmdata.items[9001].num+=smc.vmdata.items[9001].x10
smc.vmdata.items[1001].num+=smc.vmdata.items[1001].x10
smc.vmdata.items[1002].num+=smc.vmdata.items[1002].x10
smc.vmdata.items[1003].num+=smc.vmdata.items[1003].x10
smc.vmdata.items[1004].num+=smc.vmdata.items[1004].x10
smc.vmdata.items[1005].num+=smc.vmdata.items[1005].x10
smc.vmdata.items[1006].num+=smc.vmdata.items[1006].x10
smc.vmdata.items[1007].num+=smc.vmdata.items[1007].x10
smc.vmdata.items[1008].num+=smc.vmdata.items[1008].x10
smc.vmdata.items[1009].num+=smc.vmdata.items[1009].x10
smc.vmdata.items[1010].num+=smc.vmdata.items[1010].x10
smc.vmdata.items[1011].num+=smc.vmdata.items[1011].x10
smc.vmdata.items[1012].num+=smc.vmdata.items[1012].x10
smc.vmdata.items[1013].num+=smc.vmdata.items[1013].x10
smc.vmdata.items[1014].num+=smc.vmdata.items[1014].x10
smc.vmdata.items[1015].num+=smc.vmdata.items[1015].x10
smc.vmdata.items[1016].num+=smc.vmdata.items[1016].x10
this.clear_x1()
this.reset();
}
do_x1(){
console.log("x1",smc.vmdata)
this.clear_x1()
this.reset();
}
clear_x1(){
smc.vmdata.items[9001].x1=smc.vmdata.items[9001].x10=0
smc.vmdata.items[1001].x1=smc.vmdata.items[1001].x10=0
smc.vmdata.items[1002].x1=smc.vmdata.items[1002].x10=0
smc.vmdata.items[1003].x1=smc.vmdata.items[1003].x10=0
smc.vmdata.items[1004].x1=smc.vmdata.items[1004].x10=0
smc.vmdata.items[1005].x1=smc.vmdata.items[1005].x10=0
smc.vmdata.items[1006].x1=smc.vmdata.items[1006].x10=0
smc.vmdata.items[1007].x1=smc.vmdata.items[1007].x10=0
smc.vmdata.items[1008].x1=smc.vmdata.items[1008].x10=0
smc.vmdata.items[1009].x1=smc.vmdata.items[1009].x10=0
smc.vmdata.items[1010].x1=smc.vmdata.items[1010].x10=0
smc.vmdata.items[1011].x1=smc.vmdata.items[1011].x10=0
smc.vmdata.items[1012].x1=smc.vmdata.items[1012].x10=0
smc.vmdata.items[1013].x1=smc.vmdata.items[1013].x10=0
smc.vmdata.items[1014].x1=smc.vmdata.items[1014].x10=0
smc.vmdata.items[1015].x1=smc.vmdata.items[1015].x10=0
smc.vmdata.items[1016].x1=smc.vmdata.items[1016].x10=0
}
end_mission(){
}
item_show(e:any,val:any){
console.log("item_show",val)
oops.gui.open(UIID.ItemInfo, Items[val]);
}
/** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */
reset() {
this.node.destroy();
oops.gui.remove(UIID.Victory, false);
}
}