Compare commits

...

10 Commits

Author SHA1 Message Date
WoNiu bc32d687ee 1 文件目录结构调整
2 UIRoot 代码结构调整
3 Npk 修改替换
4 玩家角色站立动画初版
2024-03-29 20:08:58 +08:00
WoNiu 1c95e70661 1 数据层设计
2 事件层设计
3 其他
2024-03-27 15:57:22 +08:00
WoNiu 199507d979 幸运硬币动画 2024-03-26 17:18:28 +08:00
WoNiu 0c6de664fe 骰子按钮动画 2024-03-25 19:50:16 +08:00
WoNiu 33484b3406 1 修改坐标控制 组件
2 新增显示node位置和大小的组件
2024-03-24 17:57:19 +08:00
WoNiu 763cec406f 选择卡片决定顺序动画和其他 2024-03-24 17:55:56 +08:00
WoNiu 47918dc065 1 选择先后顺序的卡片完成
2 倒计时node封装完成
2024-03-23 20:28:14 +08:00
WoNiu b5158644d3 1 baseButton 增加一个方便的初始化状态的方法
2 修改原有使用baseButton 的代码
2024-03-22 22:56:08 +08:00
WoNiu d94ea3f4a9 GameRoot节点控制和注销修改 2024-03-22 21:19:27 +08:00
DESKTOP-J7I1C4E\a9350 3accbc5f3a 1 修改更换NPK
2 修改baseButton 的问题
3 修改更换NPK导致的index错误问题
2024-03-22 15:48:09 +08:00
63 changed files with 2682 additions and 894 deletions

4
.gitignore vendored
View File

@ -22,4 +22,6 @@ node_modules/
#//////////////////////////
# WebStorm
#//////////////////////////
.idea/
.idea/
assets/ImagePack/!幻想模拟战.NPK
assets/ImagePack/!幻想模拟战.NPK.meta

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

@ -53,6 +53,32 @@ export class BaseButton extends Component {
//按钮状态
ButtonState = BaseButtonState.Normal; // 0 普通 1悬停 2按下 8失效
/**
* @description: BaseButton初始化设置
* @param {string} ImgPath: npk中的路径
* @param {number} NormalIndex: 普通 npk.img idnex +1
*/
init(ImgPath:string,NormalIndex:number): void;
init(ImgPath:string,NormalIndex:number,HoverIndex:number,PressIndex:number,DisableIndex:number,auto:boolean): void;
/**
* @description: BaseButton初始化设置
* @param {string} ImgPath: npk中的路径
* @param {number} NormalIndex: 普通 npk.img idnex
* @param {number} HoverIndex: 悬停
* @param {number} PressIndex
* @param {number} DisableIndex
* @param {number} Disable
* @return {*}
*/
init(ImgPath:string,NormalIndex:number,HoverIndex?:number,PressIndex?:number,DisableIndex?:number,Disable:boolean = true): void{
this.ImgPath = ImgPath;
this.NormalImgIndex = NormalIndex;
this.HoverImgIndex = HoverIndex ? HoverIndex : NormalIndex + 1;
this.PressImgIndex = PressIndex ? PressIndex : NormalIndex + 2;
if (Disable){ this.DisableImgIndex = DisableIndex ? DisableIndex : NormalIndex + 3; }
}
start() {
//判断是否有精灵 如果没有 就给他搞一个
@ -120,6 +146,7 @@ export class BaseButton extends Component {
}
OnHever(event) {
if (this.ButtonState == BaseButtonState.Disable) return;
this.ButtonState = BaseButtonState.Hover;
}
OnEnd(event: EventMouse) {
if (this.ButtonState == BaseButtonState.Disable) return;

View File

@ -0,0 +1,77 @@
/*
* @Author: WoNiu
* @Date: 2024-03-23 13:22:27
* @LastEditTime: 2024-03-24 16:04:20
* @LastEditors: WoNiu
* @Description: node坐标控制
*/
import {
_decorator,
Color,
Component,
EditBox,
Font,
HorizontalTextAlignment,
Node,
Size,
Sprite,
UITransform,
v2,
VerticalTextAlignment,
} from "cc";
const { ccclass, property } = _decorator;
@ccclass("LocationImportComponent")
/**
* @description: node坐标控制
*/
export class LocationImportComponent extends Component {
editBox: EditBox;
onLoad(): void {
const node = new Node();
node.setPosition(0, 30);
const uit = node.addComponent(UITransform);
uit.anchorPoint = v2(0, 1);
uit.setContentSize(new Size(150, 30));
const sp = node.addComponent(Sprite);
sp.color = Color.WHITE;
const editBox = node.addComponent(EditBox);
editBox.inputMode = EditBox.InputMode.SINGLE_LINE;
this.editBox = editBox;
this.node.addChild(node);
//* 修改 node 的坐标
editBox.node.on("editing-did-ended", (text: EditBox) => {
const los = text.textLabel.string.split(',');
this.node.setPosition(Number(los[0]),Number(los[1]));
});
}
start() {
const placeholderLabel = this.editBox.placeholderLabel;
placeholderLabel.string = "坐标";
placeholderLabel.horizontalAlign = HorizontalTextAlignment.LEFT;
placeholderLabel.verticalAlign = VerticalTextAlignment.TOP;
placeholderLabel.fontSize = 20;
placeholderLabel.color = Color.RED;
placeholderLabel.node.setPosition(0, 50);
placeholderLabel.node.getComponent(UITransform).anchorPoint = v2(0, 2);
const textLabel = this.editBox.textLabel;
textLabel.horizontalAlign = HorizontalTextAlignment.LEFT;
textLabel.verticalAlign = VerticalTextAlignment.TOP;
textLabel.fontSize = 20;
textLabel.color = Color.RED;
textLabel.node.setPosition(0, 50);
textLabel.node.getComponent(UITransform).anchorPoint = v2(0, 2);
}
update(deltaTime: number) {}
}

View File

@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "08408ae9-019a-4902-9bc2-002e2e663cb6",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@ -0,0 +1,52 @@
/*
* @Author: WoNiu
* @Date: 2024-03-24 16:09:55
* @LastEditTime: 2024-03-24 16:30:46
* @LastEditors: WoNiu
* @Description: node的位置和大小01
*/
import { _decorator, Color, Component, Graphics, Node, UITransform } from 'cc';
const { ccclass, property } = _decorator;
@ccclass('ShowNodeBorder')
/**
* @description: node的位置和大小01
*/
export class ShowNodeBorder extends Component {
graphics: Graphics;
onLoad() {
if(this.node.getComponent(Graphics)){
this.graphics = this.node.getComponent(Graphics);
}else{
this.graphics = this.node.addComponent(Graphics);
}
this.updateBorder();
}
updateBorder() {
const borderColor = Color.YELLOW;
const borderWidth = 4;
const contentSize = this.node.getComponent(UITransform).contentSize;
this.graphics.clear();
this.graphics.strokeColor = borderColor;
this.graphics.lineWidth = borderWidth;
// this.graphics.rect(-contentSize.width / 2, -contentSize.height / 2, contentSize.width, contentSize.height);// 锚点 (0,0)
this.graphics.rect(0, 0, contentSize.width, -contentSize.height); //锚点 (0,1)
this.graphics.stroke();
}
start() {
}
update(deltaTime: number) {
}
}

View File

@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "9ef9c0ff-8d63-448d-b95f-89b02e1455f3",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@ -21,18 +21,18 @@ export class GameState extends Component {
}
//当前是否处于暂停状态
/** 当前是否处于暂停状态 */
PauseState: boolean = false;
//改变暂停状态的回调函数
/** 改变暂停状态的回调函数 */
ResumeCallBackFunc: ResumeCallback<any>[] = [];
//获取暂停状态
/** 获取暂停状态 */
IsPauseState(): boolean {
return this.PauseState;
}
//设置暂停状态
/** 设置暂停状态 */
SetCurrentPauseState(State: boolean) {
//不等于时 设置一次
if (State != this.PauseState) {
@ -45,7 +45,7 @@ export class GameState extends Component {
}
}
//注册恢复游戏的逻辑回调函数
/** 注册恢复游戏的逻辑回调函数 */
RegisterResumeCallBack(Func: ResumeCallback<any>) {
this.ResumeCallBackFunc.push(Func);
}

View File

@ -2,7 +2,7 @@
"ver": "1.0.3",
"importer": "buffer",
"imported": true,
"uuid": "dc61d9f4-8a5e-4540-8a2c-dc318bb9f198",
"uuid": "6aba7d31-7435-4f59-b5aa-79256df4ede9",
"files": [
".bin",
".json"

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-28 21:13:04
* @LastEditors: WoNiu
* @Description: Component
*/
import { _decorator, Component, Node } from "cc";
import { MapTileType, MapTileTypes } from "./MapTile/MapTileType";
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,14 +0,0 @@
import { _decorator, Component, Node } from 'cc';
const { ccclass, property } = _decorator;
@ccclass('DialogRoot')
export class DialogRoot extends Component {
start() {
}
update(deltaTime: number) {
}
}

View File

@ -0,0 +1,209 @@
/*
* @Author: WoNiu
* @Date: 2024-03-22 19:50:30
* @LastEditTime: 2024-03-24 17:09:16
* @LastEditors: WoNiu
* @Description:
*/
import {
_decorator,
EventMouse,
Node,
Sprite,
SpriteFrame,
UITransform,
v2,
tween,
Component,
Label,
Color,
Size,
v3,
} from "cc";
import { NpkImage } from "../../Tool/NPKImage";
import { BaseSpriteFrame } from "../../GlobalScript/CommonComponent/BaseSpriteFrame";
const { ccclass, property } = _decorator;
@ccclass("CardNode")
export class CardNode extends Node {
//普通精灵帧
private NormalSpriteFrame: SpriteFrame;
// 高亮精灵帧1
private oneSpriteFrame: SpriteFrame;
//高亮精灵帧2
private twoSpriteFrame: SpriteFrame;
// 翻转动画
flipsAnimation:CardFlipsAnimation;
//精灵对象
private SpriteObj: Sprite;
// 是否按钮失效
Disable = false;
constructor() {
super();
const trf = this.addComponent(UITransform);
trf.anchorPoint = v2(0.5, 1)
trf.contentSize = new Size(178,113);
this.flipsAnimation = this.addComponent(CardFlipsAnimation);
this.initBackgroundNode();
this.initSpriteFrame();
this.initEvent();
}
initBackgroundNode(){
// const node = new Node();
// this.addChild(node);
// const trf = node.addComponent(UITransform);
// trf.contentSize = new Size(178,113);
// trf.anchorPoint = v2(0,1);
// this.SpriteObj = node.addComponent(Sprite);
this.SpriteObj = this.addComponent(Sprite);
}
initSpriteFrame() {
/// 不同亮度的卡片
new BaseSpriteFrame(NpkImage.ingame, 47, (SpriteFrame: SpriteFrame) => {
this.NormalSpriteFrame = SpriteFrame;
this.SpriteObj.spriteFrame = SpriteFrame;
});
new BaseSpriteFrame(NpkImage.ingame, 48, (SpriteFrame: SpriteFrame) => {
this.oneSpriteFrame = SpriteFrame;
});
new BaseSpriteFrame(NpkImage.ingame, 49, (SpriteFrame: SpriteFrame) => {
this.twoSpriteFrame = SpriteFrame;
});
}
initEvent() {
this.on(Node.EventType.MOUSE_ENTER, this.OnHever, this);
this.on(Node.EventType.MOUSE_LEAVE, this.OffHever, this);
this.on(Node.EventType.MOUSE_DOWN, this.OnDown, this);
}
OffHever() {
if (this.Disable) return;
this.SpriteObj.spriteFrame = this.NormalSpriteFrame;
}
OnHever() {
if (this.Disable) return;
this.SpriteObj.spriteFrame = this.oneSpriteFrame;
}
OnDown(event: EventMouse) {
//必须是鼠标左键
if (event.getButton() != EventMouse.BUTTON_LEFT || this.Disable) return;
this.SpriteObj.spriteFrame = this.twoSpriteFrame;
this.Disable = true;
}
}
/**
* @description:
*/
export class CardFlipsAnimation extends Component {
// 数字1精灵帧
oneSpriteFrame: SpriteFrame;
//数字2精灵帧
twoSpriteFrame: SpriteFrame;
//数字2精灵帧
threeSpriteFrame: SpriteFrame;
// 数字
value: number;
// 单次缓动时间
tweenTime: number = 0.5;
// 玩家名称
nameNode: Node;
scale = {x:1};
onLoad() {
/// 数字卡片
new BaseSpriteFrame(NpkImage.ingame, 50, (SpriteFrame: SpriteFrame) => {
this.oneSpriteFrame = SpriteFrame;
});
new BaseSpriteFrame(NpkImage.ingame, 51, (SpriteFrame: SpriteFrame) => {
this.twoSpriteFrame = SpriteFrame;
});
new BaseSpriteFrame(NpkImage.ingame, 52, (SpriteFrame: SpriteFrame) => {
this.threeSpriteFrame = SpriteFrame;
});
// this.nameLabel = this.node.addComponent(Label);
}
start() {}
/**
* @description:
* @param {1} value: 这个卡牌反转后是几
*/
animationStart(value: number,name:string) {
this.value = value;
if (value > 2) this.value = 2;
this.initNmaeNode(name);
tween(this.scale).to(this.tweenTime, { x: 0,},{onComplete:()=>{
this.flipsTweenBack();
},onUpdate:()=>{
this.node.scale = v3(this.scale.x,1,1);
},easing:'linear'}).start();
}
flipsTweenBack(){
const spriteFrames = [this.oneSpriteFrame,this.twoSpriteFrame,this.threeSpriteFrame];
this.node.getComponent(Sprite).spriteFrame = spriteFrames[this.value];
this.nameNode.active = true;
tween(this.scale).to(this.tweenTime, { x: 1,},{onUpdate:()=>{
this.node.scale = v3(this.scale.x,1,1);
},easing:'linear'}).start();
}
initNmaeNode(name:string){
const nameNode = new Node('label');
this.node.addChild(nameNode);
this.nameNode = nameNode;
nameNode.active = false;
nameNode.setPosition(0,-75);
const trf = nameNode.addComponent(UITransform);
trf.anchorPoint = v2(0.5,1);
trf.contentSize = new Size(178,20);
const label = nameNode.addComponent(Label);
label.overflow = Label.Overflow.CLAMP;
label.string = name;
label.fontSize = 15;
label.color = Color.RED;
label.horizontalAlign = Label.HorizontalAlign.CENTER;
label.verticalAlign = Label.VerticalAlign.CENTER;
}
update(dt: number) {}
}

View File

@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "d249ab2c-fe35-459a-915d-a40a053488e2",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@ -0,0 +1,23 @@
/*
* @Author: WoNiu
* @Date: 2024-03-19 17:44:59
* @LastEditTime: 2024-03-29 14:00:11
* @LastEditors: WoNiu
* @Description:
*/
import { _decorator, Component } from "cc";
const { ccclass, property } = _decorator;
@ccclass("DialogRoot")
/**
* @description:
*/
export class DialogRoot extends Component {
start() {}
update(deltaTime: number) {}
}

View File

@ -0,0 +1,135 @@
/*
* @Author: WoNiu
* @Date: 2024-03-26 11:44:58
* @LastEditTime: 2024-03-29 14:02:43
* @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";
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;
/** 动画完成回调 */
aniDoneBack: Function;
constructor(type: LuckyType,aniDone:Function) {
super();
this.luckyType = type;
this.aniDoneBack = aniDone;
this.addComponent(UITransform).anchorPoint = v2(0, 1);
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);
}, onComplete: () => {
/// 缓动完成
this.resultNode.active = false;
// 动画完成回调
this.aniDoneBack();
// 销毁节点
director.once(Director.EVENT_END_FRAME, () => {
this.destroy();
});
},easing:'linear'})
.start();
}
}

