123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255 |
- var Global = require("Global");
- var GameProtocol = require("FruitGameProtocol");
- var LBItem = require("LBItem");
- const itemConfig = {
- "1": { //单个
- //框
- kw: 200,
- kh: 190,
- kx: -2,
- //遮罩
- mw: 168,
- mh: 142,
- mx: 14,
- my: -22,
- sx: 86,
- sy: -216,
- //动画
- bw: 168,
- bh: 182,
- bx: 14,
- by: 16,
- ax: 111,
- ay: -162
- },
- "2": { //两个
- //框
- kw: 200,
- kh: 339,
- kx: -2,
- //遮罩
- mw: 168,
- mh: 288,
- mx: 14,
- my: -22,
- sx: 86,
- sy: -216,
- //动画
- bw: 168,
- bh: 288,
- bx: 14,
- by: -22,
- ax: 111,
- ay: -169
- },
- "3": { //三个
- //框
- kw: 200,
- kh: 490,
- kx: -2,
- //遮罩
- mw: 168,
- mh: 440,
- mx: 14,
- my: -22,
- sx: 86,
- sy: -216,
- //动画
- bw: 168,
- bh: 440,
- bx: 14,
- by: -22,
- ax: 111,
- ay: -169
- },
- "6": { //六个
- //框
- kw: 423,
- kh: 490,
- kx: -7,
- //遮罩
- mw: 379,
- mh: 440,
- mx: 14,
- my: -22,
- sx: 200,
- sy: -216,
- //动画
- bw: 379,
- bh: 440,
- bx: 14,
- by: -22,
- ax: 200,
- ay: -169
- }
- }
- cc.Class({
- extends: LBItem,
- editor: {
- menu: 'Game/Fruit/Item'
- },
- properties: {
- //特殊节点
- spNode: cc.Node,
- spAni: sp.Skeleton,
- kuang: cc.Node,
- mask: cc.Node,
- maskB: cc.Node,
- maskH: cc.Node,
- bAni: sp.Skeleton,
- hAni: sp.Skeleton,
- _bBig: false,
- _totalCount: 0,
- config: null,
- },
- // LIFE-CYCLE CALLBACKS:
- // onLoad () {
-
- // },
- setValue (_val, spineData, _bSpe) {
- this._bBig = _val == GameProtocol.MAN_ICON || _val == GameProtocol.WOMAN_ICON;
- this.normalBG.active = !this._bBig;
- this.spNode.active = this._bBig;
- this.spAni.skeletonData = spineData;
- this._super(_val, spineData, _bSpe);
- },
- setRowCount(_count) {
- this._totalCount = _count;
- this.config = null;
- this.node.active = _count >= 0;
- this.config = itemConfig[_count];
- this.setBigAniConfig();
- if(_count > 1) {
- // this.spAni.clearTracks();
- this.spAni.setAnimation(0, "a2", true);
- let name = "a2";
- if(this._value == GameProtocol.WOMAN_ICON) {
- name = "b2";
- }
- // this.bAni.clearTracks();
- this.bAni.setAnimation(0, name, true);
- // this.hAni.clearTracks();
- this.hAni.setAnimation(0, "c1", true);
- }
- },
- setBigAniConfig() {
- if(!this.config) return;
- this.spAni.node.x = this.config.sx;
- this.spAni.node.y = this.config.sy;
- if(this._value == GameProtocol.WOMAN_ICON) {
- this.spAni.node.x = this.config.ax;
- this.spAni.node.y = this.config.ay;
- }
- //框
- this.kuang.width = this.config.kw;
- this.kuang.height = this.config.kh;
- this.kuang.x = this.config.kx;
- //任务动画遮罩
- this.mask.width = this.config.bw;
- this.mask.height = this.config.bh;
- this.mask.x = this.config.bx;
- this.mask.y = this.config.by;
- //背景遮罩
- this.maskB.width = this.config.mw;
- this.maskB.height = this.config.mh;
- this.maskB.x = this.config.mx;
- this.maskB.y = this.config.my;
- //花瓣遮罩
- this.maskH.width = this.config.mw;
- this.maskH.height = this.config.mh;
- this.maskH.x = this.config.mx;
- this.maskH.y = this.config.my;
- this.bAni.node.x = this.config.sx;
- this.bAni.node.y = this.config.sy;
- this.hAni.node.x = this.config.sx;
- this.hAni.node.y = this.config.sy;
- // this.spAni.clearTracks();
- // this.spAni.setAnimation(0, "a2", true);
- },
- showAppearAction() {
- if(this._totalCount < 2) {
- return;
- }
- this.spNode.stopAllActions();
- this.spNode.scale = 0;
- cc.tween(this.spNode)
- .to(0.3, {scale: 1})
- .start()
- },
- resetShow() {
- if(this._totalCount > 1 || this._totalCount < 0) {
- return;
- }
- this.showNormal();
- },
- showNormal() {
- this.normalBG.stopAllActions();
- this.normalBG.scale = 1;
- this.aniNode.active = false;
- // this.normalAni.clearTracks();
- this.normalAni.setAnimation(0, "a1", true);
- if(this._bBig) {
- this.showBigSingle();
- }
- },
- showBigSingle() {
- //动画
- // this.spAni.clearTracks();
- this.spAni.setAnimation(0, "a1", true);
- let name = "a1";
- if(this._value == GameProtocol.WOMAN_ICON) {
- name = "b1";
- }
- // this.bAni.clearTracks();
- this.bAni.setAnimation(0, name, true);
- // this.hAni.clearTracks();
- this.hAni.setAnimation(0, "c1", true);
- this.config = itemConfig[1];
- this.setBigAniConfig();
- },
- showLightAni() {
- if(this._totalCount > 1) {
- return;
- }
- if(this._lineCount <= 0) {
- this.showNormal();
- return;
- }
- this.aniNode.active = false;
- this.normalBG.stopAllActions();
- // this.normalAni.clearTracks();
- this.normalAni.setAnimation(0, "a2", true);
- // this.spAni.clearTracks();
- this.spAni.setAnimation(0, "a2", true);
- },
- showSpecialAni() {
- if(!this._bSpecial) {
- // this.showNormal();
- return;
- }
- this.normalBG.stopAllActions();
- // this.normalAni.clearTracks();
- this.normalAni.setAnimation(0, "a2", true);
- // this.spAni.clearTracks();
- this.spAni.setAnimation(0, "a2", true);
- },
- // update (dt) {},
- });
|