123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340 |
- var Global = require("Global");
- var GameProtocol = require("RomanGameProtocol");
- 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/Roman/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,
- goldLabel: cc.Label,
- kuangAni: sp.Skeleton,
- _bBig: false,
- _totalCount: 1,
- config: null,
- aniFlag: false
- },
- // LIFE-CYCLE CALLBACKS:
- // onLoad () {
-
- // },
- setValue (_val, spineData, _sunV) {
- this._bBig = false//_val == GameProtocol.MAN_ICON || _val == GameProtocol.WOMAN_ICON;
- this.normalBG.active = true;//!this._bBig;
- // this.spNode.active = this._bBig;
- // this.spAni.skeletonData = spineData;
- this.aniNode.active = false;
- this.goldLabel.node.active = false;
- this.bSunCoin = _val == GameProtocol.SUN_ICON;
- if(this.bSunCoin) {
- this.setGoldLabel(_sunV);
- }
- if(_val>=0 && _val<=4){
- this.aniFlag = true;
- }else{
- this.aniFlag = false;
- }
- this._super(_val, spineData, _val == GameProtocol.SPECIAL_ICON);
- },
- getValue() {
- return this._value;
- },
- setGoldLabel(label) {
- // this.bSunCoin = true;
- this.goldLabel.node.active = true;
- this.goldLabel.string = Global.formatString2Score(label);
- },
- getGoldLabel() {
- return this.goldLabel.string;
- },
- playGoldCoinAni() {
- if(!this.bSunCoin) return;
- this.normalAni.setAnimation(0, "a4", false);
- this.normalAni.addAnimation(0, "a4", false);
- this.normalAni.addAnimation(0, "a4", false);
- this.normalAni.addAnimation(0, "a4", false);
- this.normalAni.addAnimation(0, "a1", true);
- this.goldLabel.node.stopAllActions();
- cc.tween(this.goldLabel.node)
- .sequence(
- cc.tween().to(0.3, {scaleX: 0, x:10}),
- cc.tween().to(0.6, {x:-10}),
- cc.tween().to(0.3, {scaleX: 1, x:0})
- )
- .repeat(4)
- // .to(0.3, {scaleX: 0, x:10})
- // .to(0.6, {x:-10})
- // .to(0.3, {scaleX: 1, x:0})
- .start()
- },
- playGetCoinAni() {
- if(!this.bSunCoin) return;
- this.normalAni.setAnimation(0, "a3", false);
- this.normalAni.addAnimation(0, "a1", true);
- cc.tween(this.goldLabel.node)
- .to(0.2, {scale: 1.5})
- .to(0.2, {scale: 1})
- .start()
- },
- showInSunGame() {
- this.normalBG.stopAllActions();
- this.normalBG.scale = 1;
- this.normalBG.active = true;
- // this.spNode.active = false;
- this.aniNode.active = false;
- this.normalAni.setAnimation(0, "a1", true);
- if(!this.bSunCoin) return;
- this.aniNode.active = true;
- this.kuangAni.setAnimation(0, "a2", true);
- },
- showGoldLight() {
- this.normalBG.stopAllActions();
- this.normalBG.scale = 1;
- this.normalBG.active = true;
- // this.spNode.active = false;
- this.aniNode.active = false;
- this.normalAni.setAnimation(0, "a2", false);
- this.normalAni.addAnimation(0, "a1", true);
- },
- setRowCount(_count) {
- this.node.active = true;
- return;
- _count = 1;
- 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);
- this.node.getComponent(cc.Animation).setCurrentTime(0);
- this.node.getComponent(cc.Animation).stop();
- 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._totalCount = 1;
- this.config = itemConfig[this._totalCount];
- 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);
- if(this.aniFlag)
- this.node.getComponent(cc.Animation).play();
- // 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) {},
- });
|