/** @format */ import {Data} from '../GameControl' import {ZumaUI} from '../ui/ZumaUI' import {IBanConfig} from '../config/BanConfig' import {IZumaballConfig, ZumaballConfig} from '../config/ZumaballConfig' import {ZumamapConfig} from '../config/ZumamapConfig' import ZumaCore from './ZumaCore' const {ccclass, property} = cc._decorator export enum BALL_COLOR { green = 1, blue, purple, red, orange, } @ccclass export class Ball extends cc.Component { //小球的颜色 private _ballID: number = 0 //在地图曲线中的位置 private _posIndex: number private zumaCore: ZumaCore public ballCfg: IZumaballConfig init(ballID: number, zumaCore: ZumaCore) { this._ballID = ballID this.ballCfg = ZumaballConfig[ballID] this.zumaCore = zumaCore cc.find('icon', this.node).getComponent(cc.Sprite).spriteFrame = Data.game.gameAssetMap.get( `texture/zuma/balls/${this.ballCfg.icon}`, ) as cc.SpriteFrame } public get ballID(): number { return this._ballID } //------------设置小球的位置-------------- public set posIndex($pos: number) { this._posIndex = $pos if (!Data.zuma.mapData[this._posIndex]) { console.error('posIndex is error') return } this.node.x = Data.zuma.mapData[this._posIndex][0] this.node.y = Data.zuma.mapData[this._posIndex][1] this.node.angle = -Data.zuma.mapData[this._posIndex][2] + 90 } //------------小球爆炸------------------- public explode(): void { this.explodeComplete() } //------------爆炸结束-------------------- private explodeComplete(): void { this.node.parent.removeChild(this.node) } //------------访问小球的位置 在地图曲线中的位置-------------- public get posIndex(): number { return this._posIndex } }