| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- import { instantiate, Widget } from 'cc';
- import { _decorator, Component, Node, Animation, Prefab } from 'cc';
- import { ResourcesUtils } from '../core/resourceManager/ResourcesUtils';
- import { OpenWindow } from '../core/ui/window/OpenWindow';
- import { ConfigData } from '../Data/ConfigData';
- import { g } from '../Data/g';
- import { RotatingLightAnim } from '../SpecialEffects/RotatingLightAnim';
- const { ccclass, property } = _decorator;
- @ccclass('FlyTreasureChest')
- export class FlyTreasureChest extends Component {
- @property({ tooltip: "宝箱飞行动作节点", type: Node })
- public flyBox: Node;
- @property({ tooltip: "光效预制体根目录" })
- public lightEfficiency = '';
- @property({ tooltip: "光效父节点", type: Node })
- public lightEfficiencyBox: Node;
- // @property({ tooltip: "打开新窗口界面按钮", type: Node })
- // public toGetGoldWin: Node;
- public temp: Animation;
- start() {
- }
- public setData() {
- // this.temp.play('boxMove');
- this.node.getComponent(Widget).left = -200;
- let moveAnim: Animation = this.node.getComponent(Animation);
- moveAnim.play('boxMove');
- let flyAnim: Animation = this.flyBox.getComponent(Animation);
- flyAnim.play();
- this.setLight();
- }
- /**
- * 设置光效
- */
- public async setLight() {
- let prefabsData = await ResourcesUtils.load<Prefab>(this.lightEfficiency, null, this.node);
- var lightNode = instantiate(prefabsData);
- lightNode.parent = this.lightEfficiencyBox;
- let rotatingLight = lightNode.getComponent(RotatingLightAnim);
- rotatingLight.set_Data(300, 300, 0.5, false);
- }
- /**
- * 动画结束回调
- */
- public test() {
- this.node.removeFromParent();
- this.destroy();
- }
- /**
- * 点击宝箱回调
- */
- public openNewWindow() {
- let config = ConfigData.configMap.get("flyBox")
- let type = g.userData.lv == 0 ? 1 : g.userData.lv;
- this.getComponent(OpenWindow).open([0, config.prizeList[type - 1].prize, config.videoMultiple]);
- this.test();
- }
- }
|