AiPlayerController.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. let library = require("../Library");
  2. let webView = require("../WebView");
  3. cc.Class({
  4. extends: require("BasePlayerController"),
  5. properties: {
  6. },
  7. start()
  8. {
  9. this._super();
  10. if(cc.sys.isMobile)
  11. {
  12. this.avatar.spriteFrame = webView.rivalAvatarSpriteFrame;
  13. this.avatar.node.width = 80;
  14. this.avatar.node.height = 80;
  15. this.playerName.string = webView.rivalUserName;
  16. this.gender.string = webView.rivalGender;
  17. }
  18. this.gStatesScp.playerStatesArr.push(this.pStatesScp);
  19. },
  20. hit()
  21. {
  22. this.pStatesScp.hit++;
  23. this.score.string = this.pStatesScp.hit.toString();
  24. },
  25. actorComeOut(nameIndex,appearDur)
  26. {
  27. // return;
  28. let timing = library.getRandom(0.5, appearDur, 1);
  29. let bBeat = library.randomInt(0,3);
  30. // console.log('bBeat=',bBeat);
  31. // console.log('appearDur=',appearDur);
  32. if(bBeat!=0)
  33. {
  34. timing = appearDur;
  35. }
  36. // console.log('nameIndex=',nameIndex);
  37. this.scheduleOnce(function () {
  38. switch (nameIndex) {
  39. case 0:
  40. this.top();
  41. console.log('ai hit top mouse');
  42. break;
  43. case 1:
  44. this.left();
  45. console.log('ai hit left mouse');
  46. break;
  47. case 2:
  48. this.right();
  49. console.log('ai hit right mouse');
  50. break;
  51. default:
  52. break;
  53. }
  54. },timing);
  55. }
  56. });