fail.ts 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import { _decorator, Component, Node, Animation } 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.node.getComponent(Animation).play()
  15. this.m_call_relife = call_relife;
  16. this.m_call_restart = call_restart;
  17. if(is_relife){
  18. this.btn_fail_reLife.active = true;
  19. }else{
  20. this.btn_fail_reLife.active = false;
  21. }
  22. this.btn_fail_reLife.off(Node.EventType.TOUCH_END)
  23. this.btn_fail_reStart.off(Node.EventType.TOUCH_END)
  24. this.btn_close.off(Node.EventType.TOUCH_END)
  25. this.btn_fail_reLife.on(Node.EventType.TOUCH_END,()=>{
  26. if(this.m_call_relife!=null){
  27. this.m_call_relife()
  28. }
  29. })
  30. this.btn_fail_reStart.on(Node.EventType.TOUCH_END,()=>{
  31. if(this.m_call_restart!=null){
  32. this.m_call_restart()
  33. }
  34. })
  35. this.btn_close.on(Node.EventType.TOUCH_END,()=>{
  36. this.node.active = false;
  37. if(gameManager.Singleton.getLevelData()!=null){
  38. gameManager.Singleton.backGameList(config.BACK_GAME_STATUS.FAIL)
  39. }
  40. })
  41. gameManager.Singleton.sys_fail_prompt_music()
  42. }
  43. }