You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
70 lines
2.1 KiB
70 lines
2.1 KiB
import { _decorator, Component, Node, Sprite } from 'cc';
|
|
import { SpriteLoad } from 'db://assets/mx/components/SpriteLoad';
|
|
import { GBundle, GPath } from '../../game/ConfigRes';
|
|
const { ccclass, property } = _decorator;
|
|
|
|
@ccclass('MapGrid')
|
|
export class MapGrid extends Component {
|
|
@property({ displayName: '是否可以通行' })
|
|
isCanWalk: boolean = true;
|
|
|
|
@property({ displayName: '是否可以放置' })
|
|
isCanPutObstacle: boolean = true;
|
|
|
|
@property({ displayName: '是否可以铲除' })
|
|
isCanRemove: boolean = false;
|
|
|
|
@property({ displayName: '是否可以被雷击' })
|
|
isCanBeThunder: boolean = false;
|
|
|
|
@property({ displayName: '是否最佳摆放点' })
|
|
isBestPlace: boolean = false;
|
|
|
|
/**是否是免费推荐点 */
|
|
@property({ displayName: '是否免费推荐点' })
|
|
isFreePlace: boolean = false;
|
|
|
|
//是否是破损状态
|
|
@property({ displayName: '是否是破损状态' })
|
|
isBroken: boolean = false;
|
|
/** 行 */
|
|
Row = 0;
|
|
/** 列 */
|
|
Col = 0;
|
|
/** 网格索引 */
|
|
Index = 0;
|
|
|
|
statusSprite: Sprite = null;
|
|
removeIcon: Node = null;
|
|
|
|
ShowGuidePos: boolean = false;
|
|
|
|
protected onLoad(): void {
|
|
this.statusSprite = this.node.getOrAddComponent(Sprite);
|
|
}
|
|
|
|
updateGrid() {
|
|
if (gg.game.CurentBattle.IsEdit) {
|
|
let name = "格子状态默认";
|
|
if (this.isCanPutObstacle) name = "格子状态可放置";
|
|
else if (!this.isCanWalk && this.isCanRemove) name = "格子状态已放置";
|
|
this.node.getOrAddComponent(SpriteLoad).setSprite(GPath.ObstacleItem(name), GBundle.BattleMap);
|
|
this.showRemoveIcon(this.isCanRemove);
|
|
} else {
|
|
this.showRemoveIcon(false);
|
|
this.statusSprite.spriteFrame = null;
|
|
}
|
|
}
|
|
|
|
/**显示铲子 */
|
|
showRemoveIcon(isShow: boolean) {
|
|
if (this.removeIcon == null) {
|
|
this.removeIcon = gg.res.getNode(GPath.ObstaclePrefab(""), "removeIcon", GBundle.BattleMap);
|
|
this.node.addChild(this.removeIcon);
|
|
}
|
|
this.removeIcon.active = isShow;
|
|
this.removeIcon.setSiblingIndex(-1);
|
|
}
|
|
}
|
|
|
|
|
|
|