清理掉 missioncomp的 抽卡相关的 游戏逻辑
This commit is contained in:
@@ -452,7 +452,7 @@
|
|||||||
"_lpos": {
|
"_lpos": {
|
||||||
"__type__": "cc.Vec3",
|
"__type__": "cc.Vec3",
|
||||||
"x": 0,
|
"x": 0,
|
||||||
"y": 0,
|
"y": 1.436,
|
||||||
"z": 0
|
"z": 0
|
||||||
},
|
},
|
||||||
"_lrot": {
|
"_lrot": {
|
||||||
@@ -502,7 +502,7 @@
|
|||||||
"_lpos": {
|
"_lpos": {
|
||||||
"__type__": "cc.Vec3",
|
"__type__": "cc.Vec3",
|
||||||
"x": 0,
|
"x": 0,
|
||||||
"y": 189.827,
|
"y": 245.023,
|
||||||
"z": 0
|
"z": 0
|
||||||
},
|
},
|
||||||
"_lrot": {
|
"_lrot": {
|
||||||
@@ -515,7 +515,7 @@
|
|||||||
"_lscale": {
|
"_lscale": {
|
||||||
"__type__": "cc.Vec3",
|
"__type__": "cc.Vec3",
|
||||||
"x": 2,
|
"x": 2,
|
||||||
"y": 2,
|
"y": 2.5,
|
||||||
"z": 1
|
"z": 1
|
||||||
},
|
},
|
||||||
"_mobility": 0,
|
"_mobility": 0,
|
||||||
@@ -3697,7 +3697,7 @@
|
|||||||
"_isTrimmedMode": true,
|
"_isTrimmedMode": true,
|
||||||
"_useGrayscale": false,
|
"_useGrayscale": false,
|
||||||
"_atlas": null,
|
"_atlas": null,
|
||||||
"_id": "75natGRyhKSoENwtP3+ep4"
|
"_id": "b66NtMUq9JsrMS7a2uXNZv"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"__type__": "cc.CompPrefabInfo",
|
"__type__": "cc.CompPrefabInfo",
|
||||||
@@ -4006,7 +4006,7 @@
|
|||||||
"_lpos": {
|
"_lpos": {
|
||||||
"__type__": "cc.Vec3",
|
"__type__": "cc.Vec3",
|
||||||
"x": 110.616,
|
"x": 110.616,
|
||||||
"y": -17.135,
|
"y": -18.025,
|
||||||
"z": 0
|
"z": 0
|
||||||
},
|
},
|
||||||
"_lrot": {
|
"_lrot": {
|
||||||
@@ -4142,7 +4142,7 @@
|
|||||||
"_lpos": {
|
"_lpos": {
|
||||||
"__type__": "cc.Vec3",
|
"__type__": "cc.Vec3",
|
||||||
"x": -134.722,
|
"x": -134.722,
|
||||||
"y": -15.274,
|
"y": -18.025,
|
||||||
"z": 0
|
"z": 0
|
||||||
},
|
},
|
||||||
"_lrot": {
|
"_lrot": {
|
||||||
@@ -4278,7 +4278,7 @@
|
|||||||
"_lpos": {
|
"_lpos": {
|
||||||
"__type__": "cc.Vec3",
|
"__type__": "cc.Vec3",
|
||||||
"x": -245.406,
|
"x": -245.406,
|
||||||
"y": -21.45,
|
"y": -18.025,
|
||||||
"z": 0
|
"z": 0
|
||||||
},
|
},
|
||||||
"_lrot": {
|
"_lrot": {
|
||||||
@@ -4414,7 +4414,7 @@
|
|||||||
"_lpos": {
|
"_lpos": {
|
||||||
"__type__": "cc.Vec3",
|
"__type__": "cc.Vec3",
|
||||||
"x": 312.578,
|
"x": 312.578,
|
||||||
"y": -23.099,
|
"y": -18.025,
|
||||||
"z": 0
|
"z": 0
|
||||||
},
|
},
|
||||||
"_lrot": {
|
"_lrot": {
|
||||||
@@ -4550,7 +4550,7 @@
|
|||||||
"_lpos": {
|
"_lpos": {
|
||||||
"__type__": "cc.Vec3",
|
"__type__": "cc.Vec3",
|
||||||
"x": -340.809,
|
"x": -340.809,
|
||||||
"y": -24.131,
|
"y": -18.025,
|
||||||
"z": 0
|
"z": 0
|
||||||
},
|
},
|
||||||
"_lrot": {
|
"_lrot": {
|
||||||
@@ -4686,7 +4686,7 @@
|
|||||||
"_lpos": {
|
"_lpos": {
|
||||||
"__type__": "cc.Vec3",
|
"__type__": "cc.Vec3",
|
||||||
"x": 323.966,
|
"x": 323.966,
|
||||||
"y": -26.009,
|
"y": -18.025,
|
||||||
"z": 0
|
"z": 0
|
||||||
},
|
},
|
||||||
"_lrot": {
|
"_lrot": {
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -21,14 +21,18 @@ export class SingletonModuleComp extends ecs.Comp {
|
|||||||
in_select:false,
|
in_select:false,
|
||||||
score:888,
|
score:888,
|
||||||
};
|
};
|
||||||
fight_heros={
|
fight_heros:any={
|
||||||
0:0,
|
0:5001,
|
||||||
1:0,
|
1:5005,
|
||||||
2:0,
|
2:0,
|
||||||
3:0,
|
3:0,
|
||||||
4:0,
|
4:0,
|
||||||
}
|
}
|
||||||
heros:any = [];
|
heros:any = {
|
||||||
|
5001:{lv:1},
|
||||||
|
5005:{lv:1},
|
||||||
|
5007:{lv:1},
|
||||||
|
};
|
||||||
monsters:any = [];
|
monsters:any = [];
|
||||||
sk_info:any = []
|
sk_info:any = []
|
||||||
monsters_dead:any = []
|
monsters_dead:any = []
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ export enum GameEvent {
|
|||||||
LoginSuccess = "LoginSuccess",
|
LoginSuccess = "LoginSuccess",
|
||||||
MAP_MOVE_END_LEFT = "MAP_MOVE_END_LEFT",
|
MAP_MOVE_END_LEFT = "MAP_MOVE_END_LEFT",
|
||||||
MAP_MOVE_END_RIGHT = "MAP_MOVE_END_RIGHT",
|
MAP_MOVE_END_RIGHT = "MAP_MOVE_END_RIGHT",
|
||||||
|
UpdateHero = "UpdateHero",
|
||||||
MSSelected = "MSSelected",
|
MSSelected = "MSSelected",
|
||||||
LifeChange = "LifeChange",
|
LifeChange = "LifeChange",
|
||||||
CastSkill = "CastSkill",
|
CastSkill = "CastSkill",
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
import { _decorator, Animation, AnimationClip, CCInteger, Component, Node, resources } from 'cc';
|
import { _decorator, Animation, AnimationClip, CCInteger, Component, Label, Node, resources } from 'cc';
|
||||||
import { smc } from '../common/SingletonModuleComp';
|
import { smc } from '../common/SingletonModuleComp';
|
||||||
import { HeroInfo } from '../common/config/heroSet';
|
import { HeroInfo } from '../common/config/heroSet';
|
||||||
|
import { GameEvent } from '../common/config/GameEvent';
|
||||||
|
import { oops } from 'db://oops-framework/core/Oops';
|
||||||
const { ccclass, property } = _decorator;
|
const { ccclass, property } = _decorator;
|
||||||
|
|
||||||
@ccclass('HeroReadyCom')
|
@ccclass('HeroReadyCom')
|
||||||
@@ -10,6 +12,7 @@ export class HeroReadyCom extends Component {
|
|||||||
|
|
||||||
start() {
|
start() {
|
||||||
this.update_hero()
|
this.update_hero()
|
||||||
|
oops.message.on(GameEvent.UpdateHero,this.update_hero,this)
|
||||||
}
|
}
|
||||||
|
|
||||||
update(deltaTime: number) {
|
update(deltaTime: number) {
|
||||||
@@ -18,8 +21,10 @@ export class HeroReadyCom extends Component {
|
|||||||
update_hero(){
|
update_hero(){
|
||||||
let hero = smc.fight_heros[this.slot]
|
let hero = smc.fight_heros[this.slot]
|
||||||
if(hero==0){
|
if(hero==0){
|
||||||
|
this.no_hero()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
this.node.getChildByName("add").active=false
|
||||||
let hero_data = HeroInfo[hero]
|
let hero_data = HeroInfo[hero]
|
||||||
console.log("[HeroReadyCom]hero_data",smc.fight_heros,hero,smc.fight_heros[this.slot],this.slot,hero_data)
|
console.log("[HeroReadyCom]hero_data",smc.fight_heros,hero,smc.fight_heros[this.slot],this.slot,hero_data)
|
||||||
let anm_path=hero_data.path
|
let anm_path=hero_data.path
|
||||||
@@ -27,9 +32,14 @@ export class HeroReadyCom extends Component {
|
|||||||
this.node.getChildByName("icon").getComponent(Animation).addClip(clip);
|
this.node.getChildByName("icon").getComponent(Animation).addClip(clip);
|
||||||
this.node.getChildByName("icon").getComponent(Animation).play("idle");
|
this.node.getChildByName("icon").getComponent(Animation).play("idle");
|
||||||
});
|
});
|
||||||
|
this.node.getChildByName("lv").getChildByName("num").getComponent(Label).string=smc.heros[hero].lv.toString()
|
||||||
// console.log("[HeroReadyCom]clip",this.node.getChildByName("icon").getComponent(Animation))
|
// console.log("[HeroReadyCom]clip",this.node.getChildByName("icon").getComponent(Animation))
|
||||||
|
|
||||||
}
|
}
|
||||||
|
no_hero(){
|
||||||
|
this.node.getChildByName("lv").active=false
|
||||||
|
this.node.getChildByName("add").active=true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
413
assets/script/game/map/MissionComp copy.ts
Normal file
413
assets/script/game/map/MissionComp copy.ts
Normal file
@@ -0,0 +1,413 @@
|
|||||||
|
import { _decorator,Button,EventHandler,EventTouch,Label,NodeEventType,resources,Sprite,SpriteAtlas,tween,UITransform,v3, Vec3,Animation, UI, instantiate, Prefab, screen } 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 { smc } from "../common/SingletonModuleComp";
|
||||||
|
import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
|
||||||
|
import { FightSet, HeroUI, MissionData, VmInfo} from "../common/config/Mission";
|
||||||
|
import { Timer } from "../../../../extensions/oops-plugin-framework/assets/core/common/timer/Timer";
|
||||||
|
import { GameEvent } from "../common/config/GameEvent";
|
||||||
|
import { HeroViewComp } from "../hero/HeroViewComp";
|
||||||
|
import { Hero } from "../hero/Hero";
|
||||||
|
import { defaultEnhancements, EnhancementOptions } from "../common/config/LevelUp";
|
||||||
|
import { MonModelComp } from "../hero/MonModelComp";
|
||||||
|
import { TalentSlot } from "../common/config/TalentSet";
|
||||||
|
import { RogueTalWave } from "./RogueConfig";
|
||||||
|
import { cardType, getRandomCardsByType, SuperCards, SuperCardsList, SuperCardsType } from "../common/config/CardSet";
|
||||||
|
import { LuckCardComp } from "./LuckCardComp";
|
||||||
|
const { ccclass, property } = _decorator;
|
||||||
|
|
||||||
|
|
||||||
|
//@todo this is a test
|
||||||
|
|
||||||
|
/** 视图层对象 */
|
||||||
|
@ccclass('MissionComp')
|
||||||
|
@ecs.register('MissionComp', false)
|
||||||
|
export class MissionComp extends CCComp {
|
||||||
|
// VictoryComp:any = null;
|
||||||
|
// reward:number = 0;
|
||||||
|
// reward_num:number = 0;
|
||||||
|
GlodAddTimer:Timer = new Timer(1);
|
||||||
|
normal_max_wave:number = 10;
|
||||||
|
is_fight:boolean = false;
|
||||||
|
enhancements:any=[0,0,0,0,0]
|
||||||
|
update_count:number = 0;
|
||||||
|
is_show_time:boolean = false;
|
||||||
|
time_num:number = 0;
|
||||||
|
time_cd:Timer=new Timer(1);
|
||||||
|
|
||||||
|
next_func?:Function;
|
||||||
|
wave_time_num:number = 0;
|
||||||
|
wave_time_cd:Timer=new Timer(1);
|
||||||
|
is_in_wave:boolean = false;
|
||||||
|
tals:any={
|
||||||
|
0:false,
|
||||||
|
1:false,
|
||||||
|
2:false,
|
||||||
|
3:false,
|
||||||
|
4:false,
|
||||||
|
5:false,
|
||||||
|
}
|
||||||
|
heros:any={
|
||||||
|
0:{uuid:0,count:0},
|
||||||
|
1:{uuid:0,count:0},
|
||||||
|
2:{uuid:0,count:0},
|
||||||
|
}
|
||||||
|
func_queue:any=[]
|
||||||
|
|
||||||
|
|
||||||
|
onLoad(){
|
||||||
|
this.on(GameEvent.MissionStart,this.mission_start,this)
|
||||||
|
this.on(GameEvent.MasterCalled,this.ready_to_fight,this)
|
||||||
|
// this.on(GameEvent.CardsClose,this.after_used_skill_card,this)
|
||||||
|
this.on(GameEvent.MonDead,this.do_mon_dead,this)
|
||||||
|
|
||||||
|
this.on(GameEvent.FightEnd,this.fight_end,this)
|
||||||
|
this.on(GameEvent.MissionEnd,this.mission_end,this)
|
||||||
|
this.on(GameEvent.DO_AD_BACK,this.do_ad,this)
|
||||||
|
// this.on(GameEvent.CanUpdateLv,this.show_uplv_button,this)
|
||||||
|
this.on(GameEvent.UseHeroCard,this.hero_called,this)
|
||||||
|
}
|
||||||
|
|
||||||
|
protected update(dt: number): void {
|
||||||
|
if(!smc.mission.play||smc.mission.pause){
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if(smc.vmdata.mission_data.in_fight){
|
||||||
|
smc.vmdata.mission_data.fight_time+=dt
|
||||||
|
if(this.GlodAddTimer.update(dt)){
|
||||||
|
smc.vmdata.mission_data.gold+=(smc.vmdata.mission_data.add_gold+smc.vmdata.mission_data.buff_add_gold)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(this.is_show_time){
|
||||||
|
if(this.time_cd.update(dt)){
|
||||||
|
this.run_time()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// if(this.is_in_wave){
|
||||||
|
// if(this.wave_time_cd.update(dt)){
|
||||||
|
// smc.vmdata.mission_data.wave_time_num--
|
||||||
|
// if(smc.vmdata.mission_data.wave_time_num<=0){
|
||||||
|
// this.hide_wave_time()
|
||||||
|
// this.show_time(this.do_next_wave.bind(this))
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
//奖励发放
|
||||||
|
do_reward(){
|
||||||
|
// 奖励发放
|
||||||
|
}
|
||||||
|
hero_called(event: any, data: any) {
|
||||||
|
// 查找空位或已存在的英雄
|
||||||
|
const heroIndex = this.findHeroSlot(data.uuid);
|
||||||
|
|
||||||
|
if (heroIndex !== -1) {
|
||||||
|
// 找到英雄位置,增加数量
|
||||||
|
this.heros[heroIndex].count += 1;
|
||||||
|
} else {
|
||||||
|
// 查找空位
|
||||||
|
const emptySlot = this.findEmptySlot();
|
||||||
|
if (emptySlot !== -1) {
|
||||||
|
// 有空位,添加新英雄
|
||||||
|
this.heros[emptySlot].uuid = data.uuid;
|
||||||
|
this.heros[emptySlot].count = 1;
|
||||||
|
} else {
|
||||||
|
console.log("[MissionComp] 英雄已满");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查找英雄位置
|
||||||
|
* @param uuid 英雄UUID
|
||||||
|
* @returns 英雄索引,未找到返回-1
|
||||||
|
*/
|
||||||
|
private findHeroSlot(uuid: number): number {
|
||||||
|
for (let i = 0; i < 3; i++) {
|
||||||
|
if (this.heros[i].uuid === uuid) {
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查找空位
|
||||||
|
* @returns 空位索引,无空位返回-1
|
||||||
|
*/
|
||||||
|
private findEmptySlot(): number {
|
||||||
|
for (let i = 0; i < 3; i++) {
|
||||||
|
if (this.heros[i].uuid === 0) {
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
count_tal(){
|
||||||
|
let count=0
|
||||||
|
for(let i=0;i<FightSet.TAL_NUM;i++){
|
||||||
|
if(this.tals[i]){
|
||||||
|
count++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return count
|
||||||
|
}
|
||||||
|
|
||||||
|
do_mon_dead(){
|
||||||
|
this.do_mon_dead_thing()
|
||||||
|
smc.vmdata.mission_data.mon_num--
|
||||||
|
if(smc.vmdata.mission_data.mon_num<=0) {
|
||||||
|
// if(smc.vmdata.mission_data.current_wave == RogueTalWave[this.count_tal()].wave){
|
||||||
|
// console.log("[MissionComp] current_wave:"+smc.vmdata.mission_data.current_wave+" tal wave:"+RogueTalWave[this.count_tal()].wave)
|
||||||
|
// oops.message.dispatchEvent(GameEvent.TalentSelect,{slot:TalentSlot[this.count_tal()]})
|
||||||
|
// this.tals[this.count_tal()]=true
|
||||||
|
|
||||||
|
// }
|
||||||
|
this.show_time(this.do_next_wave.bind(this))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
do_mon_dead_thing(){
|
||||||
|
smc.vmdata.mission_data.gold+=smc.vmdata.mission_data.add_gold+smc.vmdata.mission_data.buff_add_gold
|
||||||
|
}
|
||||||
|
|
||||||
|
do_next_wave(){ //怪物死亡后,重置时间
|
||||||
|
smc.vmdata.mission_data.current_wave++
|
||||||
|
smc.vmdata.mission_data.refresh_count++
|
||||||
|
oops.message.dispatchEvent(GameEvent.NewWave)
|
||||||
|
this.show_wave_time()
|
||||||
|
}
|
||||||
|
|
||||||
|
do_ad(){
|
||||||
|
if(this.ad_back()){
|
||||||
|
oops.message.dispatchEvent(GameEvent.AD_BACK_TRUE)
|
||||||
|
smc.vmdata.mission_data.refresh_count+=FightSet.MORE_RC
|
||||||
|
}else{
|
||||||
|
oops.message.dispatchEvent(GameEvent.AD_BACK_FALSE)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ad_back(){
|
||||||
|
|
||||||
|
return true
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
show_wave_time(){
|
||||||
|
smc.vmdata.mission_data.wave_time_num=FightSet.ONE_WAVE_TIME
|
||||||
|
this.is_in_wave=true
|
||||||
|
}
|
||||||
|
|
||||||
|
hide_wave_time(){
|
||||||
|
this.is_in_wave=false
|
||||||
|
}
|
||||||
|
|
||||||
|
show_time(onHide?:Function){
|
||||||
|
this.time_num=FightSet.DOWN_TIME
|
||||||
|
this.node.getChildByName("time").active=true
|
||||||
|
this.is_show_time=true
|
||||||
|
this.run_time()
|
||||||
|
this.next_func=onHide
|
||||||
|
}
|
||||||
|
hide_time(){
|
||||||
|
if(this.next_func){
|
||||||
|
this.next_func()
|
||||||
|
}
|
||||||
|
this.node.getChildByName("time").active=false
|
||||||
|
this.is_show_time=false
|
||||||
|
this.next_func=undefined
|
||||||
|
this.time_cd.reset()
|
||||||
|
}
|
||||||
|
clear_time(){
|
||||||
|
this.node.getChildByName("time").active=false
|
||||||
|
this.is_show_time=false
|
||||||
|
this.next_func=undefined
|
||||||
|
this.time_cd.reset()
|
||||||
|
}
|
||||||
|
run_time(){
|
||||||
|
this.node.getChildByName("time").setScale(0,0,0)
|
||||||
|
tween(this.node.getChildByName("time"))
|
||||||
|
.to(0.2, {scale:v3(1,1,1)}, {easing:"backOut"})
|
||||||
|
.to(0.2, {scale:v3(0,0,0)}, {easing:"backIn"})
|
||||||
|
.start()
|
||||||
|
this.time_num--
|
||||||
|
this.node.getChildByName("time").getChildByName("time").getComponent(Label).string=this.time_num.toString()
|
||||||
|
if(this.time_num<=0){
|
||||||
|
this.hide_time()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
async mission_start(){
|
||||||
|
console.log("[MissionComp] ** 1 ** mission_start")
|
||||||
|
|
||||||
|
this.node.getChildByName("ending").getComponent(Animation).play("startFight")
|
||||||
|
oops.message.dispatchEvent(GameEvent.FightReady)
|
||||||
|
this.node.active=true
|
||||||
|
this.data_init()
|
||||||
|
let loading=this.node.parent.getChildByName("loading")
|
||||||
|
loading.active=true
|
||||||
|
this.scheduleOnce(()=>{
|
||||||
|
loading.active=false
|
||||||
|
this.node.getChildByName("ending").active=false
|
||||||
|
},0.5)
|
||||||
|
this.to_ready()
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
to_ready(){
|
||||||
|
console.log("[MissionComp] ** 2 ** to_ready")
|
||||||
|
oops.message.dispatchEvent(GameEvent.HeroSelect,{called:[]})
|
||||||
|
}
|
||||||
|
ready_to_fight(){
|
||||||
|
console.log("[MissionComp] ** 3 ** ready_to_fight")
|
||||||
|
this.time_num=5
|
||||||
|
this.show_time(this.to_fight.bind(this))
|
||||||
|
}
|
||||||
|
// show_uplv_button(){
|
||||||
|
// this.update_count++
|
||||||
|
// this.node.getChildByName("uplv").active=true
|
||||||
|
// }
|
||||||
|
// hide_uplv_button(){
|
||||||
|
// this.update_count--
|
||||||
|
// if(this.update_count > 0) return
|
||||||
|
// this.node.getChildByName("uplv").active=false
|
||||||
|
// }
|
||||||
|
// to_uplv(){
|
||||||
|
// oops.message.dispatchEvent(GameEvent.EnhancementSelect)
|
||||||
|
// }
|
||||||
|
to_call_friend(){
|
||||||
|
let called = Object.values(this.heros).filter((item: any) => item.uuid != 0)
|
||||||
|
oops.message.dispatchEvent(GameEvent.HeroSelect,{called:called})
|
||||||
|
}
|
||||||
|
|
||||||
|
to_fight(){
|
||||||
|
console.log("[MissionComp] ** 4 ** to_fight")
|
||||||
|
smc.vmdata.mission_data.in_fight=true
|
||||||
|
oops.message.dispatchEvent(GameEvent.FightStart) //MissionMonComp 监听刷怪
|
||||||
|
this.do_next_wave()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
to_end_fight(){
|
||||||
|
oops.message.dispatchEvent(GameEvent.FightEnd)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
fight_end(){
|
||||||
|
console.log("任务结束")
|
||||||
|
this.node.getChildByName("ending").active=true
|
||||||
|
this.node.getChildByName("ending").getComponent(Animation).play("endFight")
|
||||||
|
// 延迟0.5秒后执行任务结束逻辑
|
||||||
|
this.scheduleOnce(() => {
|
||||||
|
smc.mission.play=false
|
||||||
|
smc.mission.pause=false
|
||||||
|
this.cleanComponents()
|
||||||
|
}, 0.5)
|
||||||
|
}
|
||||||
|
|
||||||
|
mission_end(){
|
||||||
|
this.node.getChildByName("ending").active=false
|
||||||
|
this.node.active=false
|
||||||
|
}
|
||||||
|
|
||||||
|
data_init(){
|
||||||
|
//局内数据初始化 smc 数据初始化
|
||||||
|
smc.mission.play = true;
|
||||||
|
smc.vmdata.mission_data = JSON.parse(JSON.stringify(MissionData));
|
||||||
|
smc.vmdata.hero = JSON.parse(JSON.stringify(VmInfo));
|
||||||
|
smc.vmdata.boss = JSON.parse(JSON.stringify(VmInfo));
|
||||||
|
this.update_count=0
|
||||||
|
this.GlodAddTimer=new Timer(smc.vmdata.mission_data.refrsh_time)
|
||||||
|
smc.enhancements=defaultEnhancements()
|
||||||
|
this.heros={
|
||||||
|
0:{uuid:0,count:0},
|
||||||
|
1:{uuid:0,count:0},
|
||||||
|
2:{uuid:0,count:0},
|
||||||
|
}
|
||||||
|
|
||||||
|
this.clear_time()
|
||||||
|
this.hide_wave_time()
|
||||||
|
this.tals={
|
||||||
|
0:false,
|
||||||
|
1:false,
|
||||||
|
2:false,
|
||||||
|
3:false,
|
||||||
|
4:false,
|
||||||
|
5:false,
|
||||||
|
}
|
||||||
|
smc.vmdata.mission_data.wave_time_num=FightSet.ONE_WAVE_TIME
|
||||||
|
console.log("局内数据初始化",smc.enhancements,defaultEnhancements())
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
card_init(){
|
||||||
|
oops.message.dispatchEvent(GameEvent.CardRefresh)
|
||||||
|
}
|
||||||
|
|
||||||
|
card_refresh(){
|
||||||
|
let mission_data=smc.vmdata.mission_data
|
||||||
|
if(mission_data.gold < (mission_data.refresh_gold+mission_data.buff_refresh_gold)){
|
||||||
|
oops.gui.toast("金币不足", false);
|
||||||
|
return
|
||||||
|
}
|
||||||
|
oops.message.dispatchEvent(GameEvent.CardRefresh)
|
||||||
|
mission_data.gold-=(mission_data.refresh_gold+mission_data.buff_refresh_gold)
|
||||||
|
|
||||||
|
}
|
||||||
|
call_friend_card(){
|
||||||
|
oops.message.dispatchEvent(GameEvent.HeroSelect)
|
||||||
|
}
|
||||||
|
call_tal_card(){
|
||||||
|
oops.message.dispatchEvent(GameEvent.TalentSelect)
|
||||||
|
}
|
||||||
|
call_func_card(){
|
||||||
|
if(smc.vmdata.mission_data.gold < smc.vmdata.mission_data.lucky_gold){
|
||||||
|
oops.gui.toast("金币不足", false);
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this.do_lucky_card()
|
||||||
|
|
||||||
|
}
|
||||||
|
do_lucky_card(){
|
||||||
|
smc.vmdata.mission_data.gold-=smc.vmdata.mission_data.lucky_gold
|
||||||
|
let list=getRandomCardsByType(cardType.SPECIAL,1)
|
||||||
|
let card=SuperCards[list[0].uuid]
|
||||||
|
console.log("[MissionComp] do_lucky_card",card)
|
||||||
|
this.show_lucky_gold(card)
|
||||||
|
oops.message.dispatchEvent(GameEvent.LuckCardUsed,card)
|
||||||
|
}
|
||||||
|
show_lucky_gold(card:any){
|
||||||
|
// this.node.getChildByName("luckybox").getComponent(Animation).play("luckyopen")
|
||||||
|
var path = "game/gui/lcard";
|
||||||
|
var prefab: Prefab = oops.res.get(path, Prefab)!;
|
||||||
|
var node = instantiate(prefab);
|
||||||
|
node.setScale(0,0,0)
|
||||||
|
node.getComponent(LuckCardComp).show_card(card)
|
||||||
|
node.parent = this.node
|
||||||
|
node.setPosition(v3(this.node.getChildByName("luckybox").position.x,this.node.getChildByName("luckybox").position.y));
|
||||||
|
let height=this.node.getComponent(UITransform).height
|
||||||
|
tween(node) .to(1, {
|
||||||
|
scale: v3(1,1,1),
|
||||||
|
position: v3(0, height-300),
|
||||||
|
}, {easing:"backOut"})
|
||||||
|
.start();
|
||||||
|
|
||||||
|
}
|
||||||
|
private cleanComponents() {
|
||||||
|
smc.vmdata.hero1=JSON.parse(JSON.stringify(HeroUI))
|
||||||
|
smc.vmdata.hero2=JSON.parse(JSON.stringify(HeroUI))
|
||||||
|
smc.vmdata.hero3=JSON.parse(JSON.stringify(HeroUI))
|
||||||
|
ecs.query(ecs.allOf(HeroViewComp)).forEach(entity => {entity.remove(HeroViewComp);entity.destroy()});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** 视图层逻辑代码分离演示 */
|
||||||
|
|
||||||
|
/** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */
|
||||||
|
reset() {
|
||||||
|
this.node.destroy();
|
||||||
|
}
|
||||||
|
}
|
||||||
9
assets/script/game/map/MissionComp copy.ts.meta
Normal file
9
assets/script/game/map/MissionComp copy.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"ver": "4.0.23",
|
||||||
|
"importer": "typescript",
|
||||||
|
"imported": true,
|
||||||
|
"uuid": "d8d095e8-6cd9-4fe1-a9cc-bffcf04e0346",
|
||||||
|
"files": [],
|
||||||
|
"subMetas": {},
|
||||||
|
"userData": {}
|
||||||
|
}
|
||||||
@@ -7,13 +7,6 @@ import { FightSet, HeroUI, MissionData, VmInfo} from "../common/config/Mission";
|
|||||||
import { Timer } from "../../../../extensions/oops-plugin-framework/assets/core/common/timer/Timer";
|
import { Timer } from "../../../../extensions/oops-plugin-framework/assets/core/common/timer/Timer";
|
||||||
import { GameEvent } from "../common/config/GameEvent";
|
import { GameEvent } from "../common/config/GameEvent";
|
||||||
import { HeroViewComp } from "../hero/HeroViewComp";
|
import { HeroViewComp } from "../hero/HeroViewComp";
|
||||||
import { Hero } from "../hero/Hero";
|
|
||||||
import { defaultEnhancements, EnhancementOptions } from "../common/config/LevelUp";
|
|
||||||
import { MonModelComp } from "../hero/MonModelComp";
|
|
||||||
import { TalentSlot } from "../common/config/TalentSet";
|
|
||||||
import { RogueTalWave } from "./RogueConfig";
|
|
||||||
import { cardType, getRandomCardsByType, SuperCards, SuperCardsList, SuperCardsType } from "../common/config/CardSet";
|
|
||||||
import { LuckCardComp } from "./LuckCardComp";
|
|
||||||
const { ccclass, property } = _decorator;
|
const { ccclass, property } = _decorator;
|
||||||
|
|
||||||
|
|
||||||
@@ -26,133 +19,30 @@ export class MissionComp extends CCComp {
|
|||||||
// VictoryComp:any = null;
|
// VictoryComp:any = null;
|
||||||
// reward:number = 0;
|
// reward:number = 0;
|
||||||
// reward_num:number = 0;
|
// reward_num:number = 0;
|
||||||
GlodAddTimer:Timer = new Timer(1);
|
|
||||||
normal_max_wave:number = 10;
|
|
||||||
is_fight:boolean = false;
|
|
||||||
enhancements:any=[0,0,0,0,0]
|
|
||||||
update_count:number = 0;
|
|
||||||
is_show_time:boolean = false;
|
|
||||||
time_num:number = 0;
|
|
||||||
time_cd:Timer=new Timer(1);
|
|
||||||
|
|
||||||
next_func?:Function;
|
|
||||||
wave_time_num:number = 0;
|
|
||||||
wave_time_cd:Timer=new Timer(1);
|
|
||||||
is_in_wave:boolean = false;
|
|
||||||
tals:any={
|
|
||||||
0:false,
|
|
||||||
1:false,
|
|
||||||
2:false,
|
|
||||||
3:false,
|
|
||||||
4:false,
|
|
||||||
5:false,
|
|
||||||
}
|
|
||||||
heros:any={
|
|
||||||
0:{uuid:0,count:0},
|
|
||||||
1:{uuid:0,count:0},
|
|
||||||
2:{uuid:0,count:0},
|
|
||||||
}
|
|
||||||
func_queue:any=[]
|
|
||||||
|
|
||||||
|
|
||||||
onLoad(){
|
onLoad(){
|
||||||
this.on(GameEvent.MissionStart,this.mission_start,this)
|
this.on(GameEvent.MissionStart,this.mission_start,this)
|
||||||
this.on(GameEvent.MasterCalled,this.ready_to_fight,this)
|
|
||||||
// this.on(GameEvent.CardsClose,this.after_used_skill_card,this)
|
|
||||||
this.on(GameEvent.MonDead,this.do_mon_dead,this)
|
this.on(GameEvent.MonDead,this.do_mon_dead,this)
|
||||||
|
|
||||||
this.on(GameEvent.FightEnd,this.fight_end,this)
|
this.on(GameEvent.FightEnd,this.fight_end,this)
|
||||||
this.on(GameEvent.MissionEnd,this.mission_end,this)
|
this.on(GameEvent.MissionEnd,this.mission_end,this)
|
||||||
this.on(GameEvent.DO_AD_BACK,this.do_ad,this)
|
this.on(GameEvent.DO_AD_BACK,this.do_ad,this)
|
||||||
// this.on(GameEvent.CanUpdateLv,this.show_uplv_button,this)
|
// this.on(GameEvent.CanUpdateLv,this.show_uplv_button,this)
|
||||||
this.on(GameEvent.UseHeroCard,this.hero_called,this)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected update(dt: number): void {
|
protected update(dt: number): void {
|
||||||
if(!smc.mission.play||smc.mission.pause){
|
if(!smc.mission.play||smc.mission.pause){
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if(smc.vmdata.mission_data.in_fight){
|
if(smc.vmdata.mission_data.in_fight){
|
||||||
smc.vmdata.mission_data.fight_time+=dt
|
smc.vmdata.mission_data.fight_time+=dt
|
||||||
if(this.GlodAddTimer.update(dt)){
|
|
||||||
smc.vmdata.mission_data.gold+=(smc.vmdata.mission_data.add_gold+smc.vmdata.mission_data.buff_add_gold)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(this.is_show_time){
|
|
||||||
if(this.time_cd.update(dt)){
|
|
||||||
this.run_time()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// if(this.is_in_wave){
|
|
||||||
// if(this.wave_time_cd.update(dt)){
|
|
||||||
// smc.vmdata.mission_data.wave_time_num--
|
|
||||||
// if(smc.vmdata.mission_data.wave_time_num<=0){
|
|
||||||
// this.hide_wave_time()
|
|
||||||
// this.show_time(this.do_next_wave.bind(this))
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
//奖励发放
|
//奖励发放
|
||||||
do_reward(){
|
do_reward(){
|
||||||
// 奖励发放
|
// 奖励发放
|
||||||
}
|
}
|
||||||
hero_called(event: any, data: any) {
|
|
||||||
// 查找空位或已存在的英雄
|
|
||||||
const heroIndex = this.findHeroSlot(data.uuid);
|
|
||||||
|
|
||||||
if (heroIndex !== -1) {
|
|
||||||
// 找到英雄位置,增加数量
|
|
||||||
this.heros[heroIndex].count += 1;
|
|
||||||
} else {
|
|
||||||
// 查找空位
|
|
||||||
const emptySlot = this.findEmptySlot();
|
|
||||||
if (emptySlot !== -1) {
|
|
||||||
// 有空位,添加新英雄
|
|
||||||
this.heros[emptySlot].uuid = data.uuid;
|
|
||||||
this.heros[emptySlot].count = 1;
|
|
||||||
} else {
|
|
||||||
console.log("[MissionComp] 英雄已满");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查找英雄位置
|
|
||||||
* @param uuid 英雄UUID
|
|
||||||
* @returns 英雄索引,未找到返回-1
|
|
||||||
*/
|
|
||||||
private findHeroSlot(uuid: number): number {
|
|
||||||
for (let i = 0; i < 3; i++) {
|
|
||||||
if (this.heros[i].uuid === uuid) {
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查找空位
|
|
||||||
* @returns 空位索引,无空位返回-1
|
|
||||||
*/
|
|
||||||
private findEmptySlot(): number {
|
|
||||||
for (let i = 0; i < 3; i++) {
|
|
||||||
if (this.heros[i].uuid === 0) {
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
count_tal(){
|
|
||||||
let count=0
|
|
||||||
for(let i=0;i<FightSet.TAL_NUM;i++){
|
|
||||||
if(this.tals[i]){
|
|
||||||
count++
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return count
|
|
||||||
}
|
|
||||||
|
|
||||||
do_mon_dead(){
|
do_mon_dead(){
|
||||||
this.do_mon_dead_thing()
|
this.do_mon_dead_thing()
|
||||||
@@ -164,7 +54,6 @@ export class MissionComp extends CCComp {
|
|||||||
// this.tals[this.count_tal()]=true
|
// this.tals[this.count_tal()]=true
|
||||||
|
|
||||||
// }
|
// }
|
||||||
this.show_time(this.do_next_wave.bind(this))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -172,13 +61,6 @@ export class MissionComp extends CCComp {
|
|||||||
smc.vmdata.mission_data.gold+=smc.vmdata.mission_data.add_gold+smc.vmdata.mission_data.buff_add_gold
|
smc.vmdata.mission_data.gold+=smc.vmdata.mission_data.add_gold+smc.vmdata.mission_data.buff_add_gold
|
||||||
}
|
}
|
||||||
|
|
||||||
do_next_wave(){ //怪物死亡后,重置时间
|
|
||||||
smc.vmdata.mission_data.current_wave++
|
|
||||||
smc.vmdata.mission_data.refresh_count++
|
|
||||||
oops.message.dispatchEvent(GameEvent.NewWave)
|
|
||||||
this.show_wave_time()
|
|
||||||
}
|
|
||||||
|
|
||||||
do_ad(){
|
do_ad(){
|
||||||
if(this.ad_back()){
|
if(this.ad_back()){
|
||||||
oops.message.dispatchEvent(GameEvent.AD_BACK_TRUE)
|
oops.message.dispatchEvent(GameEvent.AD_BACK_TRUE)
|
||||||
@@ -194,50 +76,6 @@ export class MissionComp extends CCComp {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
show_wave_time(){
|
|
||||||
smc.vmdata.mission_data.wave_time_num=FightSet.ONE_WAVE_TIME
|
|
||||||
this.is_in_wave=true
|
|
||||||
}
|
|
||||||
|
|
||||||
hide_wave_time(){
|
|
||||||
this.is_in_wave=false
|
|
||||||
}
|
|
||||||
|
|
||||||
show_time(onHide?:Function){
|
|
||||||
this.time_num=FightSet.DOWN_TIME
|
|
||||||
this.node.getChildByName("time").active=true
|
|
||||||
this.is_show_time=true
|
|
||||||
this.run_time()
|
|
||||||
this.next_func=onHide
|
|
||||||
}
|
|
||||||
hide_time(){
|
|
||||||
if(this.next_func){
|
|
||||||
this.next_func()
|
|
||||||
}
|
|
||||||
this.node.getChildByName("time").active=false
|
|
||||||
this.is_show_time=false
|
|
||||||
this.next_func=undefined
|
|
||||||
this.time_cd.reset()
|
|
||||||
}
|
|
||||||
clear_time(){
|
|
||||||
this.node.getChildByName("time").active=false
|
|
||||||
this.is_show_time=false
|
|
||||||
this.next_func=undefined
|
|
||||||
this.time_cd.reset()
|
|
||||||
}
|
|
||||||
run_time(){
|
|
||||||
this.node.getChildByName("time").setScale(0,0,0)
|
|
||||||
tween(this.node.getChildByName("time"))
|
|
||||||
.to(0.2, {scale:v3(1,1,1)}, {easing:"backOut"})
|
|
||||||
.to(0.2, {scale:v3(0,0,0)}, {easing:"backIn"})
|
|
||||||
.start()
|
|
||||||
this.time_num--
|
|
||||||
this.node.getChildByName("time").getChildByName("time").getComponent(Label).string=this.time_num.toString()
|
|
||||||
if(this.time_num<=0){
|
|
||||||
this.hide_time()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
async mission_start(){
|
async mission_start(){
|
||||||
console.log("[MissionComp] ** 1 ** mission_start")
|
console.log("[MissionComp] ** 1 ** mission_start")
|
||||||
@@ -252,41 +90,14 @@ export class MissionComp extends CCComp {
|
|||||||
loading.active=false
|
loading.active=false
|
||||||
this.node.getChildByName("ending").active=false
|
this.node.getChildByName("ending").active=false
|
||||||
},1)
|
},1)
|
||||||
this.to_ready()
|
this.to_fight()
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
to_ready(){
|
|
||||||
console.log("[MissionComp] ** 2 ** to_ready")
|
|
||||||
oops.message.dispatchEvent(GameEvent.HeroSelect,{called:[]})
|
|
||||||
}
|
|
||||||
ready_to_fight(){
|
|
||||||
console.log("[MissionComp] ** 3 ** ready_to_fight")
|
|
||||||
this.time_num=5
|
|
||||||
this.show_time(this.to_fight.bind(this))
|
|
||||||
}
|
|
||||||
// show_uplv_button(){
|
|
||||||
// this.update_count++
|
|
||||||
// this.node.getChildByName("uplv").active=true
|
|
||||||
// }
|
|
||||||
// hide_uplv_button(){
|
|
||||||
// this.update_count--
|
|
||||||
// if(this.update_count > 0) return
|
|
||||||
// this.node.getChildByName("uplv").active=false
|
|
||||||
// }
|
|
||||||
// to_uplv(){
|
|
||||||
// oops.message.dispatchEvent(GameEvent.EnhancementSelect)
|
|
||||||
// }
|
|
||||||
to_call_friend(){
|
|
||||||
let called = Object.values(this.heros).filter((item: any) => item.uuid != 0)
|
|
||||||
oops.message.dispatchEvent(GameEvent.HeroSelect,{called:called})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
to_fight(){
|
to_fight(){
|
||||||
console.log("[MissionComp] ** 4 ** to_fight")
|
console.log("[MissionComp] ** 3 ** to_fight")
|
||||||
smc.vmdata.mission_data.in_fight=true
|
smc.vmdata.mission_data.in_fight=true
|
||||||
oops.message.dispatchEvent(GameEvent.FightStart) //MissionMonComp 监听刷怪
|
oops.message.dispatchEvent(GameEvent.FightStart) //MissionMonComp 监听刷怪
|
||||||
this.do_next_wave()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -316,86 +127,9 @@ export class MissionComp extends CCComp {
|
|||||||
//局内数据初始化 smc 数据初始化
|
//局内数据初始化 smc 数据初始化
|
||||||
smc.mission.play = true;
|
smc.mission.play = true;
|
||||||
smc.vmdata.mission_data = JSON.parse(JSON.stringify(MissionData));
|
smc.vmdata.mission_data = JSON.parse(JSON.stringify(MissionData));
|
||||||
smc.vmdata.hero = JSON.parse(JSON.stringify(VmInfo));
|
console.log("局内数据初始化")
|
||||||
smc.vmdata.boss = JSON.parse(JSON.stringify(VmInfo));
|
|
||||||
this.update_count=0
|
|
||||||
this.GlodAddTimer=new Timer(smc.vmdata.mission_data.refrsh_time)
|
|
||||||
smc.enhancements=defaultEnhancements()
|
|
||||||
this.heros={
|
|
||||||
0:{uuid:0,count:0},
|
|
||||||
1:{uuid:0,count:0},
|
|
||||||
2:{uuid:0,count:0},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.clear_time()
|
|
||||||
this.hide_wave_time()
|
|
||||||
this.tals={
|
|
||||||
0:false,
|
|
||||||
1:false,
|
|
||||||
2:false,
|
|
||||||
3:false,
|
|
||||||
4:false,
|
|
||||||
5:false,
|
|
||||||
}
|
|
||||||
smc.vmdata.mission_data.wave_time_num=FightSet.ONE_WAVE_TIME
|
|
||||||
console.log("局内数据初始化",smc.enhancements,defaultEnhancements())
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
card_init(){
|
|
||||||
oops.message.dispatchEvent(GameEvent.CardRefresh)
|
|
||||||
}
|
|
||||||
|
|
||||||
card_refresh(){
|
|
||||||
let mission_data=smc.vmdata.mission_data
|
|
||||||
if(mission_data.gold < (mission_data.refresh_gold+mission_data.buff_refresh_gold)){
|
|
||||||
oops.gui.toast("金币不足", false);
|
|
||||||
return
|
|
||||||
}
|
|
||||||
oops.message.dispatchEvent(GameEvent.CardRefresh)
|
|
||||||
mission_data.gold-=(mission_data.refresh_gold+mission_data.buff_refresh_gold)
|
|
||||||
|
|
||||||
}
|
|
||||||
call_friend_card(){
|
|
||||||
oops.message.dispatchEvent(GameEvent.HeroSelect)
|
|
||||||
}
|
|
||||||
call_tal_card(){
|
|
||||||
oops.message.dispatchEvent(GameEvent.TalentSelect)
|
|
||||||
}
|
|
||||||
call_func_card(){
|
|
||||||
if(smc.vmdata.mission_data.gold < smc.vmdata.mission_data.lucky_gold){
|
|
||||||
oops.gui.toast("金币不足", false);
|
|
||||||
return
|
|
||||||
}
|
|
||||||
this.do_lucky_card()
|
|
||||||
|
|
||||||
}
|
|
||||||
do_lucky_card(){
|
|
||||||
smc.vmdata.mission_data.gold-=smc.vmdata.mission_data.lucky_gold
|
|
||||||
let list=getRandomCardsByType(cardType.SPECIAL,1)
|
|
||||||
let card=SuperCards[list[0].uuid]
|
|
||||||
console.log("[MissionComp] do_lucky_card",card)
|
|
||||||
this.show_lucky_gold(card)
|
|
||||||
oops.message.dispatchEvent(GameEvent.LuckCardUsed,card)
|
|
||||||
}
|
|
||||||
show_lucky_gold(card:any){
|
|
||||||
// this.node.getChildByName("luckybox").getComponent(Animation).play("luckyopen")
|
|
||||||
var path = "game/gui/lcard";
|
|
||||||
var prefab: Prefab = oops.res.get(path, Prefab)!;
|
|
||||||
var node = instantiate(prefab);
|
|
||||||
node.setScale(0,0,0)
|
|
||||||
node.getComponent(LuckCardComp).show_card(card)
|
|
||||||
node.parent = this.node
|
|
||||||
node.setPosition(v3(this.node.getChildByName("luckybox").position.x,this.node.getChildByName("luckybox").position.y));
|
|
||||||
let height=this.node.getComponent(UITransform).height
|
|
||||||
tween(node) .to(1, {
|
|
||||||
scale: v3(1,1,1),
|
|
||||||
position: v3(0, height-300),
|
|
||||||
}, {easing:"backOut"})
|
|
||||||
.start();
|
|
||||||
|
|
||||||
}
|
|
||||||
private cleanComponents() {
|
private cleanComponents() {
|
||||||
smc.vmdata.hero1=JSON.parse(JSON.stringify(HeroUI))
|
smc.vmdata.hero1=JSON.parse(JSON.stringify(HeroUI))
|
||||||
smc.vmdata.hero2=JSON.parse(JSON.stringify(HeroUI))
|
smc.vmdata.hero2=JSON.parse(JSON.stringify(HeroUI))
|
||||||
|
|||||||
@@ -26,21 +26,34 @@ export class MissionHeroCompComp extends CCComp {
|
|||||||
this.on(GameEvent.UseHeroCard,this.call_hero,this)
|
this.on(GameEvent.UseHeroCard,this.call_hero,this)
|
||||||
this.on(GameEvent.FightReady,this.fight_ready,this)
|
this.on(GameEvent.FightReady,this.fight_ready,this)
|
||||||
this.on(GameEvent.Zhaohuan,this.zhao_huan,this)
|
this.on(GameEvent.Zhaohuan,this.zhao_huan,this)
|
||||||
|
this.on(GameEvent.FightEnd,this.clear_heros,this)
|
||||||
}
|
}
|
||||||
start() {
|
start() {
|
||||||
// this.test_call()
|
// this.test_call()
|
||||||
}
|
}
|
||||||
fight_ready(){
|
clear_heros(){
|
||||||
this.heros=[]
|
console.log("[MissionHeroComp]: FightEnd clear heros")
|
||||||
for(let i=0;i<FightSet.HERO_MAX_NUM;i++){
|
|
||||||
this.heros.push({
|
}
|
||||||
uuid:0,
|
fight_ready(){
|
||||||
count:0,
|
// this.heros=[]
|
||||||
quality:0,
|
// for(let i=0;i<FightSet.HERO_MAX_NUM;i++){
|
||||||
})
|
// this.heros.push({
|
||||||
|
// uuid:0,
|
||||||
|
// count:0,
|
||||||
|
// quality:0,
|
||||||
|
// })
|
||||||
|
// }
|
||||||
|
// this.current_hero_num=-1
|
||||||
|
// this.current_hero_uuid=0
|
||||||
|
console.log("[MissionHeroComp]:fight_ready",smc.fight_heros,Object.keys(smc.fight_heros).length)
|
||||||
|
let heros:any = smc.fight_heros
|
||||||
|
for(let i=0;i<Object.keys(heros).length;i++){
|
||||||
|
if(heros[i]!=0){
|
||||||
|
console.log("[MissionHeroComp]:fight_ready",heros[i])
|
||||||
|
this.addHero(heros[i],false)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
this.current_hero_num=-1
|
|
||||||
this.current_hero_uuid=0
|
|
||||||
}
|
}
|
||||||
protected update(dt: number): void {
|
protected update(dt: number): void {
|
||||||
if(smc.mission.status != 1) return
|
if(smc.mission.status != 1) return
|
||||||
@@ -105,6 +118,7 @@ export class MissionHeroCompComp extends CCComp {
|
|||||||
|
|
||||||
/** 添加英雄 */
|
/** 添加英雄 */
|
||||||
private addHero(uuid:number=1001,is_zhaohuan:boolean=false) {
|
private addHero(uuid:number=1001,is_zhaohuan:boolean=false) {
|
||||||
|
console.log("[MissionHeroComp]:addHero",uuid,is_zhaohuan)
|
||||||
let hero_pos=0
|
let hero_pos=0
|
||||||
let hero = ecs.getEntity<Hero>(Hero);
|
let hero = ecs.getEntity<Hero>(Hero);
|
||||||
let scale = 1
|
let scale = 1
|
||||||
|
|||||||
@@ -12,49 +12,27 @@ const { ccclass, property } = _decorator;
|
|||||||
@ecs.register('MissionHome', false)
|
@ecs.register('MissionHome', false)
|
||||||
export class MissionHomeComp extends CCComp {
|
export class MissionHomeComp extends CCComp {
|
||||||
|
|
||||||
heros:any[]=[];
|
|
||||||
heros_pos:any=[
|
|
||||||
{uuid:0,px:-100},
|
|
||||||
{uuid:0,px:-200},
|
|
||||||
{uuid:0,px:-300},
|
|
||||||
]
|
|
||||||
protected onLoad(): void {
|
protected onLoad(): void {
|
||||||
this.on(GameEvent.MissionEnd,this.mission_end,this)
|
this.on(GameEvent.MissionEnd,this.mission_end,this)
|
||||||
}
|
}
|
||||||
/** 视图层逻辑代码分离演示 */
|
/** 视图层逻辑代码分离演示 */
|
||||||
start() {
|
start() {
|
||||||
// var entity = this.ent as ecs.Entity; // ecs.Entity 可转为当前模块的具体实体对象
|
this.home_active()
|
||||||
// this.on(ModuleEvent.Cmd, this.onHandler, this);
|
|
||||||
this.load_ui_heros()
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
to_start(){
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
start_mission() {
|
start_mission() {
|
||||||
for(let i=0;i<this.heros.length;i++){
|
|
||||||
this.heros[i].to_destroy()
|
|
||||||
}
|
|
||||||
this.heros=[]
|
|
||||||
this.heros_pos=[
|
|
||||||
{uuid:0,px:-100},
|
|
||||||
{uuid:0,px:-200},
|
|
||||||
{uuid:0,px:-300},
|
|
||||||
]
|
|
||||||
oops.message.dispatchEvent(GameEvent.MissionStart, {})
|
oops.message.dispatchEvent(GameEvent.MissionStart, {})
|
||||||
this.node.active=false;
|
this.node.active=false;
|
||||||
}
|
}
|
||||||
mission_end(){
|
mission_end(){
|
||||||
|
this.home_active()
|
||||||
|
}
|
||||||
|
home_active(){
|
||||||
this.node.active=true
|
this.node.active=true
|
||||||
|
oops.message.dispatchEvent(GameEvent.UpdateHero, {})
|
||||||
}
|
}
|
||||||
|
|
||||||
load_ui_heros(){
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */
|
/** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */
|
||||||
|
|||||||
@@ -38,7 +38,9 @@ export class MissionMonCompComp extends CCComp { // 添加刷怪队列 - 扩
|
|||||||
|
|
||||||
|
|
||||||
onLoad(){
|
onLoad(){
|
||||||
this.on(GameEvent.NewWave,this.do_mon_wave,this)
|
// this.on(GameEvent.NewWave,this.do_mon_wave,this)
|
||||||
|
this.on(GameEvent.FightReady,this.fight_ready,this)
|
||||||
|
|
||||||
}
|
}
|
||||||
/** 视图层逻辑代码分离演示 */
|
/** 视图层逻辑代码分离演示 */
|
||||||
start() {
|
start() {
|
||||||
@@ -46,6 +48,11 @@ export class MissionMonCompComp extends CCComp { // 添加刷怪队列 - 扩
|
|||||||
// this.on(ModuleEvent.Cmd, this.onHandler, this);
|
// this.on(ModuleEvent.Cmd, this.onHandler, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fight_ready(){
|
||||||
|
console.log("[MissionMonComp]:fight_ready")
|
||||||
|
this.do_mon_wave()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
protected update(dt: number): void {
|
protected update(dt: number): void {
|
||||||
if(!smc.mission.play||smc.mission.pause) return
|
if(!smc.mission.play||smc.mission.pause) return
|
||||||
|
|||||||
@@ -16,8 +16,8 @@ export class move extends Component {
|
|||||||
|
|
||||||
@property({ type: CCInteger })
|
@property({ type: CCInteger })
|
||||||
sc: number = 1; // 1: 从左到右, -1: 从右到左
|
sc: number = 1; // 1: 从左到右, -1: 从右到左
|
||||||
@property({ type: CCBoolean })
|
@property({ type: CCInteger })
|
||||||
isMove:boolean=false
|
isMove:number=0
|
||||||
protected onLoad(): void {
|
protected onLoad(): void {
|
||||||
oops.message.on(GameEvent.MAP_MOVE_END_LEFT, this.onMapMoveEndLeft, this);
|
oops.message.on(GameEvent.MAP_MOVE_END_LEFT, this.onMapMoveEndLeft, this);
|
||||||
oops.message.on(GameEvent.MAP_MOVE_END_RIGHT, this.onMapMoveEndRight, this);
|
oops.message.on(GameEvent.MAP_MOVE_END_RIGHT, this.onMapMoveEndRight, this);
|
||||||
@@ -27,13 +27,13 @@ export class move extends Component {
|
|||||||
}
|
}
|
||||||
onMapMoveEndLeft() {
|
onMapMoveEndLeft() {
|
||||||
if(this.sc==-1){
|
if(this.sc==-1){
|
||||||
this.isMove=true
|
this.isMove=1
|
||||||
this.setInitialPosition()
|
this.setInitialPosition()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
onMapMoveEndRight() {
|
onMapMoveEndRight() {
|
||||||
if(this.sc==1){
|
if(this.sc==1){
|
||||||
this.isMove=true
|
this.isMove=1
|
||||||
this.setInitialPosition()
|
this.setInitialPosition()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -52,7 +52,7 @@ export class move extends Component {
|
|||||||
|
|
||||||
update(dt: number) {
|
update(dt: number) {
|
||||||
// 更新位置
|
// 更新位置
|
||||||
if(this.isMove){
|
if(this.isMove==1){
|
||||||
const newX = this.node.position.x + dt * this.speed * this.sc;
|
const newX = this.node.position.x + dt * this.speed * this.sc;
|
||||||
this.node.setPosition(newX, this.node.position.y);
|
this.node.setPosition(newX, this.node.position.y);
|
||||||
// 检查边界并重置位置
|
// 检查边界并重置位置
|
||||||
@@ -68,14 +68,14 @@ export class move extends Component {
|
|||||||
// 从左到右移动,到达右边界后回到左边界
|
// 从左到右移动,到达右边界后回到左边界
|
||||||
if (this.node.position.x >= this.maxX) {
|
if (this.node.position.x >= this.maxX) {
|
||||||
this.node.setPosition(this.minX, this.node.position.y);
|
this.node.setPosition(this.minX, this.node.position.y);
|
||||||
this.isMove=false
|
this.isMove=0
|
||||||
oops.message.dispatchEvent(GameEvent.MAP_MOVE_END_LEFT)
|
oops.message.dispatchEvent(GameEvent.MAP_MOVE_END_LEFT)
|
||||||
}
|
}
|
||||||
} else if (this.sc < 0) {
|
} else if (this.sc < 0) {
|
||||||
// 从右到左移动,到达左边界后回到右边界
|
// 从右到左移动,到达左边界后回到右边界
|
||||||
if (this.node.position.x <= this.minX) {
|
if (this.node.position.x <= this.minX) {
|
||||||
this.node.setPosition(this.maxX, this.node.position.y);
|
this.node.setPosition(this.maxX, this.node.position.y);
|
||||||
this.isMove=false
|
this.isMove=0
|
||||||
oops.message.dispatchEvent(GameEvent.MAP_MOVE_END_RIGHT)
|
oops.message.dispatchEvent(GameEvent.MAP_MOVE_END_RIGHT)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,12 +67,12 @@ export class SkillCom extends CCComp {
|
|||||||
// 缓存技能配置,避免重复查找
|
// 缓存技能配置,避免重复查找
|
||||||
this.skillConfig = SkillSet[this.s_uuid];
|
this.skillConfig = SkillSet[this.s_uuid];
|
||||||
if (!this.skillConfig) {
|
if (!this.skillConfig) {
|
||||||
console.error("[SkillCom] 技能配置不存在:", this.s_uuid);
|
// console.error("[SkillCom] 技能配置不存在:", this.s_uuid);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.isInitialized = true;
|
this.isInitialized = true;
|
||||||
console.log("[SkillCom] 技能配置初始化完成:", this.s_uuid, this.skillConfig.name);
|
// console.log("[SkillCom] 技能配置初始化完成:", this.s_uuid, this.skillConfig.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
start() {
|
start() {
|
||||||
@@ -157,7 +157,7 @@ export class SkillCom extends CCComp {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
onAnimationFinished(){
|
onAnimationFinished(){
|
||||||
console.log("[SkillCom]:onAnimationFinished",this.s_uuid)
|
// console.log("[SkillCom]:onAnimationFinished",this.s_uuid)
|
||||||
if (!this.skillConfig) return;
|
if (!this.skillConfig) return;
|
||||||
|
|
||||||
if(this.skillConfig.EType==EType.timeEnd) return
|
if(this.skillConfig.EType==EType.timeEnd) return
|
||||||
|
|||||||
Reference in New Issue
Block a user