ending.js 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458
  1. // Learn cc.Class:
  2. // - https://docs.cocos.com/creator/manual/en/scripting/class.html
  3. // Learn Attribute:
  4. // - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
  5. // Learn life-cycle callbacks:
  6. // - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
  7. cc.Class({
  8. extends: cc.Component,
  9. properties: {
  10. personFugui:cc.Node,
  11. personUncle:cc.Node,
  12. personOut:cc.Node,
  13. price:cc.Node,
  14. person_hui:cc.Node,
  15. hand:cc.Node,
  16. content:cc.Node,
  17. chatOne:cc.Label,
  18. mainCallPrice:cc.Node,
  19. mainCallPriceTwo:cc.Node,
  20. contentTable:"50000,1次",
  21. clickYes:true,
  22. count:1,
  23. downLoad:cc.Node,
  24. kill:cc.Node,
  25. buttonAudio: {
  26. default: null,
  27. type: cc.AudioClip
  28. },
  29. outAudio:{
  30. default: null,
  31. type: cc.AudioClip
  32. },
  33. outFiveAudio:{
  34. default: null,
  35. type: cc.AudioClip
  36. },
  37. outAudioFive:{
  38. default: null,
  39. type: cc.AudioClip
  40. },
  41. outAudioSeven:{
  42. default: null,
  43. type: cc.AudioClip
  44. },
  45. audioSeven:{
  46. default: null,
  47. type: cc.AudioClip
  48. },
  49. time: cc.Label,
  50. countdown: 3,
  51. countdown7_1:{
  52. default: null,
  53. type: cc.AudioClip
  54. },
  55. countdown7_2:{
  56. default: null,
  57. type: cc.AudioClip
  58. },
  59. countdown7_3:{
  60. default: null,
  61. type: cc.AudioClip
  62. },
  63. countdown7_success:{
  64. default: null,
  65. type: cc.AudioClip
  66. },
  67. audioTen:{
  68. default: null,
  69. type: cc.AudioClip
  70. },
  71. outAudioTen:{
  72. default: null,
  73. type: cc.AudioClip
  74. },
  75. audio15:{
  76. default: null,
  77. type: cc.AudioClip
  78. },
  79. countdown10_1:{
  80. default: null,
  81. type: cc.AudioClip
  82. },
  83. countdown10_2:{
  84. default: null,
  85. type: cc.AudioClip
  86. },
  87. countdown10_3:{
  88. default: null,
  89. type: cc.AudioClip
  90. },
  91. countdown10_success:{
  92. default: null,
  93. type: cc.AudioClip
  94. },
  95. screamAudio:{
  96. default: null,
  97. type: cc.AudioClip
  98. },
  99. door:cc.Node,
  100. carHide:cc.Node,
  101. egg:cc.Node,
  102. toSuccessHand:cc.Node,
  103. door_1:cc.Node,
  104. btnGiveUp:cc.Node,
  105. btnAddPrice:cc.Node
  106. },
  107. // LIFE-CYCLE CALLBACKS:
  108. // onLoad () {},
  109. playMusic(){
  110. let audioId = cc.audioEngine.playEffect(this.buttonAudio, false);
  111. cc.audioEngine.setVolume(audioId, 0.5);
  112. },
  113. startClick(){
  114. this.playMusic()
  115. cc.director.loadScene("end_fail");
  116. },
  117. toSuccess(){
  118. if( !this.btnAddPrice.active&&!this.btnGiveUp.active&&this.count>1 ){
  119. this.playMusic()
  120. cc.director.loadScene("end_success");
  121. }
  122. },
  123. onDownLoad(e){
  124. // $('#btn').on('touchstart', function (e) {
  125. window.playableSDK.sendEvent('clickContent', {
  126. section: 'section2',
  127. area: 'area3'
  128. });
  129. window.playableSDK.openAppStore()
  130. // })
  131. },
  132. addPrice(){
  133. this.playMusic()
  134. if(this.count<=1&&this.clickYes&&!this.mainCallPrice.active&&!this.mainCallPriceTwo.active&&this.personOut.active){
  135. this.personFugui.setScale(0.6)
  136. this.count ++
  137. this.unscheduleAllCallbacks()
  138. this.price.active= true
  139. this.content.active = false
  140. this.hand.destroy();
  141. this.clickYes = false
  142. let sprite = this.node.getChildByName('five').getComponent(cc.Sprite)
  143. let spriteElse = this.node.getChildByName('five_narrator').getComponent(cc.Sprite)
  144. if(this.count == 1){
  145. let audioId = cc.audioEngine.playEffect(this.outAudioFive, false);
  146. cc.audioEngine.setVolume(audioId, 1);
  147. }
  148. if(this.count==2){
  149. sprite.spriteFrame = new cc.SpriteFrame(cc.url.raw('resources/ten.png'));
  150. spriteElse.spriteFrame = new cc.SpriteFrame(cc.url.raw('resources/ten_narrator.png'));
  151. let audioId = cc.audioEngine.playEffect(this.audioTen, false);
  152. cc.audioEngine.setVolume(audioId, 1);
  153. }
  154. this.scheduleOnce(function () {
  155. this.price.active= false
  156. this.mainCallPrice.active = true
  157. this.priceShow()
  158. }, 1.5);
  159. }
  160. },
  161. start () {
  162. console.log(this.personFugui)
  163. // this.chatOne.string = this.contentTable
  164. this.time.string = 3; // 场景文本框为 显示5
  165. this.countdown = 3;
  166. if (this.countdown >= 0) {
  167. this.schedule(function () { // 计时器将每隔 1s 执行一次。
  168. this.DoSomething();
  169. if(this.countdown==0){
  170. this.time.active = false
  171. }
  172. }, 1);
  173. }
  174. },
  175. DoSomething() { // 倒计时算法
  176. if (this.countdown >= 1) {
  177. this.countdown = this.countdown - 1;
  178. this.time.string = this.countdown;
  179. //场景中文本框显示
  180. cc.log("countdown=" + this.countdown);
  181. }
  182. },
  183. priceShow(){
  184. let spriteElse = this.node.getChildByName('five_narrator').getComponent(cc.Sprite)
  185. let spriteTwo = this.node.getChildByName('7').getComponent(cc.Sprite)
  186. if(this.count == 1){
  187. this.personFugui.setScale(0.5)
  188. let audioId = cc.audioEngine.playEffect(this.outFiveAudio, false);
  189. cc.audioEngine.setVolume(audioId, 1);
  190. this.scheduleOnce(function () { // 计时器将每隔 1s 执行一次。
  191. this.mainCallPrice.active = false
  192. this.clickYes = true
  193. this.mainCallPriceTwo.active = true
  194. this.personUncle.setScale(0.6)
  195. let audioId = cc.audioEngine.playEffect(this.audioSeven, false);
  196. cc.audioEngine.setVolume(audioId, 1);
  197. var n=1
  198. this.scheduleOnce(function(){
  199. spriteElse.spriteFrame = new cc.SpriteFrame(cc.url.raw('resources/7_narrator.png'));
  200. this.mainCallPrice.active = true
  201. this.mainCallPriceTwo.active = false
  202. let audioId = cc.audioEngine.playEffect(this.outAudioSeven, false);
  203. this.scheduleOnce(function(){
  204. this.mainCallPrice.active = false
  205. this.personUncle.setScale(0.5)
  206. cc.audioEngine.setVolume(audioId, 1);
  207. this.schedule(function(){
  208. console.log("n:",n)
  209. this.content.active = true
  210. let countdown
  211. if(n===5){
  212. this.content.active = false
  213. this.unscheduleAllCallbacks()
  214. this.startClick()
  215. return
  216. }else if(n===4){
  217. this.chatOne.string = "70000,成交"
  218. countdown = cc.audioEngine.playEffect(this.countdown7_success, false);
  219. cc.audioEngine.setVolume(countdown, 1);
  220. }else if(n===3){
  221. this.chatOne.string = "70000,"+n+'次'
  222. countdown = cc.audioEngine.playEffect(this.countdown7_3, false);
  223. cc.audioEngine.setVolume(countdown, 1);
  224. }else if(n===2){
  225. this.chatOne.string = "70000,"+n+'次'
  226. countdown = cc.audioEngine.playEffect(this.countdown7_2, false);
  227. cc.audioEngine.setVolume(countdown, 1);
  228. }else if(n===1){
  229. this.chatOne.string = "70000,"+n+'次'
  230. countdown = cc.audioEngine.playEffect(this.countdown7_1, false);
  231. cc.audioEngine.setVolume(countdown, 1);
  232. }
  233. n++
  234. },1)
  235. },1.5)
  236. },2)
  237. }, 1.5);
  238. }else if(this.count == 2){
  239. this.personFugui.setScale(0.5)
  240. spriteElse.spriteFrame = new cc.SpriteFrame(cc.url.raw('resources/ten_narrator.png'));
  241. spriteTwo.spriteFrame = new cc.SpriteFrame(cc.url.raw('resources/15.png'));
  242. let audioId = cc.audioEngine.playEffect(this.outAudioTen, false);
  243. cc.audioEngine.setVolume(audioId, 1);
  244. this.scheduleOnce(function () {
  245. this.personOut.setScale(0.6) // 计时器将每隔 1s 执行一次。
  246. let audio15 = cc.audioEngine.playEffect(this.audio15, false);
  247. cc.audioEngine.setVolume(audio15, 1);
  248. this.mainCallPrice.active = false
  249. this.clickYes = true
  250. this.mainCallPriceTwo.active = true
  251. var n=1
  252. // this.scheduleOnce(function(){
  253. // this.mainCallPrice.active = true
  254. this.scheduleOnce(function(){
  255. this.personOut.setScale(0.5)
  256. this.mainCallPrice.active = false
  257. this.mainCallPriceTwo.active = false
  258. this.kill.active = true
  259. // this.schedule(function(){
  260. // console.log("n:",n)
  261. // this.content.active = true
  262. // this.chatOne.string = "150000,"+n+'次'
  263. // if(n===4){
  264. // this.content.active = false
  265. // this.unscheduleAllCallbacks()
  266. // this.startClick()
  267. // return
  268. // }
  269. // n++
  270. // },1)
  271. },2)
  272. // },1)
  273. }, 2);
  274. }
  275. },
  276. kicking(){
  277. this.playMusic()
  278. this.personOut.active = false
  279. this.kill.active = false
  280. this.mainCallPrice.active = false
  281. this.mainCallPriceTwo.active = false
  282. this.scheduleOnce(function(){
  283. let audioId = cc.audioEngine.playEffect(this.outAudio, false);
  284. cc.audioEngine.setVolume(audioId, 0.5);
  285. this.scheduleOnce(function(){
  286. var scream = cc.audioEngine.playEffect(this.screamAudio, false);
  287. cc.audioEngine.setVolume(scream, 1);
  288. var anim = this.person_hui.getComponent(cc.Animation);
  289. console.log(anim)
  290. anim.play("outPerson");
  291. var n = 1
  292. this.schedule(function(){
  293. this.content.active = true
  294. // this.chatOne.string = "100000,"+n+'次'
  295. let countdown
  296. if(n===5){
  297. this.carHide.active = false
  298. this.content.active = false
  299. this.carHide.active = false
  300. this.btnGiveUp.active =false
  301. this.btnAddPrice.active = false
  302. let two = this.door.getComponent(cc.Animation);
  303. two.play("hideDoor")
  304. this.toSuccessHand.active = true
  305. this.unscheduleAllCallbacks()
  306. // this.unscheduleAllCallbacks()
  307. // let two = this.door.getComponent(cc.Animation);
  308. // two.play("hideDoor");
  309. // this.content.active = false
  310. // this.toSuccess()
  311. // this.scheduleOnce(function(){
  312. // this.toSuccess()
  313. //
  314. // },2)
  315. return
  316. }else if(n===4){
  317. this.chatOne.string = "100000,成交"
  318. countdown = cc.audioEngine.playEffect(this.countdown10_success, false);
  319. cc.audioEngine.setVolume(countdown, 1);
  320. }else if(n===3){
  321. this.chatOne.string = "100000,"+n+'次'
  322. countdown = cc.audioEngine.playEffect(this.countdown10_3, false);
  323. cc.audioEngine.setVolume(countdown, 1);
  324. }else if(n===2){
  325. this.chatOne.string = "100000,"+n+'次'
  326. countdown = cc.audioEngine.playEffect(this.countdown10_2, false);
  327. cc.audioEngine.setVolume(countdown, 1);
  328. }else if(n===1){
  329. this.chatOne.string = "100000,"+n+'次'
  330. countdown = cc.audioEngine.playEffect(this.countdown10_1, false);
  331. cc.audioEngine.setVolume(countdown, 1);
  332. }
  333. n++
  334. },1)
  335. },.5)
  336. },.5)
  337. // let spriteOut = this.node.getChildByName('person_out').getComponent(cc.Sprite)
  338. // spriteOut.spriteFrame = new cc.SpriteFrame(cc.url.raw('resources/person_out.png'));
  339. },
  340. changeMos(){
  341. this.playMusic()
  342. // this.scheduleOnce(function(){
  343. // let audioId = cc.audioEngine.playEffect(this.outAudio, false);
  344. // cc.audioEngine.setVolume(audioId, 0.5);
  345. // },.5)
  346. // this.personOut.active = false
  347. this.kill.active = false
  348. this.door_1.active = true
  349. let spriteTwo = this.node.getChildByName('7').getComponent(cc.Sprite)
  350. spriteTwo.spriteFrame = new cc.SpriteFrame(cc.url.raw('resources/out.png'));
  351. this.scheduleOnce(function(){
  352. this.mainCallPriceTwo.active = true
  353. },1)
  354. this.scheduleOnce(function(){
  355. this.mainCallPriceTwo.active = false
  356. var n = 1
  357. if(!this.mainCallPriceTwo.active){
  358. this.schedule(function(){
  359. console.log("n:",n)
  360. this.content.active = true
  361. this.chatOne.string = "100000,"+n+'次'
  362. let countdown
  363. if(n===5){
  364. this.content.active = false
  365. this.carHide.active = false
  366. this.door_1.active = false
  367. this.btnGiveUp.active =false
  368. this.btnAddPrice.active = false
  369. let two = this.door.getComponent(cc.Animation);
  370. two.play("hideDoor")
  371. this.toSuccessHand.active = true
  372. this.unscheduleAllCallbacks()
  373. // this.scheduleOnce(function(){
  374. // this.toSuccess()
  375. // this.unscheduleAllCallbacks()
  376. // },2)
  377. return
  378. }else if(n===4){
  379. this.chatOne.string = "100000,成交"
  380. countdown = cc.audioEngine.playEffect(this.countdown10_success, false);
  381. cc.audioEngine.setVolume(countdown, 1);
  382. }else if(n===3){
  383. this.chatOne.string = "100000,"+n+'次'
  384. countdown = cc.audioEngine.playEffect(this.countdown10_3, false);
  385. cc.audioEngine.setVolume(countdown, 1);
  386. }else if(n===2){
  387. this.chatOne.string = "100000,"+n+'次'
  388. countdown = cc.audioEngine.playEffect(this.countdown10_2, false);
  389. cc.audioEngine.setVolume(countdown, 1);
  390. }else if(n===1){
  391. this.chatOne.string = "100000,"+n+'次'
  392. countdown = cc.audioEngine.playEffect(this.countdown10_1, false);
  393. cc.audioEngine.setVolume(countdown, 1);
  394. }
  395. n++
  396. },1)
  397. }
  398. },2)
  399. // let anim = this.person_hui.getComponent(cc.Animation);
  400. // console.log(anim)
  401. // anim.play("outPerson");
  402. // this.mosaic.active=true
  403. // this.mainCallPrice.active = false
  404. // this.mainCallPriceTwo.active = false
  405. },
  406. showEgg(){
  407. let two = this.egg.getComponent(cc.Animation);
  408. two.play("smallToBig");
  409. }
  410. // update (dt) {
  411. // },
  412. });