fail.ts 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import { _decorator, Component, Node } from 'cc';
  2. import { gameManager } from '../gameManager';
  3. import { config } from '../../config';
  4. const { ccclass, property } = _decorator;
  5. @ccclass('fail')
  6. export class fail extends Component {
  7. @property(Node) btn_close:Node = null;
  8. @property(Node) btn_fail_reLife:Node = null;
  9. @property(Node) btn_fail_reStart:Node = null;
  10. private m_call_relife = null;
  11. private m_call_restart = null;
  12. public show(is_relife:boolean,call_relife,call_restart){
  13. this.node.active = true;
  14. this.m_call_relife = call_relife;
  15. this.m_call_restart = call_restart;
  16. if(is_relife){
  17. this.btn_fail_reLife.active = true;
  18. }else{
  19. this.btn_fail_reLife.active = false;
  20. }
  21. this.btn_fail_reLife.off(Node.EventType.TOUCH_END)
  22. this.btn_fail_reStart.off(Node.EventType.TOUCH_END)
  23. this.btn_close.off(Node.EventType.TOUCH_END)
  24. this.btn_fail_reLife.on(Node.EventType.TOUCH_END,()=>{
  25. if(this.m_call_relife!=null){
  26. this.m_call_relife()
  27. }
  28. })
  29. this.btn_fail_reStart.on(Node.EventType.TOUCH_END,()=>{
  30. if(this.m_call_restart!=null){
  31. this.m_call_restart()
  32. }
  33. })
  34. this.btn_close.on(Node.EventType.TOUCH_END,()=>{
  35. this.node.active = false;
  36. if(gameManager.Singleton.getLevelData()!=null){
  37. gameManager.Singleton.backGameList(config.BACK_GAME_STATUS.FAIL)
  38. }
  39. })
  40. gameManager.Singleton.sys_fail_prompt_music()
  41. }
  42. }