| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- import { _decorator, Component, Node, Animation, find, EventHandler } from 'cc';
- import { Sound } from '../core/sound/Sound';
- import { ConfigData } from '../Data/ConfigData';
- import { g } from '../Data/g';
- const { ccclass, property } = _decorator;
- @ccclass('openPrizeAnimEven')
- export class openPrizeAnimEven extends Component {
- // @property({ tooltip: "跑马灯动画结束回调", type: EventHandler })
- // public animationEndFun: EventHandler;
- @property({ tooltip: "闪烁动画结束回调", type: EventHandler })
- public animation0EndFun: EventHandler;
- @property({ tooltip: "转盘抽奖音效控制器", type: Sound }) public turntableSound: Sound;
- private tempAnimation: Animation;
- private upSpeed = 0;//跑马灯圈数
- private temp_Number = 0;
- private prizeNum = 0;//获奖奖品序号(1~8)
- public prizeArryConfig = [];//奖品展示排序配置
- start() {
- this.tempAnimation = this.node.getComponent(Animation);
- this.prizeArryConfig = ConfigData.configMap.get("turntable").showOrder;
- }
- //设置中奖序号
- public setPrizeNum(prizeNum: number) {
- this.prizeNum = this.prizeArryConfig.indexOf(prizeNum) + 1;
- }
- public test(speed: number) {
- this.turntableSound.play();
- if (this.tempAnimation.getState('openPrize').speed >= 3 || this.upSpeed >= 5) {
- this.upSpeed += speed == 3 ? 1 : 0;
- if (this.upSpeed >= 5) {
- let temp = this.prizeNum < 6 ? (this.prizeNum + 8) : this.prizeNum;
- this.temp_Number = this.temp_Number == 0 ? temp + 1 : this.temp_Number;
- this.temp_Number--;
- if (this.temp_Number < 6) {
- this.tempAnimation.getState('openPrize').speed = this.tempAnimation.getState('openPrize').speed - ((this.temp_Number - 1) * 0.2 + 0.1);
- if (this.temp_Number == 0) {
- // this.animationEndFun.emit([]);
- this.tempAnimation.stop();
- this.tempAnimation.play('openPrize0')
- this.upSpeed = 0;
- }
- }
- }
- } else {
- this.tempAnimation.getState('openPrize').speed = speed;
- }
- }
- public animation0Times = 8;
- public animation0End() {
- this.turntableSound.play();
- this.animation0Times--;
- if (this.animation0Times <= 0) {
- this.tempAnimation.stop();
- this.animation0Times = 8;
- this.animation0EndFun.emit([]);
- }
- }
- }
|