Life.ts 712 B

12345678910111213141516171819202122232425
  1. import { _decorator, Component, Label, Node } from 'cc';
  2. import { LvData } from '../../game/LvData/LvData';
  3. import { Hall } from '../../hall/Hall';
  4. const { ccclass, property } = _decorator;
  5. @ccclass('Life')
  6. export class Life extends Component {
  7. @property(Label)
  8. endTime: Label = null;
  9. protected update(dt: number): void {
  10. let life =LvData.instance.lifeContor;;
  11. if(!life){
  12. this.endTime.node.active = false
  13. return
  14. }
  15. this.endTime.node.active = !life.isMax()
  16. let now = chsdk.date.now()
  17. life.addLastTime(now)
  18. let last = life.needAddTime
  19. this.endTime.string = chsdk.date.ms_format(last-now, "$M:$S")
  20. }
  21. }