| 
									
										
										
										
											2024-03-26 17:18:28 +08:00
										 |  |  |  | /* | 
					
						
							|  |  |  |  |  * @Author: WoNiu | 
					
						
							|  |  |  |  |  * @Date: 2024-03-26 11:44:58 | 
					
						
							| 
									
										
										
										
											2024-03-27 15:57:22 +08:00
										 |  |  |  |  * @LastEditTime: 2024-03-27 15:49:36 | 
					
						
							| 
									
										
										
										
											2024-03-26 17:18:28 +08:00
										 |  |  |  |  * @LastEditors: WoNiu | 
					
						
							|  |  |  |  |  * @Description: 幸运硬币效果类型 | 
					
						
							|  |  |  |  |  */ | 
					
						
							|  |  |  |  | import { | 
					
						
							|  |  |  |  |   _decorator, | 
					
						
							|  |  |  |  |   Sprite, | 
					
						
							|  |  |  |  |   Director, | 
					
						
							|  |  |  |  |   director, | 
					
						
							|  |  |  |  |   Node, | 
					
						
							|  |  |  |  |   tween, | 
					
						
							|  |  |  |  |   UITransform, | 
					
						
							|  |  |  |  |   v2, | 
					
						
							|  |  |  |  |   Color, | 
					
						
							|  |  |  |  | } from "cc"; | 
					
						
							|  |  |  |  | import { AnimationNode } from "../../GlobalScript/Animation/AnimationNode"; | 
					
						
							|  |  |  |  | import { BaseSprite } from "../../GlobalScript/CommonComponent/BaseSprite"; | 
					
						
							|  |  |  |  | import { NpkImage } from "../../Tool/NPKImage"; | 
					
						
							|  |  |  |  | import { CloseButtonNode } from "../Common/CloseButtonNode"; | 
					
						
							|  |  |  |  | import { GameRootSingleton } from "../GameRootController"; | 
					
						
							|  |  |  |  | const { ccclass, property } = _decorator; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | /** | 
					
						
							|  |  |  |  |  * @description: 幸运硬币效果类型 | 
					
						
							|  |  |  |  |  */ | 
					
						
							|  |  |  |  | export enum LuckyType { | 
					
						
							|  |  |  |  |   // 前进三格
 | 
					
						
							|  |  |  |  |   GoThree = 0, | 
					
						
							|  |  |  |  |   // 移动到月光酒馆
 | 
					
						
							|  |  |  |  |   YeGuangJiuGuan, | 
					
						
							|  |  |  |  |   // 移动到决斗场
 | 
					
						
							|  |  |  |  |   JueDouChang, | 
					
						
							|  |  |  |  |   // 移动到海上列车
 | 
					
						
							|  |  |  |  |   HaiShangLieChe, | 
					
						
							|  |  |  |  |   // 我要双倍,点数x2
 | 
					
						
							|  |  |  |  |   Double, | 
					
						
							|  |  |  |  |   // 这是我的钱,点数减半
 | 
					
						
							|  |  |  |  |   Halve, | 
					
						
							|  |  |  |  |   // 骑士马战 ,点数+2w
 | 
					
						
							|  |  |  |  |   HorseCombat, | 
					
						
							|  |  |  |  |   // 装备修理, 点数-2w
 | 
					
						
							|  |  |  |  |   Servicing, | 
					
						
							|  |  |  |  |   // 收取费用,夺取其他人 2w 点数
 | 
					
						
							|  |  |  |  |   Charge, | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | @ccclass("LuckyCoinsNode") | 
					
						
							|  |  |  |  | export class LuckyCoinsNode extends Node { | 
					
						
							|  |  |  |  |   luckyType: LuckyType; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |   // 幸运硬币的结果
 | 
					
						
							|  |  |  |  |   resultNode: Node; | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-27 15:57:22 +08:00
										 |  |  |  |   aniDoneBack: Function; | 
					
						
							| 
									
										
										
										
											2024-03-26 17:18:28 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-27 15:57:22 +08:00
										 |  |  |  |   constructor(type: LuckyType,aniDone:Function) { | 
					
						
							| 
									
										
										
										
											2024-03-26 17:18:28 +08:00
										 |  |  |  |     super(); | 
					
						
							|  |  |  |  |     this.luckyType = type; | 
					
						
							| 
									
										
										
										
											2024-03-27 15:57:22 +08:00
										 |  |  |  |     this.aniDoneBack = aniDone; | 
					
						
							| 
									
										
										
										
											2024-03-26 17:18:28 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |     this.addComponent(UITransform).anchorPoint = v2(0, 1); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     this.initResultNode(); | 
					
						
							|  |  |  |  |     this.initLuckyAni(); | 
					
						
							|  |  |  |  |     this.delayShowResult(); | 
					
						
							|  |  |  |  |   } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |   initActionButton() { | 
					
						
							|  |  |  |  |     const node = new CloseButtonNode(() => { | 
					
						
							|  |  |  |  |       this.initLuckyAni(); | 
					
						
							|  |  |  |  |     }); | 
					
						
							|  |  |  |  |     this.addChild(node); | 
					
						
							|  |  |  |  |   } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |   initResultNode() { | 
					
						
							|  |  |  |  |     const node = new Node(); | 
					
						
							|  |  |  |  |     this.addChild(node); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     node.setPosition(443, -200); | 
					
						
							|  |  |  |  |     this.resultNode = node; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     node.active = false; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     const bs = node.addComponent(BaseSprite); | 
					
						
							|  |  |  |  |     bs.updateSpriteFrame(NpkImage.luckycoin, this.luckyType); | 
					
						
							|  |  |  |  |   } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |   initLuckyAni() { | 
					
						
							|  |  |  |  |     const lucky = new AnimationNode("ani/luckycoin01.ani", () => { | 
					
						
							|  |  |  |  |       /// 这一帧结束之后调用
 | 
					
						
							|  |  |  |  |       director.once(Director.EVENT_END_FRAME, () => { | 
					
						
							|  |  |  |  |         // 销毁,销毁节点只能在当前帧结束后
 | 
					
						
							|  |  |  |  |         lucky.destroy(); | 
					
						
							|  |  |  |  |       }); | 
					
						
							|  |  |  |  |     }); | 
					
						
							|  |  |  |  |     lucky.setPosition(318.5, -107.5); | 
					
						
							|  |  |  |  |     this.addChild(lucky); | 
					
						
							|  |  |  |  |   } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |   // 延迟显示结果
 | 
					
						
							|  |  |  |  |   delayShowResult() { | 
					
						
							|  |  |  |  |     setTimeout(() => { | 
					
						
							|  |  |  |  |       this.resultNode.active = true; | 
					
						
							|  |  |  |  |       setTimeout(() => { | 
					
						
							|  |  |  |  |         this.resultTweenDestroy(); | 
					
						
							|  |  |  |  |       }, 1000); | 
					
						
							|  |  |  |  |     }, 1600); | 
					
						
							|  |  |  |  |   } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-27 15:57:22 +08:00
										 |  |  |  |   // 透明度缓动消失
 | 
					
						
							| 
									
										
										
										
											2024-03-26 17:18:28 +08:00
										 |  |  |  |   resultTweenDestroy() { | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     let obj = { x: 255 }; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     tween(obj) | 
					
						
							|  |  |  |  |       .to(0.5, { x: 1 }, { onUpdate: () => { | 
					
						
							|  |  |  |  |         const spr = this.resultNode.getComponent(Sprite); | 
					
						
							|  |  |  |  |         spr.color = new Color(255,255,255,obj.x); | 
					
						
							|  |  |  |  |       }, onComplete: () => { | 
					
						
							| 
									
										
										
										
											2024-03-27 15:57:22 +08:00
										 |  |  |  |         /// 缓动完成
 | 
					
						
							| 
									
										
										
										
											2024-03-26 17:18:28 +08:00
										 |  |  |  |         this.resultNode.active = false; | 
					
						
							| 
									
										
										
										
											2024-03-27 15:57:22 +08:00
										 |  |  |  |         // 动画完成回调
 | 
					
						
							|  |  |  |  |         this.aniDoneBack(); | 
					
						
							|  |  |  |  |         // 销毁节点
 | 
					
						
							|  |  |  |  |         director.once(Director.EVENT_END_FRAME, () => { | 
					
						
							|  |  |  |  |           this.destroy(); | 
					
						
							|  |  |  |  |         }); | 
					
						
							| 
									
										
										
										
											2024-03-26 17:18:28 +08:00
										 |  |  |  |       },easing:'linear'}) | 
					
						
							|  |  |  |  |       .start(); | 
					
						
							|  |  |  |  |   } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | } |