| 
									
										
										
										
											2024-03-14 14:19:45 +08:00
										 |  |  | import { _decorator, Component, EventMouse, EventTouch, Node, UITransform } from 'cc'; | 
					
						
							| 
									
										
										
										
											2024-03-13 17:04:19 +08:00
										 |  |  | import { BaseSprite } from '../GlobalScript/CommonComponent/BaseSprite'; | 
					
						
							|  |  |  | import { NpkImage } from '../Tool/NPKImage'; | 
					
						
							|  |  |  | import { BaseButton, BaseButtonState } from '../GlobalScript/CommonComponent/BaseButton'; | 
					
						
							| 
									
										
										
										
											2024-03-14 14:19:45 +08:00
										 |  |  | import { BaseButtonAction } from '../GlobalScript/CommonComponent/BaseButtonAction'; | 
					
						
							|  |  |  | 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-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-13 17:04:19 +08:00
										 |  |  |         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; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-14 14:19:45 +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 ); | 
					
						
							|  |  |  |         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; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											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
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } |