import { _decorator, Node } from "cc"; import { MapTileData, MapTileDirection, MapTileFactory, MapTileType, } from "./MapTileData"; import { BaseSprite } from "../GlobalScript/CommonComponent/BaseSprite"; 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; /// 占领图标 private occupyIconNode: Node; /// 决斗场选中的图标 和倍数icon private fightIconNode: Node; /// 控制器 private controller: MapTileController; constructor(type) { super(); this.controller = this.addComponent(MapTileController); this.controller.tileType = type; this.initNode(); } initNode() { /// 背景 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; } /// 名称 if (this.controller.tileData.nameIndex) { const node = new Node(); this.addChild(node); const bs = node.addComponent(BaseSprite); bs.updateSpriteFrame(this.controller.tileData.npkPath, this.controller.tileData.nameIndex); this.nameNode = node; } /// 决斗场选择后的红色边框 // 四角和命运硬币 没有红框 if ( this.controller.tileData.direction != MapTileDirection.nook || this.controller.tileType != (MapTileType.XiaoZhenMingYunYinBi || MapTileType.HaLinMingYunYinBi) ) { const node = new Node(); // node.active = false; this.addChild(node); const bs = node.addComponent(BaseSprite); // 横向地块27 竖向28 bs.updateSpriteFrame( this.controller.tileData.npkPath, this.controller.tileData.direction == MapTileDirection.horizontal ? 27 : 28 ); this.nameNode = node; } /// 鼠标选择边框 const bordeNode = new Node(); // bordeNode.active = false; const bordeBS = bordeNode.addComponent(MapTileButtonComponent); bordeBS.direction = this.controller.tileData.direction; this.borderNode = bordeNode; } }