From 1c95e7066168a609164e44e3149d56822a517532 Mon Sep 17 00:00:00 2001 From: WoNiu Date: Wed, 27 Mar 2024 15:57:22 +0800 Subject: [PATCH] =?UTF-8?q?1=20=E6=95=B0=E6=8D=AE=E5=B1=82=E8=AE=BE?= =?UTF-8?q?=E8=AE=A1=202=20=E4=BA=8B=E4=BB=B6=E5=B1=82=E8=AE=BE=E8=AE=A1?= =?UTF-8?q?=203=20=E5=85=B6=E4=BB=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../GlobalScript/Animation/AnimationNode.ts | 11 ++- assets/Script/BoardRoot.ts | 57 +++++++------- assets/Script/DialogNode/LuckyCoinsNode.ts | 74 +++---------------- assets/Script/DialogRoot.ts | 56 ++++++-------- assets/Script/MapTile/MapTileController.ts | 9 ++- assets/Script/MapTile/MapTileNode.ts | 72 +++++++++--------- assets/Script/MapTile/MapTitleAction.ts | 67 ++++++++++++++++- .../Script/MapTile/MapTitleDateSingleton.ts | 35 +++++++++ .../MapTile/MapTitleDateSingleton.ts.meta | 9 +++ assets/Script/MapTile/MapTitleModel.ts | 34 +++++++++ assets/Script/MapTile/MapTitleModel.ts.meta | 9 +++ assets/Script/UIRoot.ts | 5 +- assets/scene/main.scene | 2 +- 13 files changed, 277 insertions(+), 163 deletions(-) create mode 100644 assets/Script/MapTile/MapTitleDateSingleton.ts create mode 100644 assets/Script/MapTile/MapTitleDateSingleton.ts.meta create mode 100644 assets/Script/MapTile/MapTitleModel.ts create mode 100644 assets/Script/MapTile/MapTitleModel.ts.meta diff --git a/assets/GlobalScript/Animation/AnimationNode.ts b/assets/GlobalScript/Animation/AnimationNode.ts index a6ed289..65fa1f5 100644 --- a/assets/GlobalScript/Animation/AnimationNode.ts +++ b/assets/GlobalScript/Animation/AnimationNode.ts @@ -1,6 +1,13 @@ -import { _decorator, Component, Node } from 'cc'; +/* + * @Author: WoNiu + * @Date: 2024-03-11 12:16:36 + * @LastEditTime: 2024-03-26 15:40:23 + * @LastEditors: WoNiu + * @Description: + */ +import { _decorator, Node } from 'cc'; import { ScriptMyAnimation } from './ScriptMyAnimation'; -const { ccclass, property } = _decorator; +const { ccclass } = _decorator; @ccclass('AnimationNode') export class AnimationNode extends Node{ diff --git a/assets/Script/BoardRoot.ts b/assets/Script/BoardRoot.ts index bf5cc35..e8f5cc9 100644 --- a/assets/Script/BoardRoot.ts +++ b/assets/Script/BoardRoot.ts @@ -1,34 +1,37 @@ -import { _decorator, Component, Node } from 'cc'; -import { MapTileTypes } from './MapTile/MapTileData'; -import { MapTileNode } from './MapTile/MapTileNode'; -const { ccclass, property } = _decorator; +/* + * @Author: WoNiu + * @Date: 2024-03-16 15:26:27 + * @LastEditTime: 2024-03-26 15:43:37 + * @LastEditors: WoNiu + * @Description: 最底层的地图 图层Component + */ +import { _decorator, Component, Node } from "cc"; +import { MapTileType, MapTileTypes } from "./MapTile/MapTileData"; +import { MapTileNode } from "./MapTile/MapTileNode"; +const { ccclass } = _decorator; -/// 最底层的地图 图层Component -@ccclass('BoardRoot') +@ccclass("BoardRoot") +/** + * @description: 最底层的地图 图层Component + */ export class BoardRoot extends Component { - start() { + //* 地块nodeMap + mapNodeMap: Map = new Map(); + start() { + this.initMapTile(); + } - } + /// 初始化 地图快 + initMapTile() { + // 从枚举类型 添加所有地块 + MapTileTypes.forEach((type) => { + const node = new MapTileNode(type); + this.node.addChild(node); + this.mapNodeMap.set(type, node); + }); + } - - /// 初始化 地图快 - initMapTile(){ - - // 从枚举类型 添加所有地块 - MapTileTypes.forEach((type) => { - const node = new MapTileNode(type); - this.node.addChild(node); - - }); - } - - update(deltaTime: number) { - - - - } + update(deltaTime: number) {} } - - diff --git a/assets/Script/DialogNode/LuckyCoinsNode.ts b/assets/Script/DialogNode/LuckyCoinsNode.ts index 07c3610..c7385ab 100644 --- a/assets/Script/DialogNode/LuckyCoinsNode.ts +++ b/assets/Script/DialogNode/LuckyCoinsNode.ts @@ -1,7 +1,7 @@ /* * @Author: WoNiu * @Date: 2024-03-26 11:44:58 - * @LastEditTime: 2024-03-26 15:41:01 + * @LastEditTime: 2024-03-27 15:49:36 * @LastEditors: WoNiu * @Description: 幸运硬币效果类型 */ @@ -21,7 +21,6 @@ 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; /** @@ -55,17 +54,14 @@ export class LuckyCoinsNode extends Node { // 幸运硬币的结果 resultNode: Node; - static show(type: LuckyType) { - const node = new LuckyCoinsNode(type); - GameRootSingleton.getInstance().DialogRootNode.addChild(node); - } + aniDoneBack: Function; - constructor(type: LuckyType) { + constructor(type: LuckyType,aniDone:Function) { super(); this.luckyType = type; + this.aniDoneBack = aniDone; this.addComponent(UITransform).anchorPoint = v2(0, 1); - this.addComponent(ShowNodeBorder); this.initResultNode(); this.initLuckyAni(); @@ -114,7 +110,7 @@ export class LuckyCoinsNode extends Node { }, 1600); } - // 缓动消失 + // 透明度缓动消失 resultTweenDestroy() { let obj = { x: 255 }; @@ -123,63 +119,17 @@ export class LuckyCoinsNode extends Node { .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; + // 动画完成回调 + this.aniDoneBack(); + // 销毁节点 + director.once(Director.EVENT_END_FRAME, () => { + this.destroy(); + }); },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/DialogRoot.ts b/assets/Script/DialogRoot.ts index a6e5af2..0248077 100644 --- a/assets/Script/DialogRoot.ts +++ b/assets/Script/DialogRoot.ts @@ -1,48 +1,40 @@ /* * @Author: WoNiu * @Date: 2024-03-19 17:44:59 - * @LastEditTime: 2024-03-25 14:58:55 + * @LastEditTime: 2024-03-26 13:34:17 * @LastEditors: WoNiu - * @Description: + * @Description: */ -import { _decorator, Component, Director, director, Node } from 'cc'; -import { SelectNumberNode } from './DialogNode/SelectNumberNode'; +import { _decorator, Component, Director, director, Node } from "cc"; +import { SelectNumberNode } from "./DialogNode/SelectNumberNode"; const { ccclass, property } = _decorator; -@ccclass('DialogRoot') +@ccclass("DialogRoot") /** * @description: 弹窗 */ export class DialogRoot extends Component { - start() { - - } - - update(deltaTime: number) { - - } - - - //* 初始化并显示顺序选择node - initSelectNumberNode(): SelectNumberNode{ - const selectNode = new SelectNumberNode(); - selectNode.name = 'SelectNumberNode'; - this.node.addChild(selectNode); - return selectNode; - } - - //* 销毁顺序选择node - destroySelectNumberNode(){ - /// 一帧结束之后销毁 - director.once(Director.EVENT_END_FRAME,()=>{ - // 销毁 - this.node.getChildByName('SelectNumberNode').destroy(); - }); - } + start() { + } + update(deltaTime: number) {} + //* 初始化并显示顺序选择node + initSelectNumberNode(): SelectNumberNode { + const selectNode = new SelectNumberNode(); + selectNode.name = "SelectNumberNode"; + this.node.addChild(selectNode); + return selectNode; + } + //* 销毁顺序选择node + destroySelectNumberNode() { + /// 一帧结束之后销毁 + director.once(Director.EVENT_END_FRAME, () => { + // 销毁 + this.node.getChildByName("SelectNumberNode").destroy(); + }); + } + } - - diff --git a/assets/Script/MapTile/MapTileController.ts b/assets/Script/MapTile/MapTileController.ts index 5904862..ac0446a 100644 --- a/assets/Script/MapTile/MapTileController.ts +++ b/assets/Script/MapTile/MapTileController.ts @@ -1,4 +1,11 @@ -import { _decorator, Component, Node } from "cc"; +/* + * @Author: WoNiu + * @Date: 2024-03-16 16:34:19 + * @LastEditTime: 2024-03-27 15:27:08 + * @LastEditors: WoNiu + * @Description: 地图地块的行为控制器 + */ +import { _decorator, Component, } from "cc"; import { MapTileData, MapTileFactory, MapTileType } from "./MapTileData"; const { ccclass } = _decorator; diff --git a/assets/Script/MapTile/MapTileNode.ts b/assets/Script/MapTile/MapTileNode.ts index 63ddb1e..0097d31 100644 --- a/assets/Script/MapTile/MapTileNode.ts +++ b/assets/Script/MapTile/MapTileNode.ts @@ -1,11 +1,11 @@ import { _decorator, Node } from "cc"; -import { - MapTileDirection, - MapTileType, -} from "./MapTileData"; +import { MapTileDirection, MapTileType } from "./MapTileData"; import { BaseSprite } from "../../GlobalScript/CommonComponent/BaseSprite"; import { MapTileButtonComponent } from "./MapTileButtonComponent"; import { MapTileController } from "./MapTileController"; +import { CloseButtonNode } from "../Common/CloseButtonNode"; +import { MapTitleAction } from "./MapTitleAction"; +import { LuckyType } from "../DialogNode/LuckyCoinsNode"; const { ccclass } = _decorator; /// 地块 @@ -44,16 +44,21 @@ export class MapTileNode extends Node { this.controller.tileType = type; this.initNode(); + + // todo 测试用按钮 + this.initButton(); } /// 测试使用按钮 - initButtons(){ - + initButton() { + const node = new CloseButtonNode(()=>{ + MapTitleAction.lucky( LuckyType.GoThree ); + }) + this.addChild(node); } initNode() { - - /// 背景 + //* 背景 if (this.controller.tileData.backgroundIndex) { const node = new Node(); this.addChild(node); @@ -67,7 +72,7 @@ export class MapTileNode extends Node { this.backgroundNode = node; } - /// 名称 + //* 名称 const node = new Node(); this.addChild(node); @@ -79,8 +84,8 @@ export class MapTileNode extends Node { this.nameNode = node; - /// 决斗场选择后的红色边框 - // 四角和命运硬币 没有红框 + //* 红色边框 + // 决斗场选择后的红色边框,四角和命运硬币 没有红框 if ( this.controller.tileData.direction != MapTileDirection.nook && this.controller.tileType != @@ -94,46 +99,47 @@ export class MapTileNode extends Node { const bs = node.addComponent(BaseSprite); bs.updateSpriteFrame( this.controller.tileData.npkPath, - this.controller.tileData.direction == MapTileDirection.horizontal ? 27 : 28 + this.controller.tileData.direction == MapTileDirection.horizontal + ? 27 + : 28 ); this.fightNode = node; } - if (this.controller.tileData.trainsSelectLicense){ - // 鼠标选择边框 - const bordeNode = new Node(); - this.addChild(bordeNode); - bordeNode.active = false; - const bordeBC = bordeNode.addComponent(MapTileButtonComponent); - bordeBC.direction = this.controller.tileData.direction; - this.borderNode = bordeNode; - } + //* 鼠标选择边框 + const bordeNode = new Node(); + this.addChild(bordeNode); + bordeNode.active = false; + const bordeBC = bordeNode.addComponent(MapTileButtonComponent); + bordeBC.direction = this.controller.tileData.direction; + this.borderNode = bordeNode; - - /// 禁止选择 + //* 禁止选择node const disableNode = new Node(); this.addChild(disableNode); disableNode.active = false; const disableBS = disableNode.addComponent(BaseSprite); - disableBS.updateSpriteFrame(this.controller.tileData.npkPath,this.controller.tileData.direction + 5) + disableBS.updateSpriteFrame( + this.controller.tileData.npkPath, + this.controller.tileData.direction + 5 + ); this.disableNode = disableNode; } - - /// 显示海上列车选择 - shwTrainsSelect(show: boolean){ - if (this.borderNode){ - /// 许可选择 - if (this.controller.tileData.trainsSelectLicense){ + //* 显示海上列车选择 + shwTrainsSelect(show: boolean) { + if (this.borderNode) { + //* 许可选择 + if (this.controller.tileData.trainsSelectLicense) { this.borderNode.active = show; - }else{ + } else { this.disableNode.active = true; } - }else{ + } else { this.disableNode.active = false; this.borderNode.active = false; } } - } + diff --git a/assets/Script/MapTile/MapTitleAction.ts b/assets/Script/MapTile/MapTitleAction.ts index d1a4bec..893b06f 100644 --- a/assets/Script/MapTile/MapTitleAction.ts +++ b/assets/Script/MapTile/MapTitleAction.ts @@ -1,12 +1,13 @@ /* * @Author: WoNiu * @Date: 2024-03-26 11:36:36 - * @LastEditTime: 2024-03-26 15:28:36 + * @LastEditTime: 2024-03-27 15:55:40 * @LastEditors: WoNiu * @Description: */ import { LuckyCoinsNode, LuckyType } from "../DialogNode/LuckyCoinsNode"; +import { GameRootSingleton } from "../GameRootController"; /** * @description: 地图事件 @@ -20,15 +21,73 @@ export class MapTitleAction { /** * @description: 幸运硬币事件 */ - static lucky(){ - LuckyCoinsNode.show(LuckyType.GoThree); + static lucky(type: LuckyType) { + // 将幸运硬币动画节点添加到 Dialog 层 + const node = new LuckyCoinsNode(type, () => { + LuckyAction.Action(type); + }); + GameRootSingleton.getInstance().DialogRootNode.addChild(node); } // ─── 怪物事件 ──────────────────────────────────────────────────────────────────── /** * @description: 怪物事件 */ - static monsterAction(){ + static monsterAction() {} +} +/** + * @description: 幸运硬币事件 + */ +export class LuckyAction { + static Action(type: LuckyType) { + const lucky = new LuckyAction(); + switch (type) { + case LuckyType.GoThree: + lucky.GoThreeAction(); + break; + case LuckyType.YeGuangJiuGuan: + lucky.YeGuangJiuGuanAction(); + break; + case LuckyType.JueDouChang: + lucky.JueDouChangAction(); + break; + case LuckyType.HaiShangLieChe: + lucky.HaiShangLieCheAction(); + break; + case LuckyType.Double: + lucky.DoubleAction(); + break; + case LuckyType.Halve: + lucky.HalveAction(); + break; + case LuckyType.HorseCombat: + lucky.HorseCombatAction(); + break; + case LuckyType.Servicing: + lucky.ServicingAction(); + break; + case LuckyType.Charge: + lucky.ChargeAction(); + break; + } } + // 前进三格 + GoThreeAction() {} + // 移动到月光酒馆 + YeGuangJiuGuanAction() {} + // 移动到决斗场 + JueDouChangAction() {} + // 移动到海上列车 + HaiShangLieCheAction() {} + // 我要双倍,点数x2 + DoubleAction() {} + // 这是我的钱,点数减半 + HalveAction() {} + // 骑士马战 ,点数+2w + HorseCombatAction() {} + // 装备修理, 点数-2w + ServicingAction() {} + // 收取费用,夺取其他人 2w 点数 + ChargeAction() {} } diff --git a/assets/Script/MapTile/MapTitleDateSingleton.ts b/assets/Script/MapTile/MapTitleDateSingleton.ts new file mode 100644 index 0000000..751c13c --- /dev/null +++ b/assets/Script/MapTile/MapTitleDateSingleton.ts @@ -0,0 +1,35 @@ +/* + * @Author: WoNiu + * @Date: 2024-03-27 15:20:29 + * @LastEditTime: 2024-03-27 15:26:21 + * @LastEditors: WoNiu + * @Description: + */ +import { MapTileType, MapTileTypes } from "./MapTileData"; +import { MapTitleModel } from "./MapTitleModel"; + +/** + * @description: 地图数据的单例 + */ +export class MapTitleDatelSingleton { + private static readonly _instance: MapTitleDatelSingleton = + new MapTitleDatelSingleton(); + + //* 地块nodeMap + mapModMap: Map = new Map< + MapTileType, + MapTitleModel + >(); + + private constructor() { + + MapTileTypes.forEach((type) => { + const mod = new MapTitleModel(type); + this.mapModMap.set(type, mod); + }); + } + + public static getInstance(): MapTitleDatelSingleton { + return MapTitleDatelSingleton._instance; + } +} diff --git a/assets/Script/MapTile/MapTitleDateSingleton.ts.meta b/assets/Script/MapTile/MapTitleDateSingleton.ts.meta new file mode 100644 index 0000000..5f706db --- /dev/null +++ b/assets/Script/MapTile/MapTitleDateSingleton.ts.meta @@ -0,0 +1,9 @@ +{ + "ver": "4.0.23", + "importer": "typescript", + "imported": true, + "uuid": "de311b7f-a77a-4109-aefe-81e8f4d5740f", + "files": [], + "subMetas": {}, + "userData": {} +} diff --git a/assets/Script/MapTile/MapTitleModel.ts b/assets/Script/MapTile/MapTitleModel.ts new file mode 100644 index 0000000..49715f7 --- /dev/null +++ b/assets/Script/MapTile/MapTitleModel.ts @@ -0,0 +1,34 @@ +/* + * @Author: WoNiu + * @Date: 2024-03-26 11:12:32 + * @LastEditTime: 2024-03-27 15:16:42 + * @LastEditors: WoNiu + * @Description: + */ +import { _decorator } from "cc"; + +import { MapTileType } from "./MapTileData"; + +/** + * @description: 地图数据模型 + */ +export class MapTitleModel { + //* 地块类型 + type: MapTileType; + + //* 地块占领状态(是谁占领的,) + occupState: string; + + //* 占领等级 + occupyLevel: 0 | 1 | 2 | 3; + + //* 决斗场等级 + fightLevel: 0 | 2 | 4 | 8; + + constructor(type: MapTileType) { + this.type = type; + this.occupState = ""; + this.occupyLevel = 0; + this.fightLevel = 0; + } +} diff --git a/assets/Script/MapTile/MapTitleModel.ts.meta b/assets/Script/MapTile/MapTitleModel.ts.meta new file mode 100644 index 0000000..29536e5 --- /dev/null +++ b/assets/Script/MapTile/MapTitleModel.ts.meta @@ -0,0 +1,9 @@ +{ + "ver": "4.0.23", + "importer": "typescript", + "imported": true, + "uuid": "5597e322-7749-48fe-98d4-bb4294ab1a10", + "files": [], + "subMetas": {}, + "userData": {} +} diff --git a/assets/Script/UIRoot.ts b/assets/Script/UIRoot.ts index 840603a..0cdb1f2 100644 --- a/assets/Script/UIRoot.ts +++ b/assets/Script/UIRoot.ts @@ -16,7 +16,6 @@ import { OtherWinNode, otherWinType } from "./UINode/OtherWinNode"; import { BoardRoot } from "./BoardRoot"; import { StartGameUINode } from "./StartGameNode/StartGameUINode"; import { GameRootSingleton } from "./GameRootController"; -import { SelectNumberNode } from "./DialogNode/SelectNumberNode"; const { ccclass } = _decorator; @ccclass("UIRoot") @@ -129,6 +128,10 @@ export class UIRoot extends Component { this.diceButton.winButtonBlock = () => { this.otherWinNode.active = true; }; + + this.diceButton.diceUpBlock = () =>{ + + } } //* 初始化其他胜利条件 diff --git a/assets/scene/main.scene b/assets/scene/main.scene index 217534c..ba0589f 100644 --- a/assets/scene/main.scene +++ b/assets/scene/main.scene @@ -175,7 +175,7 @@ "_priority": 0, "_fov": 45, "_fovAxis": 0, - "_orthoHeight": 461.4054054054054, + "_orthoHeight": 509.18301104972375, "_near": 0, "_far": 1000, "_color": {