属性弹窗++
This commit is contained in:
File diff suppressed because it is too large
Load Diff
102
assets/script/game/common/EnhancedButtonTouchLong.ts
Normal file
102
assets/script/game/common/EnhancedButtonTouchLong.ts
Normal file
@@ -0,0 +1,102 @@
|
|||||||
|
import { EventHandler, EventTouch, _decorator } from "cc";
|
||||||
|
import { ButtonTouchLong } from "../../../../extensions/oops-plugin-framework/assets/libs/gui/button/ButtonTouchLong";
|
||||||
|
|
||||||
|
const { ccclass, property, menu } = _decorator;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 增强版长按按钮组件
|
||||||
|
* 支持长按触发和放开后触发两种事件
|
||||||
|
*/
|
||||||
|
@ccclass("EnhancedButtonTouchLong")
|
||||||
|
@menu('ui/button/EnhancedButtonTouchLong')
|
||||||
|
export class EnhancedButtonTouchLong extends ButtonTouchLong {
|
||||||
|
|
||||||
|
@property({
|
||||||
|
type: [EventHandler],
|
||||||
|
tooltip: "放开后触发的事件"
|
||||||
|
})
|
||||||
|
releaseEvents: EventHandler[] = [];
|
||||||
|
|
||||||
|
@property({
|
||||||
|
tooltip: "是否在长按后放开时触发事件"
|
||||||
|
})
|
||||||
|
triggerOnRelease: boolean = true;
|
||||||
|
|
||||||
|
@property({
|
||||||
|
tooltip: "是否在短按时也触发放开事件"
|
||||||
|
})
|
||||||
|
triggerOnShortPress: boolean = false;
|
||||||
|
|
||||||
|
private _wasLongPressed: boolean = false;
|
||||||
|
private _hasTriggeredRelease: boolean = false;
|
||||||
|
|
||||||
|
onLoad() {
|
||||||
|
super.onLoad();
|
||||||
|
this._wasLongPressed = false;
|
||||||
|
this._hasTriggeredRelease = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 触摸开始 */
|
||||||
|
onTouchtStart(event: EventTouch) {
|
||||||
|
this._wasLongPressed = false;
|
||||||
|
this._hasTriggeredRelease = false;
|
||||||
|
super.onTouchtStart(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 触摸结束 */
|
||||||
|
onTouchEnd(event: EventTouch) {
|
||||||
|
// 检查是否已经长按过
|
||||||
|
if (this._passTime > this.time) {
|
||||||
|
this._wasLongPressed = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 触发放开事件
|
||||||
|
if (this.triggerOnRelease && !this._hasTriggeredRelease) {
|
||||||
|
if (this._wasLongPressed || this.triggerOnShortPress) {
|
||||||
|
this._hasTriggeredRelease = true;
|
||||||
|
this.onReleaseTrigger();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
super.onTouchEnd(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 引擎更新事件 */
|
||||||
|
update(dt: number) {
|
||||||
|
super.update(dt);
|
||||||
|
|
||||||
|
// 在父类的update中,如果触发了长按事件,标记为已长按
|
||||||
|
if (this._passTime >= this.time && !this._isTouchLong) {
|
||||||
|
this._wasLongPressed = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 放开触发回调
|
||||||
|
*/
|
||||||
|
protected onReleaseTrigger() {
|
||||||
|
// 发送自定义事件
|
||||||
|
this.node.emit('releaseTrigger', this);
|
||||||
|
|
||||||
|
// 触发配置的事件
|
||||||
|
this.releaseEvents.forEach(event => {
|
||||||
|
event.emit([event.customEventData]);
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log('放开触发!');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取是否已经长按过
|
||||||
|
*/
|
||||||
|
wasLongPressed(): boolean {
|
||||||
|
return this._wasLongPressed;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取当前按住时间
|
||||||
|
*/
|
||||||
|
getPassTime(): number {
|
||||||
|
return this._passTime;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"ver": "4.0.23",
|
||||||
|
"importer": "typescript",
|
||||||
|
"imported": true,
|
||||||
|
"uuid": "caba3955-8e72-4e90-8666-0d0ee57797d9",
|
||||||
|
"files": [],
|
||||||
|
"subMetas": {},
|
||||||
|
"userData": {}
|
||||||
|
}
|
||||||
@@ -55,6 +55,10 @@ export class SingletonModuleComp extends ecs.Comp {
|
|||||||
dod:99,
|
dod:99,
|
||||||
dod_no:false,
|
dod_no:false,
|
||||||
crit_no:false,
|
crit_no:false,
|
||||||
|
wind:0,
|
||||||
|
thorns:0,
|
||||||
|
lifesteal:0,
|
||||||
|
|
||||||
},
|
},
|
||||||
friend:{
|
friend:{
|
||||||
hp:0,
|
hp:0,
|
||||||
@@ -72,6 +76,9 @@ export class SingletonModuleComp extends ecs.Comp {
|
|||||||
dod:99,
|
dod:99,
|
||||||
dod_no:false,
|
dod_no:false,
|
||||||
crit_no:false,
|
crit_no:false,
|
||||||
|
wind:0,
|
||||||
|
thorns:0,
|
||||||
|
lifesteal:0,
|
||||||
},
|
},
|
||||||
boss:{
|
boss:{
|
||||||
hp:0,
|
hp:0,
|
||||||
@@ -89,6 +96,9 @@ export class SingletonModuleComp extends ecs.Comp {
|
|||||||
dod:99,
|
dod:99,
|
||||||
dod_no:false,
|
dod_no:false,
|
||||||
crit_no:false,
|
crit_no:false,
|
||||||
|
wind:0,
|
||||||
|
thorns:0,
|
||||||
|
lifesteal:0,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
vmAdd() {
|
vmAdd() {
|
||||||
|
|||||||
@@ -52,16 +52,16 @@ export const MissionStatus = {
|
|||||||
end:4,
|
end:4,
|
||||||
}
|
}
|
||||||
export enum FightSet {
|
export enum FightSet {
|
||||||
FRIEND_WAVE_UP=2, //伙伴登场波次
|
FRIEND_WAVE_UP=3, //伙伴登场波次
|
||||||
BOSS_WAVE_UP_1=3, //boss登场波次
|
BOSS_WAVE_UP_1=3, //boss登场波次
|
||||||
BOSS_WAVE_UP_2=5, //boss登场波次
|
BOSS_WAVE_UP_2=5, //boss登场波次
|
||||||
BOSS_WAVE_UP_3=7, //boss登场波次
|
BOSS_WAVE_UP_3=7, //boss登场波次
|
||||||
EQUIP_WAVE_UP_1=4, //装备登场波次
|
EQUIP_WAVE_UP_1=4, //装备登场波次
|
||||||
EQUIP_WAVE_UP_2=6, //装备登场波次
|
EQUIP_WAVE_UP_2=6, //装备登场波次
|
||||||
EQUIP_WAVE_UP_3=8, //装备登场波次
|
EQUIP_WAVE_UP_3=8, //装备登场波次
|
||||||
SKILL_WAVE_UP_1=1, //技能登场波次
|
SKILL_WAVE_UP_1=2, //技能登场波次
|
||||||
SKILL_WAVE_UP_2=3, //技能登场波次
|
SKILL_WAVE_UP_2=5, //技能登场波次
|
||||||
SKILL_WAVE_UP_3=5, //技能登场波次
|
SKILL_WAVE_UP_3=7, //技能登场波次
|
||||||
MON_WAVE_TIME=10,//怪物波次时间
|
MON_WAVE_TIME=10,//怪物波次时间
|
||||||
FRIEND_LIVE_CD=10,//伙伴复活时间
|
FRIEND_LIVE_CD=10,//伙伴复活时间
|
||||||
ATK_ADD_FRIEND_COUNT=4,//伙伴攻击力增加
|
ATK_ADD_FRIEND_COUNT=4,//伙伴攻击力增加
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
import { _decorator, Label, Node, ProgressBar } from "cc";
|
import { _decorator, Label, Node, ProgressBar, tween, v3 } from "cc";
|
||||||
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
|
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
|
||||||
import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
|
import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
|
||||||
|
import { ButtonTouchLong } from "../../../../extensions/oops-plugin-framework/assets/libs/gui/button/ButtonTouchLong";
|
||||||
|
import { EnhancedButtonTouchLong } from "../common/EnhancedButtonTouchLong";
|
||||||
import { GameEvent } from "../common/config/GameEvent";
|
import { GameEvent } from "../common/config/GameEvent";
|
||||||
import { HeroViewComp } from "../hero/HeroViewComp";
|
import { HeroViewComp } from "../hero/HeroViewComp";
|
||||||
import { HeroModelComp } from "../hero/HeroModelComp";
|
import { HeroModelComp } from "../hero/HeroModelComp";
|
||||||
@@ -13,50 +15,70 @@ const { ccclass, property } = _decorator;
|
|||||||
@ccclass('BarCompComp')
|
@ccclass('BarCompComp')
|
||||||
@ecs.register('BarComp', false)
|
@ecs.register('BarComp', false)
|
||||||
export class BarCompComp extends CCComp {
|
export class BarCompComp extends CCComp {
|
||||||
hero_bar:Node = null;
|
|
||||||
friend_bar:Node = null;
|
|
||||||
boss_bar:Node = null;
|
|
||||||
hero:HeroViewComp = null;
|
hero:HeroViewComp = null;
|
||||||
friend:HeroViewComp = null;
|
friend:HeroViewComp = null;
|
||||||
boss:HeroViewComp = null;
|
boss:HeroViewComp = null;
|
||||||
/** 视图层逻辑代码分离演示 */
|
/** 视图层逻辑代码分离演示 */
|
||||||
protected onLoad(): void {
|
protected onLoad(): void {
|
||||||
this.on(GameEvent.FightReady,this.readay,this)
|
this.on(GameEvent.FightReady,this.readay,this)
|
||||||
|
this.on(GameEvent.FriendCalled,this.friend_called,this)
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
start() {
|
start() {
|
||||||
// this.hero_bar = this.node.getChildByName("bar");
|
|
||||||
// this.friend_bar = this.node.getChildByName("fbar");
|
|
||||||
// this.boss_bar = this.node.getChildByName("bar");
|
// this.boss_bar = this.node.getChildByName("bar");
|
||||||
// var entity = this.ent as ecs.Entity; // ecs.Entity 可转为当前模块的具体实体对象
|
// var entity = this.ent as ecs.Entity; // ecs.Entity 可转为当前模块的具体实体对象
|
||||||
// this.on(ModuleEvent.Cmd, this.onHandler, this);
|
// this.on(ModuleEvent.Cmd, this.onHandler, this);
|
||||||
}
|
}
|
||||||
private readay(){
|
private readay(){
|
||||||
this.hero_bar.active = this.get_hero()
|
this.node.getChildByName("bar").active = true
|
||||||
this.friend_bar.active = this.get_friend()
|
this.node.getChildByName("fbar").active = false
|
||||||
|
this.node.getChildByName("bar").getChildByName("more").active=false
|
||||||
|
this.node.getChildByName("fbar").getChildByName("more").active=false
|
||||||
|
}
|
||||||
|
private friend_called(){
|
||||||
|
this.node.getChildByName("fbar").active=true
|
||||||
}
|
}
|
||||||
|
|
||||||
private get_hero(){
|
show_master_more(){
|
||||||
let heros = ecs.query(ecs.allOf(MasterModelComp))
|
let barNode = this.node.getChildByName("bar");
|
||||||
if(heros.length > 0){
|
let node = barNode.getChildByName("more");
|
||||||
this.hero = heros[0].get(HeroViewComp)
|
node.active = true;
|
||||||
return true
|
node.setScale(v3(1, 0, 1));
|
||||||
}else{
|
console.log("[barcomp]:show_master_more",node)
|
||||||
this.hero = null
|
// 使用缓动动画放大和移动
|
||||||
return false
|
tween(node).to(0.2, {scale:v3(1,1,1)}).start()
|
||||||
}
|
|
||||||
}
|
}
|
||||||
private get_friend(){
|
|
||||||
let friend = ecs.query(ecs.allOf(FriendModelComp))
|
hide_master_more(){
|
||||||
if(friend.length > 0){
|
let barNode = this.node.getChildByName("bar");
|
||||||
this.friend = friend[0].get(HeroViewComp)
|
let node = barNode.getChildByName("more");
|
||||||
return true
|
console.log("[barcomp]:hide_master_more",node)
|
||||||
}else{
|
// 使用缓动动画放大和移动
|
||||||
this.friend = null
|
tween(node).to(0.2, {scale:v3(1,0,1)}).start()
|
||||||
return false
|
node.active = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
show_friend_more(){
|
||||||
|
let barNode = this.node.getChildByName("fbar");
|
||||||
|
let node = barNode.getChildByName("more");
|
||||||
|
node.active = true;
|
||||||
|
node.setScale(v3(1, 0, 1));
|
||||||
|
console.log("[barcomp]:show_friend_more",node)
|
||||||
|
// 使用缓动动画放大和移动
|
||||||
|
tween(node).to(0.2, {scale:v3(1,1,1)}).start()
|
||||||
|
}
|
||||||
|
|
||||||
|
hide_friend_more(){
|
||||||
|
let barNode = this.node.getChildByName("fbar");
|
||||||
|
let node = barNode.getChildByName("more");
|
||||||
|
console.log("[barcomp]:hide_friend_more",node)
|
||||||
|
// 使用缓动动画放大和移动
|
||||||
|
tween(node).to(0.2, {scale:v3(1,0,1)}).start()
|
||||||
|
node.active = false;
|
||||||
}
|
}
|
||||||
update_bar(){
|
update_bar(){
|
||||||
if(!this.get_hero()) return
|
|
||||||
|
|
||||||
}
|
}
|
||||||
/** 全局消息逻辑处理 */
|
/** 全局消息逻辑处理 */
|
||||||
@@ -71,4 +93,6 @@ export class BarCompComp extends CCComp {
|
|||||||
reset() {
|
reset() {
|
||||||
this.node.destroy();
|
this.node.destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -30,7 +30,7 @@ export class MissionComp extends CCComp {
|
|||||||
this.on(GameEvent.MissionEnd,this.mission_end,this)
|
this.on(GameEvent.MissionEnd,this.mission_end,this)
|
||||||
// this.on(GameEvent.CardsClose,this.after_used_skill_card,this)
|
// this.on(GameEvent.CardsClose,this.after_used_skill_card,this)
|
||||||
this.on(GameEvent.WaveUpdate,this.on_mon_wave_update,this)
|
this.on(GameEvent.WaveUpdate,this.on_mon_wave_update,this)
|
||||||
this.on(GameEvent.FriendCalled,this.friend_called,this)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected update(dt: number): void {
|
protected update(dt: number): void {
|
||||||
@@ -89,7 +89,6 @@ export class MissionComp extends CCComp {
|
|||||||
|
|
||||||
async mission_start(){
|
async mission_start(){
|
||||||
oops.message.dispatchEvent(GameEvent.FightReady)
|
oops.message.dispatchEvent(GameEvent.FightReady)
|
||||||
this.node.getChildByName("herobar").getChildByName("fbar").active=false //隐藏伙伴栏
|
|
||||||
this.node.active=true
|
this.node.active=true
|
||||||
this.data_init()
|
this.data_init()
|
||||||
this.hart_hero_load()
|
this.hart_hero_load()
|
||||||
@@ -109,9 +108,7 @@ export class MissionComp extends CCComp {
|
|||||||
to_call_friend(){
|
to_call_friend(){
|
||||||
oops.message.dispatchEvent(GameEvent.HeroSelect)
|
oops.message.dispatchEvent(GameEvent.HeroSelect)
|
||||||
}
|
}
|
||||||
friend_called(){
|
|
||||||
this.node.getChildByName("herobar").getChildByName("fbar").active=true
|
|
||||||
}
|
|
||||||
to_fight(){
|
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 监听刷怪
|
||||||
|
|||||||
Reference in New Issue
Block a user