import { TankBettle } from "../data/TankBattleGameData" ; import TankBettleBullet from "./TankBattleBullet" ; import { TankBettleTankPlayer } from "./TankBattleTank" ; const { ccclass , property } = cc . _decorator ; @ ccclass export default class TankBattleBlock extends cc . Component { public type : TankBettle . BLOCK_TYPE = null ; description param other private onCollisionEnter ( other , me ) { this . handBullet ( other , me ) ; } description param other private onCollisionStay ( other , me ) { } description param other private onCollisionExit ( other , me ) { } private removeSelf ( ) { this . node . removeFromParent ( ) ; this . node . destroy ( ) ; } private handBullet ( other , me ) { if ( other . node . group == TankBettle . GROUP . Bullet ) { switch ( this . type ) { case TankBettle . BLOCK_TYPE . GRASS : case TankBettle . BLOCK_TYPE . ICE : { } break ; case TankBettle . BLOCK_TYPE . WALL : { this . removeSelf ( ) ; } break ; case TankBettle . BLOCK_TYPE . STONE_WALL : { let bullet = other . node . getComponent ( TankBettleBullet ) ; if ( bullet && bullet . owner instanceof TankBettleTankPlayer ) { if ( bullet . owner . hasStatus ( TankBettle . PLAYER_STATUS . STRONG ) ) { this . removeSelf ( ) ; } } } break ; case TankBettle . BLOCK_TYPE . HOME : { TankBettle . gameData . gameMap . gameOver ( ) ; } break ; } } } }