1 数据层设计

2 事件层设计
3 其他
This commit is contained in:
WoNiu 2024-03-27 15:57:22 +08:00
parent 199507d979
commit 1c95e70661
13 changed files with 277 additions and 163 deletions

View File

@ -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{

View File

@ -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<MapTileType, Node> = new Map<MapTileType, Node>();
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) {}
}

View File

@ -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(){
}
}

View File

@ -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();
});
}
}

View File

@ -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;

View File

@ -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;
}
}
}

View File

@ -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() {}
}

View File

@ -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<MapTileType, MapTitleModel> = 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;
}
}

View File

@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "de311b7f-a77a-4109-aefe-81e8f4d5740f",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@ -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;
}
}

View File

@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "5597e322-7749-48fe-98d4-bb4294ab1a10",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@ -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 = () =>{
}
}
//* 初始化其他胜利条件

View File

@ -175,7 +175,7 @@
"_priority": 0,
"_fov": 45,
"_fovAxis": 0,
"_orthoHeight": 461.4054054054054,
"_orthoHeight": 509.18301104972375,
"_near": 0,
"_far": 1000,
"_color": {