| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 | 
							- import { _decorator, Label, PhysicsGroup} from 'cc';
 
- import { Role } from '../Role';
 
- import { LifeBar } from './LifeBar';
 
- import { Enemy } from './Enemy';
 
- import { GameInfo } from '../../../GameInfo';
 
- import { GameMgr } from '../../GameFrameWork/GameMgr';
 
- import { GameOver } from './GameOver';
 
- const { ccclass, property } = _decorator;
 
- @ccclass('MyTower')
 
- export class MyTower extends Role {
 
-     private _lifeBar: LifeBar = null;
 
-     private _strMyHp: Label = null;
 
-     protected onLoad(): void {
 
-         this._lifeBar = this.node.getComponent(LifeBar);
 
-         this._strMyHp = this.node.getChildByPath("ProgressBar/Label").getComponent(Label);
 
-     }
 
-     start() {
 
-         this.hp = GameInfo.Instance.getMyTowerHp();
 
-         this._initLifeBar();
 
-     }
 
-     //初始化血条
 
-     private _initLifeBar() {
 
-         this._lifeBar._curHp = GameInfo.Instance.getMyTowerHp();
 
-         this._lifeBar._totalHp = GameInfo.Instance.getMyTowerHp();
 
-     }
 
-     update(deltaTime: number) {
 
-         if(this._lifeBar._curHp <= 0){
 
-             this._gameOverDtSettlement();
 
-         }
 
-         this._strMyHp.string = `${this._lifeBar._curHp}/${this.hp}`;
 
-     }
 
-     getCurHp(){
 
-         return this._lifeBar._curHp;
 
-     }
 
-     getTotalHp(){
 
-         return this._lifeBar._totalHp;
 
-     }
 
-     //游戏结束数据结算
 
-     private _gameOverDtSettlement(){
 
-         GameInfo.Instance.setIsGameOver(true);
 
-         GameInfo.Instance.setOverWin(false);
 
-         GameInfo.Instance.setLifePecent(0);
 
-         GameMgr.Instance.getModuler(GameOver).show();
 
-     }
 
-     //必须实现抽象方法
 
-     protected _getCollisionGroup(): number {
 
-         return PhysicsGroup.Role; //实际分组值根据项目设置
 
-     }
 
-     protected _isValidTarget(target: Role): boolean {
 
-         //通过组件类型判断是否为敌人
 
-         return target instanceof Enemy;
 
-     }
 
- }
 
 
  |