View File

@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "0039c2de-95ce-49a6-aa91-0ca7ee85ecc3",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@ -0,0 +1,116 @@
/*
* @Author: WoNiu
* @Date: 2024-03-21 13:28:47
* @LastEditTime: 2024-03-25 19:44:01
* @LastEditors: WoNiu
* @Description:
*/
/*
* @Author: WoNiu
* @Date: 2024-03-21 13:28:47
* @LastEditTime: 2024-03-22 21:24:13
* @LastEditors: WoNiu
* @Description:
*/
import { _decorator, Director, director, Node } from "cc";
import { BaseSprite } from "../../GlobalScript/CommonComponent/BaseSprite";
import { NpkImage } from "../../Tool/NPKImage";
import { BaseButtonAction } from "../../GlobalScript/CommonComponent/BaseButtonAction";
import { CardNode } from "./CardNode";
import { TimingProgressBar } from "../Common/TimingProgressBar";
const { ccclass, property } = _decorator;
/// 选择顺序卡牌Node
@ccclass("SelectNumberNode")
export class SelectNumberNode extends Node {
oneCard: CardNode;
twoCard: CardNode;
threeCard: CardNode;
doneFunc: Function;
constructor() {
super();
this.initBackground();
this.initCards();
this.initTiming();
}
initBackground() {
const node = new Node();
node.setPosition(184.5, -181.5);
const bs = node.addComponent(BaseSprite);
bs.updateSpriteFrame(NpkImage.ingame, 46);
this.addChild(node);
}
initCards() {
this.oneCard = new CardNode();
this.oneCard.setPosition(339, -220);
this.addChild(this.oneCard);
const Onebba = this.oneCard.addComponent(BaseButtonAction);
Onebba.onMouseLeftDown = () => {
this.onMouseLeftDown(0);
};
this.twoCard = new CardNode();
this.twoCard.setPosition(533.5, -220);
this.addChild(this.twoCard);
const twoBba = this.twoCard.addComponent(BaseButtonAction);
twoBba.onMouseLeftDown = () => {
this.onMouseLeftDown(1);
};
this.threeCard = new CardNode();
this.threeCard.setPosition(728, -220);
this.addChild(this.threeCard);
const threeBba = this.threeCard.addComponent(BaseButtonAction);
threeBba.onMouseLeftDown = () => {
this.onMouseLeftDown(2);
};
}
//* 倒计时
initTiming() {
// 倒计时
const time = new TimingProgressBar();
this.addChild(time);
time.tweenerStart(3, () => {
//倒计时缓动完成
//开始翻转动画需要1秒完成动画
this.flipsCard();
//* 2秒后关闭node
setTimeout(() => {
this.doneFunc();
/// 这一帧结束之后调用
director.once(Director.EVENT_END_FRAME, () => {
// 销毁,销毁节点只能在当前帧结束后
this.destroy();
});
}, 2000);
});
}
//* 翻转卡片
flipsCard() {
const cards = [this.oneCard, this.twoCard, this.threeCard];
for (let i = 0; i < cards.length; i++) {
const card = cards[i];
card.Disable = true;
card.flipsAnimation.animationStart(i, "玩家" + i);
}
}
onMouseLeftDown(tag: number) {
const cards = [this.oneCard, this.twoCard, this.threeCard];
cards.forEach((card) => {
card.Disable = true;
});
}
update(deltaTime: number) {}
}

View File

@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "06193d25-5a05-4aaf-92a9-d5358c56a4ff",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@ -0,0 +1,72 @@
/*
* @Author: WoNiu
* @Date: 2024-03-21 13:29:53
* @LastEditTime: 2024-03-29 14:21:02
* @LastEditors: WoNiu
* @Description:
*/
import { _decorator, Component, Node } from "cc";
import { BoardRoot } from "./BoardRoot";
import { UIRoot } from "./UIRoot/UIRoot";
import { GameRoleController } from "./UIRoot/GameRoleController";
import { DialogRoot } from "./DialogRoot/DialogRoot";
const { ccclass, property } = _decorator;
/**
* @description:
*/
export class GameRootSingleton {
private static readonly _instance: GameRootSingleton =
new GameRootSingleton();
private constructor() {}
public static getInstance(): GameRootSingleton {
return GameRootSingleton._instance;
}
boardRootNode: Node;
UIRootNode: Node;
DialogRootNode: Node;
boardRoot: BoardRoot;
UIRoot: UIRoot;
DialogRoot: DialogRoot;
/** 玩家角色控制脚本 */
gameRoleController: GameRoleController;
}
@ccclass("GameRootController")
/**
* @description:
*/
export class GameRootController extends Component {
@property(Node) boardRootNode: Node;
@property(Node) UIRootNode: Node;
@property(Node) DialogRootNode: Node;
start() {
/// 给三个图层添加 root 根脚本
const game = GameRootSingleton.getInstance();
game.boardRootNode = this.boardRootNode;
game.UIRootNode = this.UIRootNode;
game.DialogRootNode = this.DialogRootNode;
/// 给三个图层添加 root 根脚本
game.boardRoot = this.boardRootNode.getComponent(BoardRoot);
game.UIRoot = this.UIRootNode.getComponent(UIRoot);
game.DialogRoot = this.DialogRootNode.getComponent(DialogRoot);
/// 在 UI 节点 添加玩家角色控制脚本
this.UIRootNode.addComponent(GameRoleController);
// 添加游戏 匹配过程控制 脚本
game.gameRoleController = this.addComponent(GameRoleController);
}
update(deltaTime: number) {}
}

View File

@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "949ead83-9b0e-4202-8007-c50ab2ceeeb5",
"files": [],
"subMetas": {},
"userData": {}
}

9
assets/Script/Gamer.meta Normal file
View File

