2024-03-22 22:56:08 +08:00
|
|
|
/*
|
|
|
|
|
* @Author: WoNiu
|
|
|
|
|
* @Date: 2024-03-13 12:19:50
|
|
|
|
|
* @LastEditTime: 2024-03-22 22:49:20
|
|
|
|
|
* @LastEditors: WoNiu
|
|
|
|
|
* @Description:
|
|
|
|
|
*/
|
2024-03-19 18:03:50 +08:00
|
|
|
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';
|
2024-03-14 14:19:45 +08:00
|
|
|
const { ccclass } = _decorator;
|
2024-03-13 17:04:19 +08:00
|
|
|
|
2024-03-14 14:19:45 +08:00
|
|
|
|
|
|
|
|
/// 投骰子按钮的整个节点
|
2024-03-13 17:04:19 +08:00
|
|
|
@ccclass('DiceButtonNode')
|
|
|
|
|
export class DiceButtonNode extends Node {
|
|
|
|
|
|
|
|
|
|
winButtonComponent: BaseButton;
|
|
|
|
|
spaceButtonComponent: BaseButton;
|
2024-03-22 15:48:09 +08:00
|
|
|
|
2024-03-14 14:19:45 +08:00
|
|
|
winButtonBlock: Function;
|
|
|
|
|
spaceDownBlock: Function;
|
|
|
|
|
spaceUpBlock: Function;
|
2024-03-13 17:04:19 +08:00
|
|
|
|
|
|
|
|
constructor(){
|
|
|
|
|
super();
|
|
|
|
|
|
|
|
|
|
const backgroundNode = new Node();
|
|
|
|
|
const bs = backgroundNode.addComponent( BaseSprite );
|
|
|
|
|
bs.updateSpriteFrame(NpkImage.ingame,7);
|
|
|
|
|
this.addChild(backgroundNode);
|
|
|
|
|
|
|
|
|
|
/// 其他获胜条件
|
|
|
|
|
const winButtonNode = new Node();
|
2024-03-14 14:19:45 +08:00
|
|
|
this.addChild(winButtonNode);
|
|
|
|
|
winButtonNode.setPosition(20.5,-123);
|
|
|
|
|
|
|
|
|
|
const winBa = winButtonNode.addComponent(BaseButtonAction);
|
|
|
|
|
winBa.onMouseUp = this.winOnMouseUp.bind(this);
|
2024-03-22 15:48:09 +08:00
|
|
|
|
2024-03-13 17:04:19 +08:00
|
|
|
this.winButtonComponent = winButtonNode.addComponent( BaseButton );
|
2024-03-22 22:56:08 +08:00
|
|
|
this.winButtonComponent.init(NpkImage.ingame,60)
|
2024-03-22 15:48:09 +08:00
|
|
|
|
2024-03-13 17:04:19 +08:00
|
|
|
|
|
|
|
|
/// space
|
|
|
|
|
const spaceButtonNode = new Node();
|
2024-03-14 14:19:45 +08:00
|
|
|
this.addChild(spaceButtonNode);
|
|
|
|
|
spaceButtonNode.setPosition(89,-57);
|
|
|
|
|
|
|
|
|
|
const spaceBc = spaceButtonNode.addComponent( BaseButtonAction);
|
|
|
|
|
spaceBc.onMouseLeftDown = this.spaceOnMouseDown.bind(this);
|
|
|
|
|
spaceBc.onMouseLeftUp = this.spaceOnMouseUp.bind(this);
|
|
|
|
|
|
2024-03-13 17:04:19 +08:00
|
|
|
this.spaceButtonComponent = spaceButtonNode.addComponent( BaseButton );
|
2024-03-22 22:56:08 +08:00
|
|
|
this.spaceButtonComponent.init(NpkImage.ingame,8);
|
2024-03-13 17:04:19 +08:00
|
|
|
this.spaceButtonComponent.ButtonState = BaseButtonState.Disable;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-14 14:19:45 +08:00
|
|
|
/// 其他获胜条件
|
|
|
|
|
private winOnMouseUp(event:EventMouse){
|
|
|
|
|
if (this.winButtonComponent.ButtonState == BaseButtonState.Disable ) return;
|
|
|
|
|
if (this.winButtonBlock) this.winButtonBlock();
|
2024-03-13 17:04:19 +08:00
|
|
|
}
|
|
|
|
|
|
2024-03-14 14:19:45 +08:00
|
|
|
/// 投骰子
|
|
|
|
|
private spaceOnMouseDown(event:EventMouse){
|
|
|
|
|
if (this.spaceButtonComponent.ButtonState == BaseButtonState.Disable ) return;
|
|
|
|
|
if (this.spaceDownBlock) this.spaceDownBlock();
|
2024-03-13 17:04:19 +08:00
|
|
|
}
|
2024-03-14 14:19:45 +08:00
|
|
|
private spaceOnMouseUp(event: EventMouse){
|
|
|
|
|
if (this.spaceButtonComponent.ButtonState == BaseButtonState.Disable ) return;
|
|
|
|
|
if (this.spaceUpBlock) this.spaceUpBlock();
|
2024-03-13 17:04:19 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|