| 
									
										
										
										
											2024-03-18 10:55:21 +08:00
										 |  |  | import { _decorator, Node } from "cc"; | 
					
						
							|  |  |  | import { | 
					
						
							|  |  |  |   MapTileDirection, | 
					
						
							|  |  |  |   MapTileType, | 
					
						
							|  |  |  | } from "./MapTileData"; | 
					
						
							| 
									
										
										
										
											2024-03-19 18:03:50 +08:00
										 |  |  | import { BaseSprite } from "../../GlobalScript/CommonComponent/BaseSprite"; | 
					
						
							| 
									
										
										
										
											2024-03-18 10:55:21 +08:00
										 |  |  | import { MapTileButtonComponent } from "./MapTileButtonComponent"; | 
					
						
							|  |  |  | import { MapTileController } from "./MapTileController"; | 
					
						
							|  |  |  | const { ccclass } = _decorator; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /// 地块
 | 
					
						
							|  |  |  | @ccclass("MapTileNode") | 
					
						
							|  |  |  | export class MapTileNode extends Node { | 
					
						
							|  |  |  |   /// -- Node
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   /// 背景节点
 | 
					
						
							|  |  |  |   private backgroundNode: Node; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   /// 地块名称
 | 
					
						
							|  |  |  |   private nameNode: Node; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   /// 决斗场选中的战斗边框
 | 
					
						
							|  |  |  |   private fightNode: Node; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   /// 鼠标操作变化的边框
 | 
					
						
							|  |  |  |   private borderNode: Node; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-18 20:10:09 +08:00
										 |  |  |   /// 禁止选择
 | 
					
						
							|  |  |  |   private disableNode: Node; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-18 10:55:21 +08:00
										 |  |  |   /// 占领图标
 | 
					
						
							|  |  |  |   private occupyIconNode: Node; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   /// 决斗场选中的图标 和倍数icon
 | 
					
						
							|  |  |  |   private fightIconNode: Node; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   /// 控制器
 | 
					
						
							|  |  |  |   private controller: MapTileController; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   constructor(type) { | 
					
						
							|  |  |  |     super(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     this.controller = this.addComponent(MapTileController); | 
					
						
							|  |  |  |     this.controller.tileType = type; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     this.initNode(); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-18 20:10:09 +08:00
										 |  |  |   /// 测试使用按钮
 | 
					
						
							|  |  |  |   initButtons(){ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-18 10:55:21 +08:00
										 |  |  |   initNode() { | 
					
						
							| 
									
										
										
										
											2024-03-18 20:10:09 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-18 10:55:21 +08:00
										 |  |  |     /// 背景
 | 
					
						
							|  |  |  |     if (this.controller.tileData.backgroundIndex) { | 
					
						
							|  |  |  |       const node = new Node(); | 
					
						
							|  |  |  |       this.addChild(node); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       const bs = node.addComponent(BaseSprite); | 
					
						
							|  |  |  |       bs.updateSpriteFrame( | 
					
						
							|  |  |  |         this.controller.tileData.npkPath, | 
					
						
							|  |  |  |         this.controller.tileData.backgroundIndex | 
					
						
							|  |  |  |       ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       this.backgroundNode = node; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /// 名称
 | 
					
						
							| 
									
										
										
										
											2024-03-18 20:10:09 +08:00
										 |  |  |     const node = new Node(); | 
					
						
							|  |  |  |     this.addChild(node); | 
					
						
							| 
									
										
										
										
											2024-03-18 10:55:21 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-18 20:10:09 +08:00
										 |  |  |     const bs = node.addComponent(BaseSprite); | 
					
						
							|  |  |  |     bs.updateSpriteFrame( | 
					
						
							|  |  |  |       this.controller.tileData.npkPath, | 
					
						
							|  |  |  |       this.controller.tileType | 
					
						
							|  |  |  |     ); | 
					
						
							| 
									
										
										
										
											2024-03-18 10:55:21 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-18 20:10:09 +08:00
										 |  |  |     this.nameNode = node; | 
					
						
							| 
									
										
										
										
											2024-03-18 10:55:21 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |     /// 决斗场选择后的红色边框
 | 
					
						
							|  |  |  |     // 四角和命运硬币 没有红框
 | 
					
						
							|  |  |  |     if ( | 
					
						
							| 
									
										
										
										
											2024-03-18 20:10:09 +08:00
										 |  |  |       this.controller.tileData.direction != MapTileDirection.nook && | 
					
						
							| 
									
										
										
										
											2024-03-18 10:55:21 +08:00
										 |  |  |       this.controller.tileType != | 
					
						
							|  |  |  |         (MapTileType.XiaoZhenMingYunYinBi || MapTileType.HaLinMingYunYinBi) | 
					
						
							|  |  |  |     ) { | 
					
						
							|  |  |  |       const node = new Node(); | 
					
						
							| 
									
										
										
										
											2024-03-18 20:10:09 +08:00
										 |  |  |       node.active = false; | 
					
						
							| 
									
										
										
										
											2024-03-18 10:55:21 +08:00
										 |  |  |       this.addChild(node); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       // 横向地块27 竖向28
 | 
					
						
							| 
									
										
										
										
											2024-03-18 20:10:09 +08:00
										 |  |  |       const bs = node.addComponent(BaseSprite); | 
					
						
							| 
									
										
										
										
											2024-03-18 10:55:21 +08:00
										 |  |  |       bs.updateSpriteFrame( | 
					
						
							|  |  |  |         this.controller.tileData.npkPath, | 
					
						
							|  |  |  |         this.controller.tileData.direction == MapTileDirection.horizontal ? 27 : 28 | 
					
						
							|  |  |  |       ); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-18 20:10:09 +08:00
										 |  |  |       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; | 
					
						
							| 
									
										
										
										
											2024-03-18 10:55:21 +08:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-18 20:10:09 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |     /// 禁止选择
 | 
					
						
							|  |  |  |     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) | 
					
						
							|  |  |  |     this.disableNode = disableNode; | 
					
						
							| 
									
										
										
										
											2024-03-18 10:55:21 +08:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2024-03-18 20:10:09 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   /// 显示海上列车选择
 | 
					
						
							|  |  |  |   shwTrainsSelect(show: boolean){ | 
					
						
							|  |  |  |     if (this.borderNode){ | 
					
						
							|  |  |  |       /// 许可选择
 | 
					
						
							|  |  |  |       if (this.controller.tileData.trainsSelectLicense){ | 
					
						
							|  |  |  |         this.borderNode.active = show; | 
					
						
							|  |  |  |       }else{ | 
					
						
							|  |  |  |         this.disableNode.active = true; | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |     }else{ | 
					
						
							|  |  |  |       this.disableNode.active = false; | 
					
						
							|  |  |  |       this.borderNode.active = false; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-18 10:55:21 +08:00
										 |  |  | } |