@ -0,0 +1,9 @@
{
"ver": "1.2.0",
"importer": "directory",
"imported": true,
"uuid": "d61e7a19-5a2c-45c6-b9c8-8efecdaafe18",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@ -1,23 +1,26 @@
/*
* @Author: WoNiu
* @Date: 2024-03-09 17:02:06
* @LastEditTime: 2024-03-27 16:11:51
* @LastEditors: WoNiu
* @Description:
*/
import { _decorator, Color, Label, Node, Size, Sprite, SpriteFrame, tween, UITransform, VerticalTextAlignment } from 'cc';
import { BaseSprite } from '../../GlobalScript/CommonComponent/BaseSprite';
import { NpkImage } from '../../Tool/NPKImage';
import { BaseSpriteFrame } from '../../GlobalScript/CommonComponent/BaseSpriteFrame';
import { GamerRoleType } from './GamerRoleType';
const { ccclass } = _decorator;
/// 玩家角色类型
export enum CharacterType{
/// 剑魂
JianHun = 0,
}
/// 玩家Node封装
@ccclass('Gamer')
export class GamerNode extends Node {
@ccclass('GamerCardNode')
export class GamerCardNode extends Node {
/// 玩家角色类型
private _characterType : CharacterType;
private _characterType : GamerRoleType;
/// 玩家名称
private GamerNameLabel : Label;
@ -34,7 +37,7 @@ export class GamerNode extends Node {
private blue = new Color('00baff');
set charchterType(type:CharacterType){
set charchterType(type:GamerRoleType){
if(!this.getChildByName('GamerCharacterNode')){
this._characterType = type;
this.initCharacterNode();
@ -57,7 +60,7 @@ export class GamerNode extends Node {
}},).start();
}
}
/// 设置玩家名称
@ -97,7 +100,7 @@ export class GamerNode extends Node {
}
}
constructor(gamerName:string){
super();
@ -146,7 +149,7 @@ export class GamerNode extends Node {
/// 添加 baseSprite 组件
const backgroundComponent = node.addComponent( BaseSprite );
backgroundComponent.updateSpriteFrame(NpkImage.ingame,51);
backgroundComponent.updateSpriteFrame(NpkImage.ingame,53);
}

View File

@ -0,0 +1,120 @@
/*
* @Author: WoNiu
* @Date: 2024-03-27 15:58:07
* @LastEditTime: 2024-03-29 14:40:52
* @LastEditors: WoNiu
* @Description:
*/
import {
_decorator,
Component,
Node,
Sprite,
SpriteFrame,
} from "cc";
import { NpkImageTool } from "../../Tool/NPKImage";
import { GamerRoleAni, GamerRoleType } from "./GamerRoleType";
import { GameState } from "../../GlobalScript/GlobalGameState/GameState";
const { ccclass, property } = _decorator;
@ccclass("GamerRoleNode")
//* ─── 玩家在地图上的角色 Node ────────────────────────────────────────────────────────────
/**
* @description:
*/
export class GamerRoleNode extends Node {
constructor(type: GamerRoleType) {
super();
//角色类型 设置后自动播放动画
this.addComponent(RoleAnimation).type = type;
}
}
//* ─── 角色动画播放 Component ───────────────────────────────────────────────────────────────────
export enum PlayAniState {
//播放中
playing,
//暂停
pause,
}
/**
* @description:
*/
export class RoleAnimation extends Component {
/** 节点精灵 */
private sprite: Sprite;
/** 精灵帧总数 */
private frameCount: number;
/** 是否初始化完成 */
private InitState: boolean;
/** 精灵帧map缓存 */
private frameMap: Map<number, SpriteFrame> = new Map<number, SpriteFrame>();
/** 每一帧需要显示的时间 千分之一秒 */
private static frameShowTime: number = 60;
/** 当前帧显示了的时间 */
private nowFrameTime: number = 0;
/** 当前帧 */
private nowFrameIndex: number = 0;
/** 动画状态 */
private playState: PlayAniState = PlayAniState.playing;
/** 角色类型 设置后自动播放动画 */
set type(type: GamerRoleType) {
const node = new Node();
this.node.addChild(node);
this.sprite = node.addComponent(Sprite);
//设置类型
this.sprite.sizeMode = Sprite.SizeMode.RAW;
//设置
this.sprite.trim = false;
// 获取所有帧图片
NpkImageTool.GetNpkImageAll(
GamerRoleAni.getPath(type),
(count, frameMap) => {
this.frameCount = count;
this.frameMap = frameMap;
this.InitState = true;
// 显示第一帧
this.sprite.spriteFrame = this.frameMap.get(this.nowFrameIndex);
}
);
}
start() {}
update(dt: number) {
//如果游戏世界处于暂停的模式下 不再继续播放
if (GameState.getInstance().IsPauseState()) return;
//如果初始化未完成,不播放
if (!this.InitState) return;
//如果不在播放中
if (this.playState != PlayAniState.playing) return;
//每帧增加过去的时间 取千分之一秒为单位
this.nowFrameTime += Math.trunc(dt * 1000);
// 大于60毫秒换下一帧
if (this.nowFrameTime < 60) return;
this.nowFrameTime -= 60;
this.nowFrameTime++;
// 播放完成后 重新播放
if (this.nowFrameIndex >= this.frameCount) this.nowFrameIndex = 0;
this.sprite.spriteFrame = this.frameMap.get(this.nowFrameIndex);
}
}

View File

@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "7b231e75-2650-4560-a447-3e3de615fdae",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@ -0,0 +1,410 @@
/*
* @Author: WoNiu
* @Date: 2024-03-27 16:10:31
* @LastEditTime: 2024-03-29 10:49:55
* @LastEditors: WoNiu
* @Description:
*/
/// 官网总数 63
import { NpkImage, NpkImagePath } from "../../Tool/NPKImage";
//* ─── 玩家角色类型 ──────────────────────────────────────────────────────────────────
/**
* @description:
*
*/
export enum GamerRoleType {
/** 散打 */
SanDa,
/** 柔道 */
RouDao,
/** 气功 */
QiGong,
/** 街霸 */
JieBa,
/** 女漫游 */
NvManYou,
/** 女弹药 */
NvDanYao,
/** 女机械 */
NvJiXie,
/** 女枪炮 */
NvQiangPao,
/** 冰洁 */
BingJie,
/** 元素爆破 */
YuanSuBaoPo,
/** 剑魔 */
JianMo,
/** 剑宗 */
JianZong,
/** 暗殿骑士 */
AnDianQiShi,
/** 流浪骑士 */
LiuLangQiShi,
/** 光枪 */
GuangQiang,
/** 暗枪 */
AnQiang,
/** 女街霸 */
NvJieBa,
/** 女散打 */
NvSanDa,
/** 女气功 */
NvQiGong,
/** 女柔道 */
NvRouDao,
/** 弹药 */
DanYao,
/** 枪炮 */
QiangPao,
/** 机械 */
JiXie,
/** 漫游 */
ManYou,
/** 战法 */
ZanFa,
/** 召唤 */
ZhaoHuan,
/** 魔道 */
MoDao,
/** 元素 */
YuanSu,
/** 复仇 */
FuChou,
/** 篮拳 */
LanQuan,
/** 圣骑 */
ShenQi,
/** 驱魔 */
QuMo,
/** 狂战 */
KuangZhan,
/** 鬼泣 */
GuiQi,
/** 阿修罗 */
AXiuLuo,
/** 剑魂 */
JianHun,
/** 刺客 */
Cike,
/** 影武者 */
YinWuZhe,
/** 忍者 */
RenZhe,
/** 死灵 */
SiLin,
/** 普通鬼剑士 */
GuiJianShi,
}
//* ─── 角色立绘 路径 ─────────────────────────────────────────────────────────────────
/**
* @description:
*/
export class GamerRoleCardDate {
/** NPk路径 */
npkPath: string;
/** index */
index: number;
constructor(index: number) {
this.npkPath = NpkImage.character_sd;
this.index = index;
}
/**
* @description:
*/
static getDate(type: GamerRoleType): GamerRoleCardDate {
switch (type) {
// 散打
case GamerRoleType.SanDa:
return new GamerRoleCardDate(29);
// 柔道
case GamerRoleType.RouDao:
return new GamerRoleCardDate(31);
// 气功
case GamerRoleType.QiGong:
return new GamerRoleCardDate(28);
// 街霸
case GamerRoleType.JieBa:
return new GamerRoleCardDate(30);
// 女漫游
case GamerRoleType.NvManYou:
return new GamerRoleCardDate(20);
// 女弹药
case GamerRoleType.NvDanYao:
return new GamerRoleCardDate(23);
// 女机械
case GamerRoleType.NvJiXie:
return new GamerRoleCardDate(22);
// 女枪炮
case GamerRoleType.NvQiangPao:
return new GamerRoleCardDate(21);
// 冰洁
case GamerRoleType.BingJie:
return new GamerRoleCardDate(33);
// 元素爆破
case GamerRoleType.YuanSuBaoPo:
return new GamerRoleCardDate(32);
// 剑魔
case GamerRoleType.JianMo:
return new GamerRoleCardDate(41);
// 剑宗
case GamerRoleType.JianZong:
return new GamerRoleCardDate(39);
// 暗殿骑士
case GamerRoleType.AnDianQiShi:
return new GamerRoleCardDate(40);
// 流浪骑士
case GamerRoleType.LiuLangQiShi:
return new GamerRoleCardDate(42);
// 光枪
case GamerRoleType.GuangQiang:
return new GamerRoleCardDate(48);
// 暗枪
case GamerRoleType.AnQiang:
return new GamerRoleCardDate(47);
// 女街霸
case GamerRoleType.NvJieBa:
return new GamerRoleCardDate(6);
// 女散打
case GamerRoleType.NvSanDa:
return new GamerRoleCardDate(5);
// 女气功
case GamerRoleType.NvQiGong:
return new GamerRoleCardDate(4);
// 女柔道
case GamerRoleType.NvRouDao:
return new GamerRoleCardDate(7);
// 弹药
case GamerRoleType.DanYao:
return new GamerRoleCardDate(11);
// 枪炮
case GamerRoleType.QiangPao:
return new GamerRoleCardDate(9);
// 机械
case GamerRoleType.JiXie:
return new GamerRoleCardDate(10);
// 漫游
case GamerRoleType.ManYou:
return new GamerRoleCardDate(8);
// 战法
case GamerRoleType.ZanFa:
return new GamerRoleCardDate(14);
// 召唤
case GamerRoleType.ZhaoHuan:
return new GamerRoleCardDate(13);
// 魔道
case GamerRoleType.MoDao:
return new GamerRoleCardDate(15);
// 元素
case GamerRoleType.YuanSu:
return new GamerRoleCardDate(12);
// 复仇
case GamerRoleType.FuChou:
return new GamerRoleCardDate(19);
// 篮拳
case GamerRoleType.LanQuan:
return new GamerRoleCardDate(16);
// 圣骑
case GamerRoleType.ShenQi:
return new GamerRoleCardDate(17);
// 驱魔
case GamerRoleType.QuMo:
return new GamerRoleCardDate(18);
// 狂战
case GamerRoleType.KuangZhan:
return new GamerRoleCardDate(2);
// 鬼泣
case GamerRoleType.GuiQi:
return new GamerRoleCardDate(1);
// 阿修罗
case GamerRoleType.AXiuLuo:
return new GamerRoleCardDate(3);
// 剑魂
case GamerRoleType.JianHun:
return new GamerRoleCardDate(0);
// 刺客
case GamerRoleType.Cike:
return new GamerRoleCardDate(24);
// 影武者
case GamerRoleType.YinWuZhe:
return new GamerRoleCardDate(27);
// 忍者
case GamerRoleType.RenZhe:
return new GamerRoleCardDate(26);
// 死灵
case GamerRoleType.SiLin:
return new GamerRoleCardDate(25);
// 普通鬼剑士
case GamerRoleType.GuiJianShi:
return new GamerRoleCardDate(62);
}
}
}
//* ─── 角色站立动画 路径 ───────────────────────────────────────────────────────────────
/**
* @description:
*/
export class GamerRoleAni {
/**
* @description:
*/
static getPath(type: GamerRoleType): string {
switch (type) {
// 散打
case GamerRoleType.SanDa:
return NpkImagePath + "role_1_sanda.img";
// 柔道
case GamerRoleType.RouDao:
return NpkImagePath + "role_2_roudao.img";
// 气功
case GamerRoleType.QiGong:
return NpkImagePath + "role_3_qigong.img";
// 街霸
case GamerRoleType.JieBa:
return NpkImagePath + "role_4_jieba.img";
// 女漫游
case GamerRoleType.NvManYou:
return NpkImagePath + "role_5_nv_manyou.img";
// 女弹药
case GamerRoleType.NvDanYao:
return NpkImagePath + "role_6_nv_danyao.img";
// 女机械
case GamerRoleType.NvJiXie:
return NpkImagePath + "role_7_nv_jixie.img";
// 女枪炮
case GamerRoleType.NvQiangPao:
return NpkImagePath + "role_8_nv_qiangpao.img";
// 冰洁
case GamerRoleType.BingJie:
return NpkImagePath + "role_9_bingjie.img";
// 元素爆破
case GamerRoleType.YuanSuBaoPo:
return NpkImagePath + "role_10_yuasubaopo.img";
// 剑魔
case GamerRoleType.JianMo:
return NpkImagePath + "role_11_jianmo.img";
// 剑宗
case GamerRoleType.JianZong:
return NpkImagePath + "role_12_jianzong.img";
// 暗殿骑士
case GamerRoleType.AnDianQiShi:
return NpkImagePath + "role_13_andianqishi.img";
// 流浪骑士
case GamerRoleType.LiuLangQiShi:
return NpkImagePath + "role_14_liulangjianshi.img";
// 光枪
case GamerRoleType.GuangQiang:
return NpkImagePath + "role_15_guangqiang.img";
// 暗枪
case GamerRoleType.AnQiang:
return NpkImagePath + "role_16_anqiang.img";
// 女街霸
case GamerRoleType.NvJieBa:
return NpkImagePath + "role_17_nv_jieba.img";
// 女散打
case GamerRoleType.NvSanDa:
return NpkImagePath + "role_18_nv_sanda.img";
// 女气功
case GamerRoleType.NvQiGong:
return NpkImagePath + "role_19_nv_qigong.img";
// 女柔道
case GamerRoleType.NvRouDao:
return NpkImagePath + "role_20_nv_roudao.img";
// 弹药
case GamerRoleType.DanYao:
return NpkImagePath + "role_21_danyao.img";
// 枪炮
case GamerRoleType.QiangPao:
return NpkImagePath + "role_22_qiangpao.img";
// 机械
case GamerRoleType.JiXie:
return NpkImagePath + "role_23_jixie.img";
// 漫游
case GamerRoleType.ManYou:
return NpkImagePath + "role_24_manyou.img";
// 战法
case GamerRoleType.ZanFa:
return NpkImagePath + "role_25_zhanfa.img";
// 召唤
case GamerRoleType.ZhaoHuan:
return NpkImagePath + "role_26_zhaohuan.img";
// 魔道
case GamerRoleType.MoDao:
return NpkImagePath + "role_27_modao.img";
// 元素
case GamerRoleType.YuanSu:
return NpkImagePath + "role_28_yuansu.img";
// 复仇
case GamerRoleType.FuChou:
return NpkImagePath + "role_29_fuchou.img";
// 篮拳
case GamerRoleType.LanQuan:
return NpkImagePath + "role_30_lanquan.img";
// 圣骑
case GamerRoleType.ShenQi:
return NpkImagePath + "role_31_shenqi.img";
// 驱魔
case GamerRoleType.QuMo:
return NpkImagePath + "role_32_qumo.img";
// 狂战
case GamerRoleType.KuangZhan:
return NpkImagePath + "role_33_kuangzhan.img";
// 鬼泣
case GamerRoleType.GuiQi:
return NpkImagePath + "role_34_guiqi.img";
// 阿修罗
case GamerRoleType.AXiuLuo:
return NpkImagePath + "role_35_axiuluo.img";
// 剑魂
case GamerRoleType.JianHun:
return NpkImagePath + "role_36_jianhun.img";
// 刺客
case GamerRoleType.Cike:
return NpkImagePath + "role_37_ceke.img";
// 影武者
case GamerRoleType.YinWuZhe:
return NpkImagePath + "role_38_yinwuzhe.img";
// 忍者
case GamerRoleType.RenZhe:
return NpkImagePath + "role_39_renzhe.img";
// 死灵
case GamerRoleType.SiLin:
return NpkImagePath + "role_40_silin.img";
// 普通鬼剑士
case GamerRoleType.GuiJianShi:
return NpkImagePath + "role_41_guijian.img";
}
}
}

View File

@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "150e386d-95e6-4ebc-af15-1ef927aa4788",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@ -11,7 +11,7 @@ import {
Vec3,
} from "cc";
import { NpkImage } from "../../Tool/NPKImage";
import { MapTileDirection } from "./MapTileData";
import { MapTileDirection } from "./MapTileType";
import { BaseSprite } from "../../GlobalScript/CommonComponent/BaseSprite";
import { DiamondCheck, Point } from "./../Common/InDiamondCheck";
const { ccclass } = _decorator;

View File

@ -1,5 +1,12 @@
import { _decorator, Component, Node } from "cc";
import { MapTileData, MapTileFactory, MapTileType } from "./MapTileData";
/*
* @Author: WoNiu
* @Date: 2024-03-16 16:34:19
* @LastEditTime: 2024-03-28 21:09:58
* @LastEditors: WoNiu
* @Description:
*/
import { _decorator, Component, } from "cc";
import { MapTileData, MapTileType } from "./MapTileType";
const { ccclass } = _decorator;
@ccclass("MapTileController")
@ -13,7 +20,7 @@ export class MapTileController extends Component {
private _tileType: MapTileType;
set tileType(newType: MapTileType){
this._tileType = newType;
this._tileData = MapTileFactory.getData(newType as MapTileType);
this._tileData = MapTileData.getData(newType as MapTileType);
};
get tileType(){ return this._tileType; };

View File

@ -1,11 +1,11 @@
import { _decorator, Node } from "cc";
import {
MapTileDirection,
MapTileType,
} from "./MapTileData";
import { MapTileDirection, MapTileType } from "./MapTileType";
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 "../DialogRoot/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,155 +1,165 @@
import { Vec2, v2 } from "cc";
import { NpkImage } from "../../Tool/NPKImage";
/// 地块类型
//* ─── 地块类型 ────────────────────────────────────────────────────────────────────
/** 地块类型 */
export enum MapTileType {
/// 赫顿玛尔
/** 赫顿玛尔 */
HeDunMaEr = 0,
/// 时间广场
/** 时间广场 */
ShiJianGuangChang,
/// 兽人峡谷
/** 兽人峡谷 */
ShouRenXiaGu,
/// 超时空漩涡
/** 超时空漩涡 */
ChaoShiKongXuanWo,
/// 恐怖的栖息地
/** 恐怖的栖息地 */
KongBuDeQiXiDi,
/// 红色魔女之森
/** 红色魔女之森 */
HongSeMoNvZhiSen,
/// 月光酒馆
/** 月光酒馆 */
YueGuangJiuGuan,
/// 亡命杀阵
/** 亡命杀阵 */
WangMingShaZhen,
/// 皇家娱乐
/** 皇家娱乐 */
HuangJaiYuLe,
/// 黑暗都市
/** 黑暗都市 */
HeiAnDuShi,
/// 哈林的命运硬币(左边)
/** 哈林的命运硬币(左边) */
HaLinMingYunYinBi,
/// 第九隔离区
/** 第九隔离区 */
DiJiuGeLiQu,
/// 决斗场
/** 决斗场 */
JueDouChang,
/// 腐坏街道
/** 腐坏街道 */
FuHuaiJieDao,
/// 溢血的地下城
/** 溢血的地下城 */
YiXueDeDiXiaChen,
/// 普雷·伊西斯
/** 普雷·伊西斯 */
PuLeiYiXiSi,
/// 沉重的礼拜堂
/** 沉重的礼拜堂 */
ChenZhongDeLiBaiTang,
/// 螺旋王国
/** 螺旋王国 */
LuoXuanWangGuo,
/// 海上列车
/** 海上列车 */
HaiShangLieChe,
/// 暗黑神殿
/** 暗黑神殿 */
AnHeiShenDian,
/// 痛苦地下城
/** 痛苦地下城 */
TongKuDiXiaChen,
/// 无底坑道
/** 无底坑道 */
WuDiKenDao,
/// 切斯特小镇的命运硬币(右边)
/** 切斯特小镇的命运硬币(右边) */
XiaoZhenMingYunYinBi,
/// 记忆之地
/** 记忆之地 */
JiYiZhiDi,
}
//* ─── 所有地块类型数组 ────────────────────────────────────────────────────────────────
/** 所有地块类型数组 */
export const MapTileTypes = [
/// 赫顿玛尔
/** 赫顿玛尔 */
MapTileType.HeDunMaEr,
/// 时间广场
MapTileType.ShiJianGuangChang,
/// 兽人峡谷
MapTileType.ShouRenXiaGu,
/// 超时空漩涡
MapTileType.ChaoShiKongXuanWo,
/// 恐怖的栖息地
MapTileType.KongBuDeQiXiDi,
/// 红色魔女之森
MapTileType.HongSeMoNvZhiSen,
/** 时间广场 */
MapTileType.ShiJianGuangChang,
/** 兽人峡谷 */
MapTileType.ShouRenXiaGu,
/** 超时空漩涡 */
MapTileType.ChaoShiKongXuanWo,
/** 恐怖的栖息地 */
MapTileType.KongBuDeQiXiDi,
/** 红色魔女之森 */
MapTileType.HongSeMoNvZhiSen,
/// 月光酒馆
MapTileType.YueGuangJiuGuan,
/// 亡命杀阵
MapTileType.WangMingShaZhen,
/// 皇家娱乐
MapTileType.HuangJaiYuLe,
/// 黑暗都市
MapTileType.HeiAnDuShi,
/// 哈林的命运硬币(左边)
MapTileType.HaLinMingYunYinBi,
/// 第九隔离区
MapTileType.DiJiuGeLiQu,
/** 月光酒馆 */
MapTileType.YueGuangJiuGuan,
/** 亡命杀阵 */
MapTileType.WangMingShaZhen,
/** 皇家娱乐 */
MapTileType.HuangJaiYuLe,
/** 黑暗都市 */
MapTileType.HeiAnDuShi,
/** 哈林的命运硬币(左边) */
MapTileType.HaLinMingYunYinBi,
/** 第九隔离区 */
MapTileType.DiJiuGeLiQu,
/// 决斗场
MapTileType.JueDouChang,
/// 腐坏街道
MapTileType.FuHuaiJieDao,
/// 溢血的地下城
MapTileType.YiXueDeDiXiaChen,
/// 普雷·伊西斯
MapTileType.PuLeiYiXiSi,
/// 沉重的礼拜堂
MapTileType.ChenZhongDeLiBaiTang,
/// 螺旋王国
MapTileType.LuoXuanWangGuo,
/** 决斗场 */
MapTileType.JueDouChang,
/** 腐坏街道 */
MapTileType.FuHuaiJieDao,
/** 溢血的地下城 */
MapTileType.YiXueDeDiXiaChen,
/** 普雷·伊西斯 */
MapTileType.PuLeiYiXiSi,
/** 沉重的礼拜堂 */
MapTileType.ChenZhongDeLiBaiTang,
/** 螺旋王国 */
MapTileType.LuoXuanWangGuo,
/// 海上列车
MapTileType.HaiShangLieChe,
/// 暗黑神殿
MapTileType.AnHeiShenDian,
/// 痛苦地下城
MapTileType.TongKuDiXiaChen,
/// 无底坑道
MapTileType.WuDiKenDao,
/// 切斯特小镇的命运硬币(右边)
MapTileType.XiaoZhenMingYunYinBi,
/// 记忆之地
MapTileType.JiYiZhiDi,
/** 海上列车 */
MapTileType.HaiShangLieChe,
/** 暗黑神殿 */
MapTileType.AnHeiShenDian,
/** 痛苦地下城 */
MapTileType.TongKuDiXiaChen,
/** 无底坑道 */
MapTileType.WuDiKenDao,
/** 切斯特小镇的命运硬币(右边) */
MapTileType.XiaoZhenMingYunYinBi,
/** 记忆之地 */
MapTileType.JiYiZhiDi,
];
/// 地块方向
//* ─── 地块方向 ────────────────────────────────────────────────────────────────────
/** 地块方向 */
export enum MapTileDirection {
/// 横
/** 横 */
horizontal = 24,
/// 竖
/** 竖 */
vertical = 25,
/// 角落
/** 角落 */
nook = 26,
}
/// 地块的数据
export class MapTileData {
/// 坐标
location: Vec2;
/// npk路径
npkPath: NpkImage;
/// 地块背景index
backgroundIndex: number;
/// 地块方向
direction: MapTileDirection;
/// 怪物相关数据
//* ─── 地块的数据 ───────────────────────────────────────────────────────────────────
/// 列车选择许可
/** 地块的数据 */
export class MapTileData {
/** 坐标 */
location: Vec2;
/** npk路径 */
npkPath: NpkImage;
/** 地块背景index */
backgroundIndex: number;
/** 地块方向 */
direction: MapTileDirection;
/** 怪物相关数据 */
/** 列车选择许可 */
trainsSelectLicense: boolean;
/// 决斗场选择许可
/** 决斗场选择许可 */
duelSelectLicense: boolean;
/// 占领许可
/** 占领许可 */
occupyLicense: boolean;
constructor({
/// 坐标
/** 坐标 */
location,
/// 背景index
/** 背景index */
backgroundIndex,
/// 地块方向
/** 地块方向 */
direction,
/// 占领许可
/** 占领许可 */
occupyLicense,
/// 列车选择许可
/** 列车选择许可 */
trainsSelectLicense,
/// 决斗场选择许可
/** 决斗场选择许可 */
duelSelectLicense,
}: {
location: Vec2;
@ -168,87 +178,85 @@ export class MapTileData {
this.duelSelectLicense = duelSelectLicense ?? true;
this.occupyLicense = occupyLicense ?? true;
}
}
export class MapTileFactory {
static getData(type: MapTileType): MapTileData {
switch (type) {
/// 赫顿玛尔
case MapTileType.HeDunMaEr:
return MapTileFactory.HeDunMaErData;
return this.HeDunMaErData;
/// 时间广场
case MapTileType.ShiJianGuangChang:
return MapTileFactory.ShiJianGuangChangData;
return this.ShiJianGuangChangData;
/// 兽人峡谷
case MapTileType.ShouRenXiaGu:
return MapTileFactory.ShouRenXiaGuData;
return this.ShouRenXiaGuData;
/// 超时空漩涡
case MapTileType.ChaoShiKongXuanWo:
return MapTileFactory.ChaoShiKongXuanWoData;
return this.ChaoShiKongXuanWoData;
/// 恐怖的栖息地
case MapTileType.KongBuDeQiXiDi:
return MapTileFactory.KongBuDeQiXiDiData;
return this.KongBuDeQiXiDiData;
/// 红色魔女之森
case MapTileType.HongSeMoNvZhiSen:
return MapTileFactory.HongSeMoNvZhiSenData;
return this.HongSeMoNvZhiSenData;
/// 月光酒馆
case MapTileType.YueGuangJiuGuan:
return MapTileFactory.YueGuangJiuGuanData;
return this.YueGuangJiuGuanData;
/// 亡命杀镇子
case MapTileType.WangMingShaZhen:
return MapTileFactory.WangMingShaZhenData;
return this.WangMingShaZhenData;
/// 皇家娱乐
case MapTileType.HuangJaiYuLe:
return MapTileFactory.HuangJaiYuLeData;
return this.HuangJaiYuLeData;
/// 黑暗都市
case MapTileType.HeiAnDuShi:
return MapTileFactory.HeiAnDuShiData;
return this.HeiAnDuShiData;
/// 哈林的命运硬币(左边)
case MapTileType.HaLinMingYunYinBi:
return MapTileFactory.HaLinMingYunYinBiData;
return this.HaLinMingYunYinBiData;
/// 第九隔离区
case MapTileType.DiJiuGeLiQu:
return MapTileFactory.DiJiuGeLiQuData;
return this.DiJiuGeLiQuData;
/// 决斗场
case MapTileType.JueDouChang:
return MapTileFactory.JueDouChangData;
return this.JueDouChangData;
/// 腐坏街道
case MapTileType.FuHuaiJieDao:
return MapTileFactory.FuHuaiJieDaoData;
return this.FuHuaiJieDaoData;
/// 溢血的地下城
case MapTileType.YiXueDeDiXiaChen:
return MapTileFactory.YiXueDeDiXiaChenData;
return this.YiXueDeDiXiaChenData;
/// 普雷·伊西斯
case MapTileType.PuLeiYiXiSi:
return MapTileFactory.PuLeiYiXiSiData;
return this.PuLeiYiXiSiData;
/// 沉重的礼拜堂
case MapTileType.ChenZhongDeLiBaiTang:
return MapTileFactory.ChenZhongDeLiBaiTangData;
return this.ChenZhongDeLiBaiTangData;
/// 螺旋王国
case MapTileType.LuoXuanWangGuo:
return MapTileFactory.LuoXuanWangGuoData;
return this.LuoXuanWangGuoData;
/// 海上列车
case MapTileType.HaiShangLieChe:
return MapTileFactory.HaiShangLieCheData;
return this.HaiShangLieCheData;
/// 暗黑神殿
case MapTileType.AnHeiShenDian:
return MapTileFactory.AnHeiShenDianData;
return this.AnHeiShenDianData;
/// 痛苦地下城
case MapTileType.TongKuDiXiaChen:
return MapTileFactory.TongKuDiXiaChenData;
return this.TongKuDiXiaChenData;
/// 无底坑道
case MapTileType.WuDiKenDao:
return MapTileFactory.WuDiKenDaoData;
return this.WuDiKenDaoData;
/// 切斯特小镇的命运硬币(右边)
case MapTileType.XiaoZhenMingYunYinBi:
return MapTileFactory.XiaoZhenMingYunYinBiData;
return this.XiaoZhenMingYunYinBiData;
/// 记忆之地
case MapTileType.JiYiZhiDi:
return MapTileFactory.JiYiZhiDiData;
return this.JiYiZhiDiData;
}
}
// 赫顿玛尔
/** 赫顿玛尔 */
private static HeDunMaErData = new MapTileData({
location: v2(475, -448),
direction: MapTileDirection.nook,
@ -256,38 +264,38 @@ export class MapTileFactory {
occupyLicense: false,
});
/// 时间广场 (55,34)
/** 时间广场 (55,34) */
private static ShiJianGuangChangData = new MapTileData({
location: v2(420, -414),
direction: MapTileDirection.horizontal,
});
/// 兽人峡谷 (52,34)
/** 兽人峡谷 (52,34) */
private static ShouRenXiaGuData = new MapTileData({
location: v2(368, -380),
direction: MapTileDirection.horizontal,
});
/// 超时空漩涡 (53,34)
/** 超时空漩涡 (53,34) */
private static ChaoShiKongXuanWoData = new MapTileData({
location: v2(315, -346),
backgroundIndex: 32,
direction: MapTileDirection.horizontal,
});
/// 恐怖的栖息地 (52,34)
/** 恐怖的栖息地 (52,34) */
private static KongBuDeQiXiDiData = new MapTileData({
location: v2(262, -312),
direction: MapTileDirection.horizontal,
});
/// 红色魔女之森 (52,34)
/** 红色魔女之森 (52,34) */
private static HongSeMoNvZhiSenData = new MapTileData({
location: v2(209, -278),
direction: MapTileDirection.horizontal,
});
// 月光酒馆(69,44)
// 月光酒馆(69,44) */
private static YueGuangJiuGuanData = new MapTileData({
location: v2(140, -234),
direction: MapTileDirection.nook,
@ -295,24 +303,24 @@ export class MapTileFactory {
occupyLicense: false,
});
/// 亡命杀镇 (53,34)
/** 亡命杀镇 (53,34) */
private static WangMingShaZhenData = new MapTileData({
location: v2(209, -198),
direction: MapTileDirection.vertical,
});
/// 皇家娱乐(53,34)
/** 皇家娱乐(53,34) */
private static HuangJaiYuLeData = new MapTileData({
location: v2(262, -164),
direction: MapTileDirection.vertical,
});
/// 黑暗都市
/** 黑暗都市 */
private static HeiAnDuShiData = new MapTileData({
location: v2(315, -130),
direction: MapTileDirection.vertical,
});
/// 哈林的命运硬币(左边)
/** 哈林的命运硬币(左边) */
private static HaLinMingYunYinBiData = new MapTileData({
location: v2(368, -96),
backgroundIndex: 34,
@ -320,13 +328,13 @@ export class MapTileFactory {
duelSelectLicense: false,
occupyLicense: false,
});
/// 第九隔离区
/** 第九隔离区 */
private static DiJiuGeLiQuData = new MapTileData({
location: v2(421, -62),
direction: MapTileDirection.vertical,
});
// 决斗场(54,44)
// 决斗场(54,44) */
private static JueDouChangData = new MapTileData({
location: v2(475, -18),
direction: MapTileDirection.nook,
@ -334,38 +342,38 @@ export class MapTileFactory {
occupyLicense: false,
});
/// 腐坏街道(53,34)
/** 腐坏街道(53,34) */
private static FuHuaiJieDaoData = new MapTileData({
location: v2(544, -62),
direction: MapTileDirection.horizontal,
});
/// 溢血的地下城(53,34)
/** 溢血的地下城(53,34) */
private static YiXueDeDiXiaChenData = new MapTileData({
location: v2(597, -96),
direction: MapTileDirection.horizontal,
});
/// 普雷·伊西斯
/** 普雷·伊西斯 */
private static PuLeiYiXiSiData = new MapTileData({
location: v2(650, -130),
backgroundIndex: 33,
direction: MapTileDirection.horizontal,
});
/// 沉重的礼拜堂
/** 沉重的礼拜堂 */
private static ChenZhongDeLiBaiTangData = new MapTileData({
location: v2(703, -164),
direction: MapTileDirection.horizontal,
});
/// 螺旋王国
/** 螺旋王国 */
private static LuoXuanWangGuoData = new MapTileData({
location: v2(756, -198),
direction: MapTileDirection.horizontal,
});
// 海上列车(69,44)
// 海上列车(69,44) */
private static HaiShangLieCheData = new MapTileData({
location: v2(808, -234),
direction: MapTileDirection.nook,
@ -374,25 +382,25 @@ export class MapTileFactory {
occupyLicense: false,
});
/// 暗黑神殿
/** 暗黑神殿 */
private static AnHeiShenDianData = new MapTileData({
location: v2(756, -278),
direction: MapTileDirection.vertical,
});
/// 痛苦地下城
/** 痛苦地下城 */
private static TongKuDiXiaChenData = new MapTileData({
location: v2(703, -312),
direction: MapTileDirection.vertical,
});
/// 无底坑道
/** 无底坑道 */
private static WuDiKenDaoData = new MapTileData({
location: v2(650, -346),
direction: MapTileDirection.vertical,
});
/// 切斯特小镇的命运硬币(右边)
/** 切斯特小镇的命运硬币(右边) */
private static XiaoZhenMingYunYinBiData = new MapTileData({
location: v2(597, -380),
backgroundIndex: 34,
@ -401,9 +409,11 @@ export class MapTileFactory {
occupyLicense: false,
});
/// 记忆之地
/** 记忆之地 */
private static JiYiZhiDiData = new MapTileData({
location: v2(544, -414),
direction: MapTileDirection.vertical,
});
}

View File

@ -0,0 +1,93 @@
/*
* @Author: WoNiu
* @Date: 2024-03-26 11:36:36
* @LastEditTime: 2024-03-29 14:03:36
* @LastEditors: WoNiu
* @Description:
*/
import { LuckyCoinsNode, LuckyType } from "../DialogRoot/LuckyCoinsNode";
import { GameRootSingleton } from "../GameRootController";
/**
* @description:
*/
export class MapTitleAction {
// ─── 特殊事件 ────────────────────────────────────────────────────────────
//* 月光酒馆
//* 决斗场
//* 海上列车
//* 幸运硬币
/**
* @description:
*/
static lucky(type: LuckyType) {
// 将幸运硬币动画节点添加到 Dialog 层
const node = new LuckyCoinsNode(type, () => {
LuckyAction.Action(type);
});
GameRootSingleton.getInstance().DialogRootNode.addChild(node);
}
// ─── 怪物事件 ────────────────────────────────────────────────────────────────────
/**
* @description:
*/
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,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "38b0fe6c-2083-4510-92d6-8f50384fac2c",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@ -0,0 +1,35 @@
/*
* @Author: WoNiu
* @Date: 2024-03-27 15:20:29
* @LastEditTime: 2024-03-28 21:15:43
* @LastEditors: WoNiu
* @Description:
*/
import { MapTileType, MapTileTypes } from "./MapTileType";
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 "./MapTileType";
/**
* @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

@ -3,8 +3,8 @@ import { BaseSprite } from '../../GlobalScript/CommonComponent/BaseSprite';
import { NpkImage } from '../../Tool/NPKImage';
import { BaseButton } from '../../GlobalScript/CommonComponent/BaseButton';
import { AnimationNode } from '../../GlobalScript/Animation/AnimationNode';
import { UIRoot } from '../UIRoot';
import {CloseButtonNode } from '../Common/CloseButtonNode';
import { GameRootSingleton } from '../GameRootController';
const { ccclass } = _decorator;
/// 开始游戏按钮界面
@ -12,18 +12,7 @@ const { ccclass } = _decorator;
export class StartGameUINode extends Node {
/// 玩法介绍
private _pressenNode: Node;
set pressenNode(node: Node){
if (this._pressenNode){
this._pressenNode.destroy();
this._pressenNode = null;
}
this._pressenNode = node;
}
get pressenNode(): Node{
return this._pressenNode;
}
private pressenNode: Node;
constructor(){
super();
@ -70,11 +59,7 @@ export class StartGameUINode extends Node {
/// 给节点添加 button 组件
const buttonComponent = startButtonNode.addComponent( BaseButton );
buttonComponent.ImgPath = NpkImage.main;
buttonComponent.NormalImgIndex = 1;
buttonComponent.HoverImgIndex = 2;
buttonComponent.PressImgIndex = 3;
buttonComponent.DisableImgIndex = 4;
buttonComponent.init(NpkImage.main,1);
startButtonNode.addComponent( Button)
startButtonNode.on(Button.EventType.CLICK,this.startOnTouchEnd,this);
@ -103,11 +88,7 @@ export class StartGameUINode extends Node {
/// 给节点添加 button 组件
const buttonComponent = pressenButtonNode.addComponent( BaseButton );
buttonComponent.ImgPath = NpkImage.main;
buttonComponent.NormalImgIndex = 9;
buttonComponent.HoverImgIndex = 10;
buttonComponent.PressImgIndex = 11;
buttonComponent.DisableImgIndex = 12;
buttonComponent.init(NpkImage.main,9);
pressenButtonNode.on(Node.EventType.MOUSE_UP,this.pressenOnTouchEnd,this);
@ -156,7 +137,7 @@ export class StartGameUINode extends Node {
/// 开始游戏
startOnTouchEnd(event:Event){
const uiroot = this.parent.getComponent( UIRoot );
const uiroot = GameRootSingleton.getInstance().UIRoot;
uiroot.initGameUI();
/// 一帧结束之后销毁

View File

@ -1,80 +0,0 @@
import { _decorator, EventMouse, Node } from 'cc';
import { BaseSprite } from '../../GlobalScript/CommonComponent/BaseSprite';
import { NpkImage } from '../../Tool/NPKImage';
import { BaseButton, BaseButtonState } from '../../GlobalScript/CommonComponent/BaseButton';
import { BaseButtonAction } from '../../GlobalScript/CommonComponent/BaseButtonAction';
const { ccclass } = _decorator;
/// 投骰子按钮的整个节点
@ccclass('DiceButtonNode')
export class DiceButtonNode extends Node {
winButtonComponent: BaseButton;
spaceButtonComponent: BaseButton;
winButtonBlock: Function;
spaceDownBlock: Function;
spaceUpBlock: Function;
constructor(){
super();
const backgroundNode = new Node();
const bs = backgroundNode.addComponent( BaseSprite );
bs.updateSpriteFrame(NpkImage.ingame,7);
this.addChild(backgroundNode);
/// 其他获胜条件
const winButtonNode = new Node();
this.addChild(winButtonNode);
winButtonNode.setPosition(20.5,-123);
const winBa = winButtonNode.addComponent(BaseButtonAction);
winBa.onMouseUp = this.winOnMouseUp.bind(this);
this.winButtonComponent = winButtonNode.addComponent( BaseButton );
this.winButtonComponent.ButtonState = BaseButtonState.Disable;
this.winButtonComponent.ImgPath = NpkImage.ingame;
this.winButtonComponent.NormalImgIndex = 58;
this.winButtonComponent.HoverImgIndex = 59;
this.winButtonComponent.PressImgIndex = 60;
this.winButtonComponent.DisableImgIndex = 61;
/// space
const spaceButtonNode = new Node();
this.addChild(spaceButtonNode);
spaceButtonNode.setPosition(89,-57);
const spaceBc = spaceButtonNode.addComponent( BaseButtonAction);
spaceBc.onMouseLeftDown = this.spaceOnMouseDown.bind(this);
spaceBc.onMouseLeftUp = this.spaceOnMouseUp.bind(this);
this.spaceButtonComponent = spaceButtonNode.addComponent( BaseButton );
this.spaceButtonComponent.ButtonState = BaseButtonState.Disable;
this.spaceButtonComponent.ImgPath = NpkImage.ingame;
this.spaceButtonComponent.NormalImgIndex = 8;
this.spaceButtonComponent.HoverImgIndex = 9;
this.spaceButtonComponent.PressImgIndex = 10;
this.spaceButtonComponent.DisableImgIndex = 11;
}
/// 其他获胜条件
private winOnMouseUp(event:EventMouse){
if (this.winButtonComponent.ButtonState == BaseButtonState.Disable ) return;
if (this.winButtonBlock) this.winButtonBlock();
}
/// 投骰子
private spaceOnMouseDown(event:EventMouse){
if (this.spaceButtonComponent.ButtonState == BaseButtonState.Disable ) return;
if (this.spaceDownBlock) this.spaceDownBlock();
}
private spaceOnMouseUp(event: EventMouse){
if (this.spaceButtonComponent.ButtonState == BaseButtonState.Disable ) return;
if (this.spaceUpBlock) this.spaceUpBlock();
}
}

View File

@ -1,157 +0,0 @@
import {
_decorator,
Component,
Director,
director,
Node,
UITransform,
} from "cc";
import { CharacterType, GamerNode } from "./UINode/GamerNode";
import { BaseSprite } from "../GlobalScript/CommonComponent/BaseSprite";
import { NpkImage } from "../Tool/NPKImage";
import { AnimationNode } from "../GlobalScript/Animation/AnimationNode";
import { BaseButtonState } from "../GlobalScript/CommonComponent/BaseButton";
import { DiceButtonNode } from "./UINode/DiceButtonNode";
import { OtherWinNode, otherWinType } from "./UINode/OtherWinNode";
import { BoardRoot } from "./BoardRoot";
import { StartGameUINode } from "./StartGameNode/StartGameUINode";
const { ccclass } = _decorator;
@ccclass("UIRoot")
export class UIRoot extends Component {
/// 等待玩家
private awaitGamerNode: Node;
/// 玩家一
private gamerOne: GamerNode;
/// 玩家二
private gamerTwo: GamerNode;
/// 玩家三
private gamerThree: GamerNode;
/// 投骰子按钮
private diceButton: DiceButtonNode;
/// 其他胜利条件
private otherWinNode: OtherWinNode;
/// 初始化开始游戏界面的UI
initStartGameUI() {
const startGameUINode = new StartGameUINode();
startGameUINode.addComponent(UITransform).setContentSize(1067, 600);
this.node.addChild(startGameUINode);
}
/// 初始化游戏界面UI
initGameUI() {
/// 玩家UI
this.initGamerUI();
/// 右下骰子操作按钮
this.initDiceButton();
/// 等待玩家加载
this.initAwaitGamerUI();
/// 其他胜利条件
this.initOtherNode();
}
/// 初始化玩家UI
initGamerUI() {
this.gamerOne = new GamerNode("玩家一");
this.gamerOne.setPosition(0, -540);
this.gamerOne.charchterType = CharacterType.JianHun;
this.node.addChild(this.gamerOne);
this.gamerTwo = new GamerNode("");
this.gamerTwo.setPosition(877, 0);
this.node.addChild(this.gamerTwo);
this.gamerThree = new GamerNode("");
this.node.addChild(this.gamerThree);
this.initDiceButton();
}
/// 初始化等待玩家加载UI
initAwaitGamerUI() {
const node = new Node();
node.setPosition(177.5, -244.5);
this.node.addChild(node);
const spr = node.addComponent(BaseSprite);
spr.updateSpriteFrame(NpkImage.loading_loop, 0);
const ani = new AnimationNode("ani/loading_loop01.ani");
ani.setPosition(350, -110);
node.addChild(ani);
this.awaitGamerNode = node;
/// 2秒后 结束加载
setTimeout(() => {
/// 这一帧结束之后销毁
director.once(Director.EVENT_END_FRAME, () => {
// 销毁
this.awaitGamerNode.destroy();
/// 初始化开始倒计时动画
// this.initCountFontAni(5);
});
this.aniDone();
}, 2000);
}
/// 初始化倒计时动画
initCountFontAni(index: number) {
const ani = new AnimationNode("ani/dnf_quiz_" + index + ".ani", () => {
director.once(Director.EVENT_END_FRAME, () => {
ani.destroy();
});
if (index > 1) {
this.initCountFontAni(index - 1);
} else {
/// 动画结束
this.aniDone();
}
});
ani.setPosition(420, -180);
this.node.addChild(ani);
}
/// 初始化投骰子按钮
initDiceButton() {
this.diceButton = new DiceButtonNode();
this.diceButton.setPosition(849, -453);
this.node.addChild(this.diceButton);
/// 显示其他胜利条件
this.diceButton.winButtonBlock = () => {
this.otherWinNode.active = true;
};
}
/// 初始化其他胜利条件
initOtherNode() {
this.otherWinNode = new OtherWinNode(otherWinType.longRun);
this.node.addChild(this.otherWinNode);
this.otherWinNode.active = false;
}
/// 动画结束
aniDone() {
/// 恢复其他胜利按钮的状态
this.diceButton.winButtonComponent.ButtonState = BaseButtonState.Normal;
/// 显示其他胜利条件
this.otherWinNode.active = true;
const boardNode = this.node.parent.getChildByName("BoardRoot");
/// 显示最底层的地图块
const board = boardNode.getComponent(BoardRoot);
board.initMapTile();
}
start() {
this.node.addComponent(UITransform).setContentSize(1067, 600);
this.initStartGameUI();
}
update(deltaTime: number) {}
}

View File

@ -0,0 +1,271 @@
/*
* @Author: WoNiu
* @Date: 2024-03-13 12:19:50
* @LastEditTime: 2024-03-29 13:01:41
* @LastEditors: WoNiu
* @Description:
*/
/*
* @Author: WoNiu
* @Date: 2024-03-13 12:19:50
* @LastEditTime: 2024-03-25 14:19:53
* @LastEditors: WoNiu
* @Description:
*/
import {
_decorator,
Component,
EventMouse,
Node,
Sprite,
SpriteFrame,
Texture2D,
UITransform,
v2,
} from "cc";
import { BaseSprite } from "../../GlobalScript/CommonComponent/BaseSprite";
import { NpkImage, NpkImageTool } from "../../Tool/NPKImage";
import {
BaseButton,
BaseButtonState,
} from "../../GlobalScript/CommonComponent/BaseButton";
import { BaseButtonAction } from "../../GlobalScript/CommonComponent/BaseButtonAction";
import { ImagePack } from "../../GlobalScript/ImagePack/ImagePack";
import { GameState } from "../../GlobalScript/GlobalGameState/GameState";
import { ImgInfo } from "../../GlobalScript/GlobalInterface/GlobalInterface";
import { GamerRoleAni, GamerRoleType } from "../Gamer/GamerRoleType";
const { ccclass } = _decorator;
@ccclass("DiceButtonNode")
/**
* @description:
*/
export class DiceButtonNode extends Node {
winButtonComponent: BaseButton;
diceButtonComponent: BaseButton;
winButtonBlock: Function;
diceDownBlock: Function;
diceUpBlock: Function;
gaugeAnimation: GaugeAnimation;
constructor() {
super();
this.initBackgroundNode();
this.initOtherWinButtonNode();
this.initdiceButtonNode();
this.initdiceDiceAniNode();
}
// 背景节点
private initBackgroundNode(){
const backgroundNode = new Node();
const bs = backgroundNode.addComponent(BaseSprite);
bs.updateSpriteFrame(NpkImage.ingame, 7);
this.addChild(backgroundNode);
}
// 其他获胜条件按钮节点
private initOtherWinButtonNode() {
/// 其他获胜条件
const winButtonNode = new Node();
this.addChild(winButtonNode);
winButtonNode.setPosition(20.5, -123);
const winBa = winButtonNode.addComponent(BaseButtonAction);
winBa.onMouseUp = this.winOnMouseUp.bind(this);
this.winButtonComponent = winButtonNode.addComponent(BaseButton);
this.winButtonComponent.init(NpkImage.ingame, 60);
}
// 骰子按钮节点
private initdiceButtonNode() {
/// dice 按钮
const diceButtonNode = new Node('diceButton');
this.addChild(diceButtonNode);
diceButtonNode.setPosition(89, -57);
const diceBc = diceButtonNode.addComponent(BaseButtonAction);
diceBc.onMouseLeftDown = this.diceOnMouseDown.bind(this);
diceBc.onMouseLeftUp = this.diceOnMouseUp.bind(this);
this.diceButtonComponent = diceButtonNode.addComponent(BaseButton);
this.diceButtonComponent.init(NpkImage.ingame, 8);
this.diceButtonComponent.ButtonState = BaseButtonState.Disable;
}
// 播放动画节点
private initdiceDiceAniNode() {
const node = new Node();
this.addChild(node);
node.setPosition(45, -15);
//设置节点锚点为左上角
node.addComponent(UITransform).anchorPoint = v2(0, 1);
this.gaugeAnimation = node.addComponent(GaugeAnimation);
}
/// 其他获胜条件
private winOnMouseUp(event: EventMouse) {
if (this.winButtonComponent.ButtonState == BaseButtonState.Disable) return;
if (this.winButtonBlock) this.winButtonBlock();
}
/// 投骰子
private diceOnMouseDown(event: EventMouse) {
console.log('diceOnMouseDown');
if (this.diceButtonComponent.ButtonState == BaseButtonState.Disable)
return;
if (this.diceDownBlock) this.diceDownBlock();
this.gaugeAnimation.updatePlayState(PlayAniState.playing);
}
private diceOnMouseUp(event: EventMouse) {
console.log('diceOnMouseUp');
if (this.diceButtonComponent.ButtonState == BaseButtonState.Disable)
return;
if (this.diceUpBlock) this.diceUpBlock();
this.gaugeAnimation.updatePlayState(PlayAniState.pause);
}
}
//* ─── 动画播放 ────────────────────────────────────────────────────────────────────
export enum PlayAniState {
//未播放
unplayed,
//播放中
playing,
//倒放
reversed,
//暂停
pause,
//播放完成
done,
}
/**
* @description:
*/
export class GaugeAnimation extends Component {
// 所有精灵帧缓存
private frameMap: Map<number, SpriteFrame> = new Map<number, SpriteFrame>();
// 精灵帧的数量
private frameCount: number = 100;
// 精灵帧初始化状态
private InitState: boolean = false;
// 总的播放时间
private aniTime: number = 1;
// 当前帧显示时间
private nowFrameTime: number = 0;
// 每一帧需要显示的时间
private frameShowTime: number = 0;
// 当前帧
private nowFrameIndex: number = -1;
//* 动画状态
private playState: PlayAniState = PlayAniState.unplayed;
// 节点的精灵
private sprite: Sprite;
onLoad() {
if (!this.node.getComponent(Sprite)) {
this.sprite = this.node.addComponent(Sprite);
} else {
this.sprite = this.node.getComponent(Sprite);
}
//设置类型
this.sprite.sizeMode = Sprite.SizeMode.RAW;
//设置
this.sprite.trim = false;
NpkImageTool.GetNpkImageAll(NpkImage.gauge, (count,frameMap)=>{
this.frameMap = frameMap;
this.frameCount = count;
this.InitState = true;
});
}
start() {}
/**
* @description:
* @param {PlayAniState} palyState: 动画状态
* @param {number} aniTime
*/
updatePlayState(palyState: PlayAniState, aniTime?: number) {
this.playState = palyState;
// 数据的初始化
if (this.playState == PlayAniState.unplayed) {
this.sprite.spriteFrame = null;
this.nowFrameIndex = -1;
} else if (
this.playState == (PlayAniState.playing || PlayAniState.reversed)
) {
this.aniTime = aniTime ?? this.aniTime;
// 单帧显示时间
this.frameShowTime = this.aniTime * 1000 / this.frameCount;
// this.frameShowTime = this.frameShowTime / this.frameCount;
}
// 精灵帧的初始化
if (this.playState == PlayAniState.playing) {
this.sprite.spriteFrame = this.frameMap.get(0);
} else if (this.playState == PlayAniState.reversed) {
this.sprite.spriteFrame = this.frameMap.get(this.frameCount - 1);
}
}
update(dt: number) {
//如果游戏世界处于暂停的模式下 不再继续播放
if (GameState.getInstance().IsPauseState()) return;
//如果初始化未完成,不播放
if (!this.InitState) return;
//如果不在播放中
if (this.playState != PlayAniState.playing && this.playState != PlayAniState.reversed)
return;
//每帧增加过去的时间 取千分之一秒为单位
this.nowFrameTime += Math.trunc(dt * 1000);
// 计算当前加减帧数
const index = Math.trunc(this.nowFrameTime / this.frameShowTime);
// 当前帧时间不足 一帧显示就跳过
if (index < 1) return;
// 将多余的时间 重新赋值回去
this.nowFrameTime = this.nowFrameTime % this.frameShowTime;
if (this.playState == PlayAniState.playing) {
this.nowFrameIndex += index
this.sprite.spriteFrame = this.frameMap.get(this.nowFrameIndex);
// 播放到最后一帧 修改播放状态 为倒放
if (this.nowFrameIndex >= this.frameCount - 1) {
this.playState = PlayAniState.reversed;
}
} else if (this.playState == PlayAniState.reversed) {
this.nowFrameIndex -= index;
this.sprite.spriteFrame = this.frameMap.get(this.nowFrameIndex);
// 播放到第一帧 修改播放状态 为倒放
if (this.nowFrameIndex <= 0) {
this.playState = PlayAniState.playing;
}
}
}
}

View File

@ -0,0 +1,50 @@
/*
* @Author: WoNiu
* @Date: 2024-03-29 13:20:16
* @LastEditTime: 2024-03-29 14:16:51
* @LastEditors: WoNiu
* @Description:
*/
import { _decorator, Component, Director, director, Node } from "cc";
import { UIRoot } from "./UIRoot";
import { GameRootSingleton } from "./../GameRootController";
const { ccclass, property } = _decorator;
@ccclass("GameMatchingProcessControl")
/**
* @description:
*/
export class GameMatchingProcessControl extends Component {
/** UIRoot 节点的 UI节点 */
uiRoot: UIRoot;
start() {
this.uiRoot = GameRootSingleton.getInstance().UIRoot;
this.countDown();
}
//todo 自动跳过,接入网络后修改
/** 匹配加载动画控制 */
countDown() {
// 1秒后 结束加载
setTimeout(() => {
/// 这一帧结束之后销毁
director.once(Director.EVENT_END_FRAME, () => {
// 销毁
this.uiRoot.awaitGamerNode.destroy();
// todo 开发时跳过倒计时动画
/// 初始化开始倒计时动画
// this.initCountDownFontAni(5);
});
// todo 开发时跳过倒计时动画
this.uiRoot.countDownAniDone();
}, 1000);
}
update(deltaTime: number) {}
}

View File

@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "79e2c1f6-7206-4356-82a5-09f3d1039dff",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@ -0,0 +1,48 @@
/*
* @Author: WoNiu
* @Date: 2024-03-29 14:04:56
* @LastEditTime: 2024-03-29 14:14:48
* @LastEditors: WoNiu
* @Description:
*/
import { _decorator, Component, Node } from "cc";
import { GamerRoleNode } from "../Gamer/GamerRoleNode";
import { GamerRoleType } from "../Gamer/GamerRoleType";
const { ccclass, property } = _decorator;
@ccclass("GameRoleController")
/**
* @description:
*/
export class GameRoleController extends Component {
/** 玩家 1 角色 */
oneRole: GamerRoleNode;
/** 玩家 2 角色 */
twoRole: GamerRoleNode;
/** 玩家 3 角色 */
threeRole: GamerRoleNode;
/**
* @description:
* @param oneRoleType : 玩家 1
* @param twoRoleType : 玩家 2
* @param threeRoleType : 玩家 3
*/
initRole(
oneRoleType: GamerRoleType,
twoRoleType: GamerRoleType,
threeRoleType: GamerRoleType
) {
this.oneRole = new GamerRoleNode(oneRoleType);
this.twoRole = new GamerRoleNode(twoRoleType);
this.threeRole = new GamerRoleNode(threeRoleType);
this.node.addChild(this.oneRole);
this.node.addChild(this.twoRole);
this.node.addChild(this.threeRole);
}
start() {}
update(deltaTime: number) {}
}

View File

@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "80141aea-c2a5-4eab-8430-59484a333bf1",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@ -0,0 +1,178 @@
import {
_decorator,
Component,
Director,
director,
Node,
UITransform,
} from "cc";
import { GamerCardNode } from "./../Gamer/GamerCardNode";
import { BaseSprite } from "../../GlobalScript/CommonComponent/BaseSprite";
import { NpkImage } from "../../Tool/NPKImage";
import { AnimationNode } from "../../GlobalScript/Animation/AnimationNode";
import { BaseButtonState } from "../../GlobalScript/CommonComponent/BaseButton";
import { DiceButtonNode } from "../UIRoot/DiceButtonNode";
import { OtherWinNode, otherWinType } from "../UIRoot/OtherWinNode";
import { BoardRoot } from "../BoardRoot";
import { StartGameUINode } from "../StartGameNode/StartGameUINode";
import { GamerRoleType } from "../Gamer/GamerRoleType";
import { SelectNumberNode } from "../DialogRoot/SelectNumberNode";
const { ccclass } = _decorator;
@ccclass("UIRoot")
/**
* @description: UIRoot节点的 UI
*/
export class UIRoot extends Component {
/** 玩家一 */
private gamerCardOne: GamerCardNode;
/** 玩家二 */
private gamerCardTwo: GamerCardNode;
/** 玩家三 */
private gamerCardThree: GamerCardNode;
/** 等待玩家 */
awaitGamerNode: Node;
/** 投骰子按钮 */
diceButton: DiceButtonNode;
/** 其他胜利条件 */
otherWinNode: OtherWinNode;
// ─── 初始化ui ───────────────────────────────────────────────────────────────────
/** 初始化开始游戏界面的UI */
initStartGameUI() {
const startGameUINode = new StartGameUINode();
startGameUINode.addComponent(UITransform).setContentSize(1067, 600);
this.node.addChild(startGameUINode);
}
/** 初始化游戏界面UI */
initGameUI() {
/// 玩家UI
this.initGamerUI();
/// 右下骰子操作按钮
this.initDiceButton();
/// 等待玩家加载
this.initAwaitGamerUI();
}
/** 初始化玩家卡片 UI */
private initGamerUI() {
this.gamerCardOne = new GamerCardNode("玩家一");
this.gamerCardOne.setPosition(0, -540);
this.gamerCardOne.charchterType = GamerRoleType.JianHun;
this.node.addChild(this.gamerCardOne);
this.gamerCardTwo = new GamerCardNode("");
this.gamerCardTwo.setPosition(877, 0);
this.node.addChild(this.gamerCardTwo);
this.gamerCardThree = new GamerCardNode("");
this.node.addChild(this.gamerCardThree);
}
/** 初始化骰子节点 */
private initDiceButton() {
this.diceButton = new DiceButtonNode();
this.diceButton.setPosition(849, -453);
this.node.addChild(this.diceButton);
/// 显示其他胜利条件
this.diceButton.winButtonBlock = () => {
this.otherWinNode.active = true;
};
this.diceButton.diceUpBlock = () => {};
}
/** 初始化其他胜利条件 */
initOtherWinNode(type: otherWinType) {
if (!this.otherWinNode) {
this.otherWinNode = new OtherWinNode(type);
this.node.addChild(this.otherWinNode);
this.otherWinNode.active = false;
}
}
/** 初始化并显示顺序选择node */
initSelectNumberNode(): SelectNumberNode {
const selectNode = new SelectNumberNode();
this.node.addChild(selectNode);
return selectNode;
}
// ─── 动画初始化 ──────────────────────────────────────────────────────────
/** 初始化等待玩家加载UI */
initAwaitGamerUI() {
const node = new Node();
node.setPosition(177.5, -244.5);
this.node.addChild(node);
const spr = node.addComponent(BaseSprite);
spr.updateSpriteFrame(NpkImage.loading_loop, 0);
const ani = new AnimationNode("ani/loading_loop01.ani");
ani.setPosition(350, -110);
node.addChild(ani);
this.awaitGamerNode = node;
}
/** 初始化倒计时动画 */
initCountDownFontAni(index: number) {
const ani = new AnimationNode("ani/count_font.ani", () => {
/// 这一帧结束之后销毁
director.once(Director.EVENT_END_FRAME, () => {
// 销毁
ani.destroy();
});
/// 动画结束
this.countDownAniDone();
});
ani.setPosition(500, -200);
this.node.addChild(ani);
}
/** 倒计时动画结束 */
countDownAniDone() {
/// 恢复其他胜利按钮的状态
this.diceButton.winButtonComponent.ButtonState = BaseButtonState.Normal;
/// 显示其他胜利条件
this.otherWinNode.active = true;
const boardNode = this.node.parent.getChildByName("BoardRoot");
/// 显示最底层的地图块
const board = boardNode.getComponent(BoardRoot);
board.initMapTile();
// 1秒后自动关闭胜利条件显示,并显示顺序选择
setTimeout(() => {
// 隐藏其他胜利条件 node
this.otherWinNode.active = false;
const select = this.initSelectNumberNode();
select.doneFunc = () => {
// todo 开发阶段在选择顺序结束后,恢复骰子按钮状态
this.diceButton.diceButtonComponent.ButtonState =
BaseButtonState.Normal;
};
}, 1000);
}
// ─── 生命周期 ────────────────────────────────────────────────────────────
start() {
this.node.addComponent(UITransform).setContentSize(1067, 600);
/// 初始化 开始游戏 的 UI
this.initStartGameUI();
}
update(deltaTime: number) {}
}

View File

@ -0,0 +1,145 @@
/*
* @Author: WoNiu
* @Date: 2024-03-21 13:44:57
* @LastEditTime: 2024-03-25 19:42:52
* @LastEditors: WoNiu
* @Description:
*/
/*
* @Author: WoNiu
* @Date: 2024-03-21 13:44:57
* @LastEditTime: 2024-03-23 12:57:36
* @LastEditors: WoNiu
* @Description:
*/
import {
_decorator,
Component,
Director,
director,
Node,
ProgressBar,
Sprite,
tween,
UITransform,
v2,
} from "cc";
import { BaseSprite } from "../../GlobalScript/CommonComponent/BaseSprite";
import { NpkImage } from "../../Tool/NPKImage";
import { LocationImportComponent } from "../../GlobalScript/CommonComponent/LocationImportComponent";
const { ccclass } = _decorator;
/// 倒计时时间进度Node
@ccclass("TimingProgressBar")
export class TimingProgressBar extends Node {
//* 进度条bar
progressBar: ProgressBar;
//* 进度条精灵
barSprite: Sprite;
//* 缓动控制
timingComponent: TimingComponent;
constructor() {
super();
this.setPosition(353.5, -355);
this.addComponent(UITransform).anchorPoint = v2(0, 1);
this.timingComponent = this.addComponent(TimingComponent);
this.initBackgrund();
this.initBarSprite();
this.initProgressBar();
}
//* 倒计时缓动开始
/**
* @description:
* @param {number} time
* @param {Function} back
*/
tweenerStart(time:number,back:Function){
this.timingComponent.tweenerStart(time,back);
}
initBackgrund() {
const bs = this.addComponent(BaseSprite);
bs.updateSpriteFrame(NpkImage.ingame, 43);
}
initProgressBar() {
const progressBar = this.addComponent(ProgressBar);
progressBar.barSprite = this.barSprite;
progressBar.mode = ProgressBar.Mode.FILLED;
progressBar.totalLength = 280;
progressBar.progress = 1;
this.progressBar = progressBar;
}
initBarSprite() {
const node = new Node();
this.addChild(node);
node.setPosition(60, -22);
const barNode = new Node();
node.addChild(barNode);
this.barSprite = barNode.addComponent(Sprite);
const bs = barNode.addComponent(BaseSprite);
bs.updateSpriteFrame(NpkImage.ingame, 45);
this.barSprite = bs.SpriteObj;
this.barSprite.spriteFrame = bs.SpriteObj.spriteFrame;
this.barSprite.type = Sprite.Type.FILLED;
}
}
@ccclass("TimingComponent")
export class TimingComponent extends Component {
obj = { progress: 1};
onCompleteBack: Function;
start() {
}
tweenerStart(time:number,back:Function){
this.onCompleteBack = back;
tween(this.obj)
.to(
time,
{ progress: 0 },
{
easing: "linear",
onUpdate: this.onUpdate.bind(this),
onComplete: this.onComplete.bind(this),
}
)
.start();
}
//* 缓动进度
onUpdate(target: any, ratio: number){
const timingProgressBar: TimingProgressBar = this.node as TimingProgressBar;
timingProgressBar.progressBar.progress = this.obj.progress;
}
//* 缓动完成
onComplete(){
this.obj.progress = 1;
this.onCompleteBack();
/// 这一帧结束之后销毁
director.once(Director.EVENT_END_FRAME, () => {
// 销毁
this.node.destroy();
});
}
update(deltaTime: number) {}
}

View File

@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "f93a24df-e11c-4c40-a67f-9d1e61d67547",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@ -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){
@ -12,11 +15,7 @@ export class CloseButtonNode extends Node {
/// 给节点添加 button 组件
const buttonComponent = this.addComponent( BaseButton );
buttonComponent.ImgPath = NpkImage.ingame;
buttonComponent.NormalImgIndex = 39;
buttonComponent.HoverImgIndex = 40;
buttonComponent.PressImgIndex = 41;
buttonComponent.DisableImgIndex = 42;
buttonComponent.init(NpkImage.ingame,39);
/// 添加点击事件
const bba = this.addComponent( BaseButtonAction );
@ -24,5 +23,5 @@ export class CloseButtonNode extends Node {
}
}
}

View File

@ -1,45 +1,121 @@
const path = 'interface2/event/chn_event_2020/200922_dnf_marble/'
/*
* @Author: WoNiu
* @Date: 2024-03-10 20:00:57
* @LastEditTime: 2024-03-29 12:57:23
* @LastEditors: WoNiu
* @Description:
*/
import { SpriteFrame, Texture2D, v2 } from "cc";
import { ImagePack } from "../GlobalScript/ImagePack/ImagePack";
import { ImgInfo } from "../GlobalScript/GlobalInterface/GlobalInterface";
/** interface2/event/chn_event_2020/200922_dnf_marble/ */
export const NpkImagePath =
"interface2/event/chn_event_2020/200922_dnf_marble/";
export enum NpkImage {
main = path + '00_main.img',
ingame = path + '01_ingame.img',
board = path + '02_board.img',
gauge = path + '03_gauge.img',
character_sd = path + '04_character_sd.img',
monsternotice = path + '05_monsternotice.img',
specialplace = path + '06_specialplace.img',
conditionsofvictory = path + '07_conditionsofvictory.img',
calendar = path + '08_calendar.img',
bankruptcy = path + 'bankruptcy.img',
character_loop = path + 'character_loop.img',
count_font = path + 'count_font.img',
dice_1x1_db = path + 'dice_1x1_db.img',
dice_1x2 = path + 'dice_1x2.img',
dice_1x3 = path + 'dice_1x3.img',
dice_2x2_db = path + 'dice_2x2_db.img',
dice_2x3 = path + 'dice_2x3.img',
dice_2x4 = path + 'dice_2x4.img',
dice_3x3_db = path + 'dice_3x3_db.img',
dice_3x4 = path + 'dice_3x4.img',
dice_3x5 = path + 'dice_3x5.img',
dice_4x4_db = path + 'dice_4x4_db.img',
dice_4x5 = path + 'dice_4x5.img',
dice_4x6 = path + 'dice_4x6.img',
dice_5x5 = path + 'dice_5x5.img',
dice_5x6 = path + 'dice_5x6.img',
dice_6x6_db = path + 'dice_6x6_db.img',
dice_font = path + 'dice_font.img',
dungeonbg = path + 'dungeonbg.img',
fire_loop = path + 'fire_loop.img',
light01 = path + 'light01.img',
light02 = path + 'light02.img',
loading_loop = path + 'loading_loop.img',
luckycoin = path + 'luckycoin.img',
luckycoin_bg = path + 'luckycoin_bg.img',
point_loop = path + 'point_loop.img',
table_back = path + 'table_back.img',
table_dodge = path + 'table_dodge.img',
table_front = path + 'table_front.img',
title_loop = path + 'title_loop.img',
win = path + 'win.img',
};
main = NpkImagePath + "00_main.img",
ingame = NpkImagePath + "01_ingame.img",
board = NpkImagePath + "02_board.img",
gauge = NpkImagePath + "03_gauge.img",
character_sd = NpkImagePath + "04_character_sd.img",
monsternotice = NpkImagePath + "05_monsternotice.img",
specialplace = NpkImagePath + "06_specialplace.img",
conditionsofvictory = NpkImagePath + "07_conditionsofvictory.img",
calendar = NpkImagePath + "08_calendar.img",
bankruptcy = NpkImagePath + "bankruptcy.img",
character_loop = NpkImagePath + "character_loop.img",
count_font = NpkImagePath + "count_font.img",
dice_1x1_db = NpkImagePath + "dice_1x1_db.img",
dice_1x2 = NpkImagePath + "dice_1x2.img",
dice_1x3 = NpkImagePath + "dice_1x3.img",
dice_2x2_db = NpkImagePath + "dice_2x2_db.img",
dice_2x3 = NpkImagePath + "dice_2x3.img",
dice_2x4 = NpkImagePath + "dice_2x4.img",
dice_3x3_db = NpkImagePath + "dice_3x3_db.img",
dice_3x4 = NpkImagePath + "dice_3x4.img",
dice_3x5 = NpkImagePath + "dice_3x5.img",
dice_4x4_db = NpkImagePath + "dice_4x4_db.img",
dice_4x5 = NpkImagePath + "dice_4x5.img",
dice_4x6 = NpkImagePath + "dice_4x6.img",
dice_5x5 = NpkImagePath + "dice_5x5.img",
dice_5x6 = NpkImagePath + "dice_5x6.img",
dice_6x6_db = NpkImagePath + "dice_6x6_db.img",
dice_font = NpkImagePath + "dice_font.img",
dungeonbg = NpkImagePath + "dungeonbg.img",
fire_loop = NpkImagePath + "fire_loop.img",
light01 = NpkImagePath + "light01.img",
light02 = NpkImagePath + "light02.img",
loading_loop = NpkImagePath + "loading_loop.img",
luckycoin = NpkImagePath + "luckycoin.img",
luckycoin_bg = NpkImagePath + "luckycoin_bg.img",
point_loop = NpkImagePath + "point_loop.img",
table_back = NpkImagePath + "table_back.img",
table_dodge = NpkImagePath + "table_dodge.img",
table_front = NpkImagePath + "table_front.img",
title_loop = NpkImagePath + "title_loop.img",
win = NpkImagePath + "win.img",
}
interface NpkImageCallback{
/**
* @param {number} frameCount
* @param {Map<number, SpriteFrame>} frameMapMap
*/
(frameCount: number, frameMap: Map<number, SpriteFrame>): void;
}
export class NpkImageTool {
/**
* @description: Npk path路径下的所有
* @param {string} path
* @param {Function} callBack((frameCount, frameMap)number, Map<number, SpriteFrame>
*/
static GetNpkImageAll(path: string, callBack: NpkImageCallback) {
// 精灵帧总数
let frameCount = 0;
// 精灵帧缓存
let frameMap: Map<number, SpriteFrame> = new Map<number, SpriteFrame>();
ImagePack.getInstance().ReadNpkTable(
"sprite/" + path.toLocaleLowerCase(),
(ImgObj: { Png_List: [ImgInfo]; Png_Count: number; }) => {
const Pngs = ImgObj.Png_List;
// 总数量
frameCount = ImgObj.Png_Count;
for (let i = 0; i < Pngs.length; i++) {
const png = Pngs[i];
const spriteFrame = NpkImageTool.initSpriteFrame(png);
frameMap.set(i, spriteFrame);
}
callBack(frameCount, frameMap);
}
);
}
/**
* @description:
* @param {ImgInfo} Png: 动画数据
*/
static initSpriteFrame(Png: ImgInfo): SpriteFrame {
const spriteFrame = new SpriteFrame();
let tex = new Texture2D();
tex.reset({
width: Png.Width,
height: Png.Height,
format: Texture2D.PixelFormat.RGBA8888,
mipmapLevel: 0,
});
tex.uploadData(Png.PNGdata);
// 更新 0 级 Mipmap。
tex.updateImage();
spriteFrame.texture = tex;
spriteFrame.offset = v2(Png.Xpos, -Png.Ypos);
return spriteFrame;
}
}

View File

@ -1,8 +1,7 @@
import { _decorator, Component, director, instantiate, Node, Prefab, resources, Scene } from 'cc';
import { _decorator, Component, director } from 'cc';
import { GlobalAudio } from '../../GlobalScript/GlobalAudio/GlobalAudio';
import { ImagePack } from '../../GlobalScript/ImagePack/ImagePack';
import { GameScript } from '../../GlobalScript/GameScript/GameScript';
import { UIRoot } from '../../Script/UIRoot';
const { ccclass, property } = _decorator;

View File

@ -22,7 +22,9 @@
],
"_active": true,
"_components": [],
"_prefab": null,
"_prefab": {
"__id__": 19
},
"_lpos": {
"__type__": "cc.Vec3",
"x": 0,
@ -52,7 +54,7 @@
},
"autoReleaseAssets": false,
"_globals": {
"__id__": 25
"__id__": 20
},
"_id": "efb7fd68-0786-4a0e-8e5d-46841ad6023c"
},
@ -76,27 +78,21 @@
},
{
"__id__": 11
},
{
"__id__": 15
},
{
"__id__": 18
}
],
"_active": true,
"_components": [
{
"__id__": 21
"__id__": 15
},
{
"__id__": 22
"__id__": 16
},
{
"__id__": 23
"__id__": 17
},
{
"__id__": 24
"__id__": 18
}
],
"_prefab": null,
@ -188,7 +184,7 @@
"_priority": 0,
"_fov": 45,
"_fovAxis": 0,
"_orthoHeight": 346.1673212882954,
"_orthoHeight": 473.21751412429376,
"_near": 0,
"_far": 1000,
"_color": {
@ -562,250 +558,6 @@
"__prefab": null,
"_id": "feJdyZgTlBtLnL5U4x8Hwh"
},
{
"__type__": "cc.Node",
"_name": "Label",
"_objFlags": 0,
"__editorExtras__": {},
"_parent": {
"__id__": 2
},
"_children": [],
"_active": false,
"_components": [
{
"__id__": 16
},
{
"__id__": 17
}
],
"_prefab": null,
"_lpos": {
"__type__": "cc.Vec3",
"x": 460.781,
"y": -273,
"z": 0
},
"_lrot": {
"__type__": "cc.Quat",
"x": 0,
"y": 0,
"z": 0,
"w": 1
},
"_lscale": {
"__type__": "cc.Vec3",
"x": 1,
"y": 1,
"z": 1
},
"_mobility": 0,
"_layer": 33554432,
"_euler": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_id": "9bDuMqKd9OhYCo2Brm7XBF"
},
{
"__type__": "cc.UITransform",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 15
},
"_enabled": true,
"__prefab": null,
"_contentSize": {
"__type__": "cc.Size",
"width": 59.05815762192456,
"height": 54.39999999999999
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_id": "1cDddsfIpJWLM7qjX4jUZl"
},
{
"__type__": "cc.Label",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 15
},
"_enabled": true,
"__prefab": null,
"_customMaterial": null,
"_srcBlendFactor": 2,
"_dstBlendFactor": 4,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_string": "加载中...",
"_horizontalAlign": 1,
"_verticalAlign": 1,
"_actualFontSize": 16.10637300843486,
"_fontSize": 13.5,
"_fontFamily": "Arial",
"_lineHeight": 40,
"_overflow": 0,
"_enableWrapText": true,
"_font": {
"__uuid__": "5ebfd5b0-a054-4349-b69f-f850a1e1fbcd",
"__expectedType__": "cc.TTFFont"
},
"_isSystemFontUsed": false,
"_spacingX": 0,
"_isItalic": false,
"_isBold": false,
"_isUnderline": false,
"_underlineHeight": 2,
"_cacheMode": 0,
"_enableOutline": true,
"_outlineColor": {
"__type__": "cc.Color",
"r": 0,
"g": 0,
"b": 0,
"a": 255
},
"_outlineWidth": 2,
"_enableShadow": false,
"_shadowColor": {
"__type__": "cc.Color",
"r": 0,
"g": 0,
"b": 0,
"a": 255
},
"_shadowOffset": {
"__type__": "cc.Vec2",
"x": 2,
"y": 2
},
"_shadowBlur": 2,
"_id": "9bskEfsttFSpkYFl+TK+Ql"
},
{
"__type__": "cc.Node",
"_name": "nowloading",
"_objFlags": 0,
"__editorExtras__": {},
"_parent": {
"__id__": 2
},
"_children": [],
"_active": false,
"_components": [
{
"__id__": 19
},
{
"__id__": 20
}
],
"_prefab": null,
"_lpos": {
"__type__": "cc.Vec3",
"x": 448.781,
"y": -270,
"z": 0
},
"_lrot": {
"__type__": "cc.Quat",
"x": 0,
"y": 0,
"z": 0,
"w": 1
},
"_lscale": {
"__type__": "cc.Vec3",
"x": 1,
"y": 1,
"z": 1
},
"_mobility": 0,
"_layer": 33554432,
"_euler": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_id": "01u0WBtzJETpNAzZw8pQB3"
},
{
"__type__": "cc.UITransform",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 18
},
"_enabled": true,
"__prefab": null,
"_contentSize": {
"__type__": "cc.Size",
"width": 170,
"height": 30
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_id": "70lYqn5O1DBbchN/agLNK+"
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 18
},
"_enabled": true,
"__prefab": null,
"_customMaterial": null,
"_srcBlendFactor": 2,
"_dstBlendFactor": 4,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_spriteFrame": {
"__uuid__": "235eaff0-b052-4034-aabc-b9023743f51c@f9941",
"__expectedType__": "cc.SpriteFrame"
},
"_type": 0,
"_fillType": 0,
"_sizeMode": 1,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_useGrayscale": false,
"_atlas": null,
"_id": "99S3MSERxLIYPo/qGECCpu"
},
{
"__type__": "cc.UITransform",
"_name": "",
@ -886,31 +638,39 @@
"__prefab": null,
"_id": "26OkVwPkVC07BRPXJ50ncp"
},
{
"__type__": "cc.PrefabInfo",
"root": null,
"asset": null,
"fileId": "efb7fd68-0786-4a0e-8e5d-46841ad6023c",
"instance": null,
"targetOverrides": null
},
{
"__type__": "cc.SceneGlobals",
"ambient": {
"__id__": 26
"__id__": 21
},
"shadows": {
"__id__": 27
"__id__": 22
},
"_skybox": {
"__id__": 28
"__id__": 23
},
"fog": {
"__id__": 29
"__id__": 24
},
"octree": {
"__id__": 30
"__id__": 25
},
"skin": {
"__id__": 31
"__id__": 26
},
"lightProbeInfo": {
"__id__": 32
"__id__": 27
},
"postSettings": {
"__id__": 33
"__id__": 28
},
"bakedWithStationaryMainLight": false,
"bakedWithHighpLightmap": false

View File

@ -23,7 +23,7 @@
"_active": true,
"_components": [],
"_prefab": {
"__id__": 19
"__id__": 16
},
"_lpos": {
"__type__": "cc.Vec3",
@ -54,7 +54,7 @@
},
"autoReleaseAssets": false,
"_globals": {
"__id__": 20
"__id__": 17
},
"_id": "f713b5ea-a70f-486c-8260-0338f089a5b8"
},
@ -77,13 +77,13 @@
"_active": true,
"_components": [
{
"__id__": 16
"__id__": 13
},
{
"__id__": 17
"__id__": 14
},
{
"__id__": 18
"__id__": 15
}
],
"_prefab": null,
@ -175,7 +175,7 @@
"_priority": 0,
"_fov": 45,
"_fovAxis": 0,
"_orthoHeight": 509.95129375951296,
"_orthoHeight": 477.2642163661581,
"_near": 0,
"_far": 1000,
"_color": {
@ -220,10 +220,10 @@
"__id__": 6
},
{
"__id__": 10
"__id__": 9
},
{
"__id__": 13
"__id__": 11
}
],
"_active": true,
@ -232,7 +232,7 @@
"_lpos": {
"__type__": "cc.Vec3",
"x": -533.5,
"y": -300.00000000000006,
"y": 300,
"z": 0
},
"_lrot": {
@ -274,16 +274,13 @@
},
{
"__id__": 8
},
{
"__id__": 9
}
],
"_prefab": null,
"_lpos": {
"__type__": "cc.Vec3",
"x": 0,
"y": 600,
"y": 0,
"z": 0
},
"_lrot": {
@ -345,18 +342,6 @@
"ImgIndex": 0,
"_id": "fc2gTwXM1Lq68bZxSz8rQ1"
},
{
"__type__": "51518t/LCBGQZ6rvzL2I2e5",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 6
},
"_enabled": true,
"__prefab": null,
"_id": "5c+WvJW35JkYzLE6SY7Dmz"
},
{
"__type__": "cc.Node",
"_name": "UIRoot",
@ -369,17 +354,14 @@
"_active": true,
"_components": [
{
"__id__": 11
},
{
"__id__": 12
"__id__": 10
}
],
"_prefab": null,
"_lpos": {
"__type__": "cc.Vec3",
"x": 0,
"y": 600,
"y": 0,
"z": 0
},
"_lrot": {
@ -411,7 +393,7 @@
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 10
"__id__": 9
},
"_enabled": true,
"__prefab": null,
@ -427,18 +409,6 @@
},
"_id": "6cbBeNcXdJr6bJDAOt5tLP"
},
{
"__type__": "a578c1qrTRIdaMFhEtim8LM",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 10
},
"_enabled": true,
"__prefab": null,
"_id": "6clS3n6E1O3Ir6YO9pV5rA"
},
{
"__type__": "cc.Node",
"_name": "DialogRoot",
@ -451,17 +421,14 @@
"_active": true,
"_components": [
{
"__id__": 14
},
{
"__id__": 15
"__id__": 12
}
],
"_prefab": null,
"_lpos": {
"__type__": "cc.Vec3",
"x": 0,
"y": 600,
"y": 0,
"z": 0
},
"_lrot": {
@ -493,7 +460,7 @@
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 13
"__id__": 11
},
"_enabled": true,
"__prefab": null,
@ -509,18 +476,6 @@
},
"_id": "28/iYuYk1JyqaQ0l2uDYPY"
},
{
"__type__": "11718UDzs1Cra3Z5OOr4Z4r",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 13
},
"_enabled": true,
"__prefab": null,
"_id": "d79jn93oZBELG9gxMlR3iL"
},
{
"__type__": "cc.UITransform",
"_name": "",
@ -600,28 +555,28 @@
{
"__type__": "cc.SceneGlobals",
"ambient": {
"__id__": 21
"__id__": 18
},
"shadows": {
"__id__": 22
"__id__": 19
},
"_skybox": {
"__id__": 23
"__id__": 20
},
"fog": {
"__id__": 24
"__id__": 21
},
"octree": {
"__id__": 25
"__id__": 22
},
"skin": {
"__id__": 26
"__id__": 23
},
"lightProbeInfo": {
"__id__": 27
"__id__": 24
},
"postSettings": {
"__id__": 28
"__id__": 25
},
"bakedWithStationaryMainLight": false,
"bakedWithHighpLightmap": false

View File

@ -5,5 +5,6 @@
"width": 1067,
"height": 600
}
}
},
"custom_joint_texture_layouts": []
}