| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231 | 
							
- cc.Class({
 
-     extends: cc.Component,
 
-     properties: {
 
-         work: {
 
-             default: null,
 
-             type: cc.SpriteFrame,
 
-             serializable: true,
 
-         },
 
-         sleep: {
 
-             default: null,
 
-             type: cc.SpriteFrame,
 
-             serializable: true,
 
-         },
 
-         dogBasinFood: {
 
-             default: null,
 
-             type: cc.SpriteFrame,
 
-             serializable: true,
 
-         },
 
-         dogBasin: {
 
-             default: null,
 
-             type: cc.SpriteFrame,
 
-             serializable: true,
 
-         },
 
-         DogNode: {
 
-             default: null,
 
-             type: cc.Node,
 
-             serializable: true,
 
-         },
 
-         DogSliderNode: {
 
-             default: null,
 
-             type: cc.Node,
 
-             serializable: true,
 
-         },
 
-         DogSliderLabel: {
 
-             default: null,
 
-             type: cc.Label,
 
-             serializable: true,
 
-         },
 
-         basinNode: {
 
-             default: null,
 
-             type: cc.Node,
 
-             serializable: true,
 
-         },
 
-         basinSliderNode: {
 
-             default: null,
 
-             type: cc.Node,
 
-             serializable: true,
 
-         },
 
-         basinSliderLabel: {
 
-             default: null,
 
-             type: cc.Label,
 
-             serializable: true,
 
-         },
 
-         showButtonLabel: {
 
-             default: null,
 
-             type: cc.Label,
 
-             serializable: true,
 
-         },
 
-         infoBoxNode: {
 
-             default: null,
 
-             type: cc.Node,
 
-             serializable: true,
 
-         },
 
-         //是否是自家的狗
 
-         bSelfDog: {
 
-             default: true,
 
-             visible: false
 
-         },
 
-         buyDogFoodPrefab: {
 
-             default: null,
 
-             type: cc.Prefab,
 
-             serializable: true,
 
-         }
 
-     },
 
-     // LIFE-CYCLE CALLBACKS:
 
-     onLoad() {
 
-         this.onGetSelfList();
 
-     },
 
-     start() {
 
-         this.basinNode.on(cc.Node.EventType.TOUCH_START, () => {
 
-             console.log("点击添加狗粮,this.bSelfDog =", this.bSelfDog);
 
-             if (!this.bSelfDog) return;
 
-             //生成预制件
 
-             let _foodPanel = cc.instantiate(this.buyDogFoodPrefab);
 
-             let parent = cc.find('Canvas/UICamera/DAPPContainer');
 
-             _foodPanel.parent = parent;
 
-             _foodPanel.setPosition(0, 0);
 
-             //把操作对象传入
 
-             let _buyDogInfoScript = _foodPanel.getComponent("BuyDogInfo");
 
-             _buyDogInfoScript.parentNode = this;
 
-             _buyDogInfoScript.onLoadFoodList();
 
-         })
 
-     },
 
-     /**
 
-      * 直接更新狗的状态
 
-      * @param {狗对象}} dog 
 
-      */
 
-     onSetSelfDogState(dog) {
 
-         this.bSelfDog = true;
 
-         GlobalD.Dog = dog;
 
-         this.infoBoxNode.active = true;
 
-         this.DogNode.active = true;
 
-         this._updateDogState(GlobalD.Dog);
 
-     },
 
-     onGetSelfList() {
 
-         // let ManageUI = cc.find("GameNode/ManageUI").getComponent("ManageUI");
 
-         this.bSelfDog = true;
 
-         //获取狗的信息
 
-         this._updateList({});
 
-     },
 
-     //获取其他用户狗的信息
 
-     onGetOtherUserList() {
 
-         this.bSelfDog = false;
 
-         this._updateList({ otherUserId: GlobalD.OtherUserInfo.userId });
 
-     },
 
-     _updateList(data) {
 
-         this.infoBoxNode.active = false;
 
-         this._resetDogState();
 
-         GlobalD.GameData.onGetEquipmentListState(data, (value) => {
 
-             // console.log(value);
 
-             let _list = value.data;
 
-             for (let i = 0; i < _list.length; i++) {
 
-                 if (0 === _list[i].otherType) {
 
-                     GlobalD.Dog = _list[i];
 
-                     //存在狗
 
-                     if (this.bSelfDog) {
 
-                         this.infoBoxNode.active = true;
 
-                         this.DogNode.active = true;
 
-                     } else {
 
-                         this.DogNode.active = 1 === GlobalD.Dog.isShow ? true : false;
 
-                     }
 
-                     if (this.DogNode.active) {
 
-                         this._updateDogState(GlobalD.Dog);
 
-                     }
 
-                 } else if (1 === _list[i].otherType) {
 
-                     GlobalD.Stick = _list[i];
 
-                     if (GlobalD.Stick.remainingDay > 0)
 
-                         GlobalD.game._ManageUIScript.onSettingStickAlpha(255);
 
-                 }
 
-             }
 
-         })
 
-     },
 
-     _resetDogState() {
 
-         GlobalD.Dog = null;
 
-         GlobalD.Stick = null;
 
-         this.DogNode.active = false;
 
-         this.basinNode.getComponent(cc.Sprite).spriteFrame = this.dogBasin;
 
-         GlobalD.game._ManageUIScript.onSettingDogAlpha(125);
 
-         GlobalD.game._ManageUIScript.onSettingStickAlpha(125);
 
-     },
 
-     //切换小狗状态
 
-     onSwitchDogActive() {
 
-         console.log(GlobalD.Dog);
 
-         GlobalD.GameData.onSetDogShowState({ isShow: 1 === GlobalD.Dog.isShow ? 0 : 1 }, (value) => {
 
-             console.log(value.data);
 
-             GlobalD.Dog = value.data.dog;
 
-             //修改按钮提示文字
 
-             this.showButtonLabel.string = 1 === GlobalD.Dog.isShow ? "隐藏小狗" : "显示小狗"
 
-             this.DogNode.opacity = 1 === GlobalD.Dog.isShow ? 255 : 125;
 
-         })
 
-     },
 
-     _updateDogState(dogValue) {
 
-         //修改按钮提示文字
 
-         this.showButtonLabel.string = 1 === dogValue.isShow ? "隐藏小狗" : "显示小狗";
 
-         //修改半显示状态
 
-         this.DogNode.opacity = 1 === dogValue.isShow ? 255 : 125;
 
-         this.DogSliderLabel.string = "剩" + dogValue.remainingDay + "天";
 
-         this.basinSliderLabel.string = "剩余" + dogValue.remainingConsumption + "G";
 
-         //狗的剩余天数进度
 
-         let _dogSliderNodeScript = this.DogSliderNode.getComponent("slider_progress");
 
-         let _dogSliderProccess = 0 === dogValue.totalDay ? 0 : dogValue.remainingDay / dogValue.totalDay;
 
-         _dogSliderNodeScript.onSetProcgress(_dogSliderProccess);
 
-         //狗粮的剩余进度
 
-         let _basinSliderNodeScript = this.basinSliderNode.getComponent("slider_progress");
 
-         let _basinSliderProccess = 0 === dogValue.totalConsumption ? 0 : dogValue.remainingConsumption / dogValue.totalConsumption;
 
-         _basinSliderNodeScript.onSetProcgress(_basinSliderProccess);
 
-         if (dogValue.remainingDay > 0 && dogValue.remainingConsumption > 0) {
 
-             this.basinNode.getComponent(cc.Sprite).spriteFrame = this.dogBasinFood;
 
-             this.DogNode.getComponent(cc.Sprite).spriteFrame = this.work;
 
-             GlobalD.game._ManageUIScript.onSettingDogAlpha(255);
 
-         } else {
 
-             //不够狗粮,睡觉
 
-             this.basinNode.getComponent(cc.Sprite).spriteFrame = this.dogBasin;
 
-             this.DogNode.getComponent(cc.Sprite).spriteFrame = this.sleep;
 
-             GlobalD.game._ManageUIScript.onSettingDogAlpha(125);
 
-         }
 
-     },
 
- });
 
 
  |