diff --git a/assets/Script/DialogNode/LuckyCoinsNode.ts b/assets/Script/DialogNode/LuckyCoinsNode.ts new file mode 100644 index 0000000..07c3610 --- /dev/null +++ b/assets/Script/DialogNode/LuckyCoinsNode.ts @@ -0,0 +1,185 @@ +/* + * @Author: WoNiu + * @Date: 2024-03-26 11:44:58 + * @LastEditTime: 2024-03-26 15:41:01 + * @LastEditors: WoNiu + * @Description: 幸运硬币效果类型 + */ +import { + _decorator, + Sprite, + Director, + director, + Node, + tween, + UITransform, + v2, + Color, +} from "cc"; +import { AnimationNode } from "../../GlobalScript/Animation/AnimationNode"; +import { BaseSprite } from "../../GlobalScript/CommonComponent/BaseSprite"; +import { NpkImage } from "../../Tool/NPKImage"; +import { CloseButtonNode } from "../Common/CloseButtonNode"; +import { GameRootSingleton } from "../GameRootController"; +import { ShowNodeBorder } from "../../GlobalScript/CommonComponent/ShowNodeBorder"; +const { ccclass, property } = _decorator; + +/** + * @description: 幸运硬币效果类型 + */ +export enum LuckyType { + // 前进三格 + GoThree = 0, + // 移动到月光酒馆 + YeGuangJiuGuan, + // 移动到决斗场 + JueDouChang, + // 移动到海上列车 + HaiShangLieChe, + // 我要双倍,点数x2 + Double, + // 这是我的钱,点数减半 + Halve, + // 骑士马战 ,点数+2w + HorseCombat, + // 装备修理, 点数-2w + Servicing, + // 收取费用,夺取其他人 2w 点数 + Charge, +} + +@ccclass("LuckyCoinsNode") +export class LuckyCoinsNode extends Node { + luckyType: LuckyType; + + // 幸运硬币的结果 + resultNode: Node; + + static show(type: LuckyType) { + const node = new LuckyCoinsNode(type); + GameRootSingleton.getInstance().DialogRootNode.addChild(node); + } + + constructor(type: LuckyType) { + super(); + this.luckyType = type; + + this.addComponent(UITransform).anchorPoint = v2(0, 1); + this.addComponent(ShowNodeBorder); + + this.initResultNode(); + this.initLuckyAni(); + this.delayShowResult(); + } + + initActionButton() { + const node = new CloseButtonNode(() => { + this.initLuckyAni(); + }); + this.addChild(node); + } + + initResultNode() { + const node = new Node(); + this.addChild(node); + + node.setPosition(443, -200); + this.resultNode = node; + + node.active = false; + + const bs = node.addComponent(BaseSprite); + bs.updateSpriteFrame(NpkImage.luckycoin, this.luckyType); + } + + initLuckyAni() { + const lucky = new AnimationNode("ani/luckycoin01.ani", () => { + /// 这一帧结束之后调用 + director.once(Director.EVENT_END_FRAME, () => { + // 销毁,销毁节点只能在当前帧结束后 + lucky.destroy(); + }); + }); + lucky.setPosition(318.5, -107.5); + this.addChild(lucky); + } + + // 延迟显示结果 + delayShowResult() { + setTimeout(() => { + this.resultNode.active = true; + setTimeout(() => { + this.resultTweenDestroy(); + }, 1000); + }, 1600); + } + + // 缓动消失 + resultTweenDestroy() { + + let obj = { x: 255 }; + + tween(obj) + .to(0.5, { x: 1 }, { onUpdate: () => { + const spr = this.resultNode.getComponent(Sprite); + spr.color = new Color(255,255,255,obj.x); + + console.log(spr.color.a + ' - ' + obj.x); + + }, onComplete: () => { + this.resultNode.active = false; + },easing:'linear'}) + .start(); + } + + close(){ + + } + +} + + + +/** + * @description: 幸运硬币事件 + */ +export class LuckyAction { + // 前进三格 + static GoThreeAction(){ + + } + // 移动到月光酒馆 + YeGuangJiuGuanAction(){ + + } + // 移动到决斗场 + JueDouChangAction(){ + + } + // 移动到海上列车 + HaiShangLieCheAction(){ + + } + // 我要双倍,点数x2 + DoubleAction(){ + + } + // 这是我的钱,点数减半 + HalveAction(){ + + } + // 骑士马战 ,点数+2w + HorseCombatAction(){ + + } + // 装备修理, 点数-2w + ServicingAction(){ + + } + // 收取费用,夺取其他人 2w 点数 + ChargeAction(){ + + } + + + } \ No newline at end of file diff --git a/assets/Script/DialogNode/LuckyCoinsNode.ts.meta b/assets/Script/DialogNode/LuckyCoinsNode.ts.meta new file mode 100644 index 0000000..4c4dc8a --- /dev/null +++ b/assets/Script/DialogNode/LuckyCoinsNode.ts.meta @@ -0,0 +1,9 @@ +{ + "ver": "4.0.23", + "importer": "typescript", + "imported": true, + "uuid": "0039c2de-95ce-49a6-aa91-0ca7ee85ecc3", + "files": [], + "subMetas": {}, + "userData": {} +} diff --git a/assets/Script/MapTile/MapTitleAction.ts b/assets/Script/MapTile/MapTitleAction.ts new file mode 100644 index 0000000..d1a4bec --- /dev/null +++ b/assets/Script/MapTile/MapTitleAction.ts @@ -0,0 +1,34 @@ +/* + * @Author: WoNiu + * @Date: 2024-03-26 11:36:36 + * @LastEditTime: 2024-03-26 15:28:36 + * @LastEditors: WoNiu + * @Description: + */ + +import { LuckyCoinsNode, LuckyType } from "../DialogNode/LuckyCoinsNode"; + +/** + * @description: 地图事件 + */ +export class MapTitleAction { + // ─── 特殊事件 ──────────────────────────────────────────────────────────── + //* 月光酒馆 + //* 决斗场 + //* 海上列车 + //* 幸运硬币 + /** + * @description: 幸运硬币事件 + */ + static lucky(){ + LuckyCoinsNode.show(LuckyType.GoThree); + } + // ─── 怪物事件 ──────────────────────────────────────────────────────────────────── + /** + * @description: 怪物事件 + */ + static monsterAction(){ + + } + +} diff --git a/assets/Script/MapTile/MapTitleAction.ts.meta b/assets/Script/MapTile/MapTitleAction.ts.meta new file mode 100644 index 0000000..71626f0 --- /dev/null +++ b/assets/Script/MapTile/MapTitleAction.ts.meta @@ -0,0 +1,9 @@ +{ + "ver": "4.0.23", + "importer": "typescript", + "imported": true, + "uuid": "38b0fe6c-2083-4510-92d6-8f50384fac2c", + "files": [], + "subMetas": {}, + "userData": {} +} diff --git a/assets/Script/common/closeButtonNode.ts b/assets/Script/common/closeButtonNode.ts index 45d3bcb..41e634a 100644 --- a/assets/Script/common/closeButtonNode.ts +++ b/assets/Script/common/closeButtonNode.ts @@ -5,6 +5,9 @@ import { BaseButtonAction } from '../../GlobalScript/CommonComponent/BaseButtonA const { ccclass } = _decorator; @ccclass('CloseButtonNode') +/** + * @description: x按钮node + */ export class CloseButtonNode extends Node { constructor(onMouseLeftUp?:Function){