Commit 8bdc7915 authored by liujiaxin's avatar liujiaxin

feat: pets

parent 34659f9a
...@@ -41,7 +41,6 @@ export default class ChangeItemAnimation extends cc.Component { ...@@ -41,7 +41,6 @@ export default class ChangeItemAnimation extends cc.Component {
this.armatureDisplay.playAnimation("newAnimation", 1); this.armatureDisplay.playAnimation("newAnimation", 1);
let {x, y, width, height} = this.node; let {x, y, width, height} = this.node;
if (data.rect) { if (data.rect) {
debugger
x = data.rect.x; x = data.rect.x;
y = data.rect.y; y = data.rect.y;
width = data.rect.width; width = data.rect.width;
......
...@@ -1605,7 +1605,7 @@ ...@@ -1605,7 +1605,7 @@
"__id__": 30 "__id__": 30
} }
], ],
"_active": true, "_active": false,
"_components": [ "_components": [
{ {
"__id__": 33 "__id__": 33
...@@ -1890,7 +1890,7 @@ ...@@ -1890,7 +1890,7 @@
"__id__": 39 "__id__": 39
} }
], ],
"_active": true, "_active": false,
"_components": [ "_components": [
{ {
"__id__": 42 "__id__": 42
...@@ -2382,7 +2382,7 @@ ...@@ -2382,7 +2382,7 @@
"__id__": 56 "__id__": 56
} }
], ],
"_active": true, "_active": false,
"_components": [ "_components": [
{ {
"__id__": 59 "__id__": 59
...@@ -2918,7 +2918,7 @@ ...@@ -2918,7 +2918,7 @@
"__id__": 69 "__id__": 69
} }
], ],
"_active": true, "_active": false,
"_components": [ "_components": [
{ {
"__id__": 72 "__id__": 72
...@@ -3203,7 +3203,7 @@ ...@@ -3203,7 +3203,7 @@
"__id__": 78 "__id__": 78
} }
], ],
"_active": true, "_active": false,
"_components": [ "_components": [
{ {
"__id__": 81 "__id__": 81
...@@ -3488,7 +3488,7 @@ ...@@ -3488,7 +3488,7 @@
"__id__": 87 "__id__": 87
} }
], ],
"_active": true, "_active": false,
"_components": [ "_components": [
{ {
"__id__": 90 "__id__": 90
...@@ -3773,7 +3773,7 @@ ...@@ -3773,7 +3773,7 @@
"__id__": 96 "__id__": 96
} }
], ],
"_active": true, "_active": false,
"_components": [ "_components": [
{ {
"__id__": 99 "__id__": 99
...@@ -4058,7 +4058,7 @@ ...@@ -4058,7 +4058,7 @@
"__id__": 105 "__id__": 105
} }
], ],
"_active": true, "_active": false,
"_components": [ "_components": [
{ {
"__id__": 108 "__id__": 108
...@@ -4333,7 +4333,7 @@ ...@@ -4333,7 +4333,7 @@
}, },
{ {
"__type__": "cc.Node", "__type__": "cc.Node",
"_name": "bg_lamp", "_name": "bg_photo",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 67 "__id__": 67
...@@ -4343,7 +4343,7 @@ ...@@ -4343,7 +4343,7 @@
"__id__": 114 "__id__": 114
} }
], ],
"_active": true, "_active": false,
"_components": [ "_components": [
{ {
"__id__": 117 "__id__": 117
...@@ -4372,8 +4372,8 @@ ...@@ -4372,8 +4372,8 @@
}, },
"_contentSize": { "_contentSize": {
"__type__": "cc.Size", "__type__": "cc.Size",
"width": 173, "width": 265,
"height": 258 "height": 217
}, },
"_anchorPoint": { "_anchorPoint": {
"__type__": "cc.Vec2", "__type__": "cc.Vec2",
...@@ -4384,8 +4384,8 @@ ...@@ -4384,8 +4384,8 @@
"__type__": "TypedArray", "__type__": "TypedArray",
"ctor": "Float64Array", "ctor": "Float64Array",
"array": [ "array": [
384.059, 249.461,
-4.682999999999993, 178.252,
0, 0,
0, 0,
0, 0,
...@@ -4407,7 +4407,7 @@ ...@@ -4407,7 +4407,7 @@
"_is3DNode": false, "_is3DNode": false,
"_groupIndex": 0, "_groupIndex": 0,
"groupIndex": 0, "groupIndex": 0,
"_id": "ffJ/dWovhG96ueZ8FUyejl" "_id": "565Kv77/RBwYUFIogI4h2m"
}, },
{ {
"__type__": "cc.Node", "__type__": "cc.Node",
...@@ -4471,7 +4471,7 @@ ...@@ -4471,7 +4471,7 @@
"_is3DNode": false, "_is3DNode": false,
"_groupIndex": 0, "_groupIndex": 0,
"groupIndex": 0, "groupIndex": 0,
"_id": "fac7XpyNpPEaJa4KXlhCB2" "_id": "8f6ymxyyRCN7mSWwDMhHVP"
}, },
{ {
"__type__": "dragonBones.ArmatureDisplay", "__type__": "dragonBones.ArmatureDisplay",
...@@ -4511,7 +4511,7 @@ ...@@ -4511,7 +4511,7 @@
"_N$timeScale": 1, "_N$timeScale": 1,
"_N$debugBones": false, "_N$debugBones": false,
"_N$enableBatch": false, "_N$enableBatch": false,
"_id": "a0VOJxdkhELZHpCeGklHhq" "_id": "a7pMNVx0REbYxguJHr5XQr"
}, },
{ {
"__type__": "cc.PrefabInfo", "__type__": "cc.PrefabInfo",
...@@ -4540,7 +4540,7 @@ ...@@ -4540,7 +4540,7 @@
"_srcBlendFactor": 770, "_srcBlendFactor": 770,
"_dstBlendFactor": 771, "_dstBlendFactor": 771,
"_spriteFrame": { "_spriteFrame": {
"__uuid__": "1b376b4d-fce0-416d-981b-85726dc8d4b2" "__uuid__": "555a92c7-617e-4ebd-8a20-28b08a3d5817"
}, },
"_type": 0, "_type": 0,
"_sizeMode": 1, "_sizeMode": 1,
...@@ -4554,7 +4554,7 @@ ...@@ -4554,7 +4554,7 @@
"_fillRange": 0, "_fillRange": 0,
"_isTrimmedMode": true, "_isTrimmedMode": true,
"_atlas": null, "_atlas": null,
"_id": "2eYkmIROpHDqdcHikIy4Mo" "_id": "85wth9OsdKUYzYFLJgjdas"
}, },
{ {
"__type__": "cc.Widget", "__type__": "cc.Widget",
...@@ -4566,11 +4566,11 @@ ...@@ -4566,11 +4566,11 @@
"_enabled": true, "_enabled": true,
"alignMode": 1, "alignMode": 1,
"_target": null, "_target": null,
"_alignFlags": 4, "_alignFlags": 0,
"_left": 0, "_left": 0,
"_right": 0, "_right": 0,
"_top": 0, "_top": 0,
"_bottom": 241.317, "_bottom": 444.752,
"_verticalCenter": 0, "_verticalCenter": 0,
"_horizontalCenter": 0, "_horizontalCenter": 0,
"_isAbsLeft": true, "_isAbsLeft": true,
...@@ -4581,7 +4581,7 @@ ...@@ -4581,7 +4581,7 @@
"_isAbsVerticalCenter": true, "_isAbsVerticalCenter": true,
"_originalWidth": 0, "_originalWidth": 0,
"_originalHeight": 0, "_originalHeight": 0,
"_id": "3648XFsSpIh4B61sgsgBlQ" "_id": "263/lMGrZJhpS7YgeQdOCk"
}, },
{ {
"__type__": "a0c42HFVrlAzI/8g9Wlsc+q", "__type__": "a0c42HFVrlAzI/8g9Wlsc+q",
...@@ -4591,7 +4591,7 @@ ...@@ -4591,7 +4591,7 @@
"__id__": 113 "__id__": 113
}, },
"_enabled": true, "_enabled": true,
"_id": "d6D2hxaNNGoYF5mWLtpJvG" "_id": "f6N/RB1N1JGY8OGBiuGxEf"
}, },
{ {
"__type__": "cc.BlockInputEvents", "__type__": "cc.BlockInputEvents",
...@@ -4601,7 +4601,7 @@ ...@@ -4601,7 +4601,7 @@
"__id__": 113 "__id__": 113
}, },
"_enabled": true, "_enabled": true,
"_id": "fcb/M/0UpP/bVP4hR17O2w" "_id": "cdHYtihwtKIoeWs8xEofWu"
}, },
{ {
"__type__": "f9a5c5c6NpCFaKuCHIv6tRO", "__type__": "f9a5c5c6NpCFaKuCHIv6tRO",
...@@ -4614,11 +4614,11 @@ ...@@ -4614,11 +4614,11 @@
"starPopAudio": { "starPopAudio": {
"__uuid__": "82aa8d86-812e-48a6-b9f6-b5ef748f1719" "__uuid__": "82aa8d86-812e-48a6-b9f6-b5ef748f1719"
}, },
"_id": "9atxOjCxtMtZ3IJMi6l6Og" "_id": "d3chnR4aZLrrtj21MG1jmm"
}, },
{ {
"__type__": "cc.Node", "__type__": "cc.Node",
"_name": "bg_photo", "_name": "bg_lamp",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 67 "__id__": 67
...@@ -4628,7 +4628,7 @@ ...@@ -4628,7 +4628,7 @@
"__id__": 123 "__id__": 123
} }
], ],
"_active": true, "_active": false,
"_components": [ "_components": [
{ {
"__id__": 126 "__id__": 126
...@@ -4657,8 +4657,8 @@ ...@@ -4657,8 +4657,8 @@
}, },
"_contentSize": { "_contentSize": {
"__type__": "cc.Size", "__type__": "cc.Size",
"width": 265, "width": 173,
"height": 217 "height": 258
}, },
"_anchorPoint": { "_anchorPoint": {
"__type__": "cc.Vec2", "__type__": "cc.Vec2",
...@@ -4669,8 +4669,8 @@ ...@@ -4669,8 +4669,8 @@
"__type__": "TypedArray", "__type__": "TypedArray",
"ctor": "Float64Array", "ctor": "Float64Array",
"array": [ "array": [
249.461, 384.059,
178.252, -4.682999999999993,
0, 0,
0, 0,
0, 0,
...@@ -4692,7 +4692,7 @@ ...@@ -4692,7 +4692,7 @@
"_is3DNode": false, "_is3DNode": false,
"_groupIndex": 0, "_groupIndex": 0,
"groupIndex": 0, "groupIndex": 0,
"_id": "565Kv77/RBwYUFIogI4h2m" "_id": "ffJ/dWovhG96ueZ8FUyejl"
}, },
{ {
"__type__": "cc.Node", "__type__": "cc.Node",
...@@ -4756,7 +4756,7 @@ ...@@ -4756,7 +4756,7 @@
"_is3DNode": false, "_is3DNode": false,
"_groupIndex": 0, "_groupIndex": 0,
"groupIndex": 0, "groupIndex": 0,
"_id": "8f6ymxyyRCN7mSWwDMhHVP" "_id": "fac7XpyNpPEaJa4KXlhCB2"
}, },
{ {
"__type__": "dragonBones.ArmatureDisplay", "__type__": "dragonBones.ArmatureDisplay",
...@@ -4796,7 +4796,7 @@ ...@@ -4796,7 +4796,7 @@
"_N$timeScale": 1, "_N$timeScale": 1,
"_N$debugBones": false, "_N$debugBones": false,
"_N$enableBatch": false, "_N$enableBatch": false,
"_id": "a7pMNVx0REbYxguJHr5XQr" "_id": "a0VOJxdkhELZHpCeGklHhq"
}, },
{ {
"__type__": "cc.PrefabInfo", "__type__": "cc.PrefabInfo",
...@@ -4825,7 +4825,7 @@ ...@@ -4825,7 +4825,7 @@
"_srcBlendFactor": 770, "_srcBlendFactor": 770,
"_dstBlendFactor": 771, "_dstBlendFactor": 771,
"_spriteFrame": { "_spriteFrame": {
"__uuid__": "555a92c7-617e-4ebd-8a20-28b08a3d5817" "__uuid__": "1b376b4d-fce0-416d-981b-85726dc8d4b2"
}, },
"_type": 0, "_type": 0,
"_sizeMode": 1, "_sizeMode": 1,
...@@ -4839,7 +4839,7 @@ ...@@ -4839,7 +4839,7 @@
"_fillRange": 0, "_fillRange": 0,
"_isTrimmedMode": true, "_isTrimmedMode": true,
"_atlas": null, "_atlas": null,
"_id": "85wth9OsdKUYzYFLJgjdas" "_id": "2eYkmIROpHDqdcHikIy4Mo"
}, },
{ {
"__type__": "cc.Widget", "__type__": "cc.Widget",
...@@ -4851,11 +4851,11 @@ ...@@ -4851,11 +4851,11 @@
"_enabled": true, "_enabled": true,
"alignMode": 1, "alignMode": 1,
"_target": null, "_target": null,
"_alignFlags": 0, "_alignFlags": 4,
"_left": 0, "_left": 0,
"_right": 0, "_right": 0,
"_top": 0, "_top": 0,
"_bottom": 444.752, "_bottom": 241.317,
"_verticalCenter": 0, "_verticalCenter": 0,
"_horizontalCenter": 0, "_horizontalCenter": 0,
"_isAbsLeft": true, "_isAbsLeft": true,
...@@ -4866,7 +4866,7 @@ ...@@ -4866,7 +4866,7 @@
"_isAbsVerticalCenter": true, "_isAbsVerticalCenter": true,
"_originalWidth": 0, "_originalWidth": 0,
"_originalHeight": 0, "_originalHeight": 0,
"_id": "263/lMGrZJhpS7YgeQdOCk" "_id": "3648XFsSpIh4B61sgsgBlQ"
}, },
{ {
"__type__": "a0c42HFVrlAzI/8g9Wlsc+q", "__type__": "a0c42HFVrlAzI/8g9Wlsc+q",
...@@ -4876,7 +4876,7 @@ ...@@ -4876,7 +4876,7 @@
"__id__": 122 "__id__": 122
}, },
"_enabled": true, "_enabled": true,
"_id": "f6N/RB1N1JGY8OGBiuGxEf" "_id": "d6D2hxaNNGoYF5mWLtpJvG"
}, },
{ {
"__type__": "cc.BlockInputEvents", "__type__": "cc.BlockInputEvents",
...@@ -4886,7 +4886,7 @@ ...@@ -4886,7 +4886,7 @@
"__id__": 122 "__id__": 122
}, },
"_enabled": true, "_enabled": true,
"_id": "cdHYtihwtKIoeWs8xEofWu" "_id": "fcb/M/0UpP/bVP4hR17O2w"
}, },
{ {
"__type__": "f9a5c5c6NpCFaKuCHIv6tRO", "__type__": "f9a5c5c6NpCFaKuCHIv6tRO",
...@@ -4899,7 +4899,7 @@ ...@@ -4899,7 +4899,7 @@
"starPopAudio": { "starPopAudio": {
"__uuid__": "82aa8d86-812e-48a6-b9f6-b5ef748f1719" "__uuid__": "82aa8d86-812e-48a6-b9f6-b5ef748f1719"
}, },
"_id": "d3chnR4aZLrrtj21MG1jmm" "_id": "9atxOjCxtMtZ3IJMi6l6Og"
}, },
{ {
"__type__": "cc.Widget", "__type__": "cc.Widget",
...@@ -26908,7 +26908,7 @@ ...@@ -26908,7 +26908,7 @@
"__id__": 55 "__id__": 55
}, },
"lamp": { "lamp": {
"__id__": 113 "__id__": 122
}, },
"carpet": { "carpet": {
"__id__": 68 "__id__": 68
...@@ -26926,7 +26926,7 @@ ...@@ -26926,7 +26926,7 @@
"__id__": 104 "__id__": 104
}, },
"photo": { "photo": {
"__id__": 122 "__id__": 113
}, },
"starPop": null, "starPop": null,
"_id": "52c251abcdd44956b72965" "_id": "52c251abcdd44956b72965"
......
...@@ -230,12 +230,11 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -230,12 +230,11 @@ export default class SceneComponent extends MyCocosSceneComponent {
pg.view.touchOn(this.exitButton, this.onExitPetRoom, this); pg.view.touchOn(this.exitButton, this.onExitPetRoom, this);
} }
renderMyHouse() { renderMyHouse() {
console.log('house', user.myFurniture);
const fur_kinds = Object.keys(user.myFurniture.furniture); const fur_kinds = Object.keys(user.myFurniture.furniture);
const self = this;
fur_kinds.forEach(kind => { fur_kinds.forEach(kind => {
const fur = user.myFurniture.furniture[kind]; const fur = user.myFurniture.furniture[kind];
console.log(kind, fur.id, fur.rect); house.setFurnitureItem(self[kind], fur.id, fur.rect);
house.setFurnitureItem(this[kind], fur.id, fur.rect);
}); });
} }
//----------------------------商店部分-------------------------------------- //----------------------------商店部分--------------------------------------
...@@ -245,8 +244,8 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -245,8 +244,8 @@ export default class SceneComponent extends MyCocosSceneComponent {
} }
// 换装相关 // 换装相关
onTouchItemToChange(kind){ onTouchItemToChange(kind){
// console.log('house', house.list); console.log('house', house.list);
// console.log('change', kind); console.log('change', kind);
this.updateMyHouseItemsListView(kind); this.updateMyHouseItemsListView(kind);
this.skin_choice_dialog.active = true; this.skin_choice_dialog.active = true;
} }
...@@ -407,8 +406,7 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -407,8 +406,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
let discount = pg.view.find(item, "bg_food/discount"); let discount = pg.view.find(item, "bg_food/discount");
let btn_buy = pg.view.find(item, "bg_food/btn_buy"); let btn_buy = pg.view.find(item, "bg_food/btn_buy");
if(data.type == ITEM_TYPE.HOUSE && (data as HouseItem).own) { if(data.type == ITEM_TYPE.HOUSE && (data as HouseItem).num > 0) {
console.log(1, data);
let own = pg.view.find(item, "bg_food/own"); let own = pg.view.find(item, "bg_food/own");
pg.view.visible(own, true); pg.view.visible(own, true);
} }
...@@ -463,6 +461,7 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -463,6 +461,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
this.openTipNormal(data, () => { this.openTipNormal(data, () => {
action(data); action(data);
this.closeTipNormal(); this.closeTipNormal();
}, () => { }, () => {
this.closeTipNormal(); this.closeTipNormal();
}) })
...@@ -476,6 +475,7 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -476,6 +475,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
} }
buy(data) { buy(data) {
this.showWaitingLetters(); this.showWaitingLetters();
console.log('buy', data)
Api.askBuyItem(data).then((resp) => { Api.askBuyItem(data).then((resp) => {
this.fetchUserData().then(ud => { this.fetchUserData().then(ud => {
this.hideWaitingLetters(true) this.hideWaitingLetters(true)
...@@ -484,6 +484,13 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -484,6 +484,13 @@ export default class SceneComponent extends MyCocosSceneComponent {
this.updateShopBtns(); this.updateShopBtns();
this.openTipBuy(data, () => { this.openTipBuy(data, () => {
this.closeTipBuy(); this.closeTipBuy();
if (data.type == ITEM_TYPE.HOUSE) {
this.openTipAlert({message: '长按家具,可以更换装扮哦~',
callback: () => {
this.closeTipAlert();
}
})
}
}); });
}).catch(e => { }).catch(e => {
this.hideWaitingLetters(true); this.hideWaitingLetters(true);
......
...@@ -2,9 +2,10 @@ import Item from "./item"; ...@@ -2,9 +2,10 @@ import Item from "./item";
class HouseItem extends Item { class HouseItem extends Item {
public itemImage: string; // public itemImage: string; //
public kind: string; // 商品种类 public kind: string; // 商品种类
public own: boolean; // public own: boolean;
public rect: {x: number, y: number, width: number, height: number} public rect: {x: number, y: number, width: number, height: number}
public current = false; public current = false;
public defaultId: number;
constructor(obj: any) { constructor(obj: any) {
super(obj); super(obj);
// if (obj.type == 1) { // if (obj.type == 1) {
...@@ -17,8 +18,9 @@ class HouseItem extends Item { ...@@ -17,8 +18,9 @@ class HouseItem extends Item {
if (obj.meta_value && obj.meta_value.item) { if (obj.meta_value && obj.meta_value.item) {
this.itemImage = obj.meta_value.item; this.itemImage = obj.meta_value.item;
} }
this.own = obj.amount > 0; // this.num = obj.amount;
this.rect = obj.meta_value.rect; this.rect = obj.meta_value.rect;
this.defaultId = obj.defaultId;
// console.log(222, obj) // console.log(222, obj)
} }
} }
......
...@@ -26,8 +26,18 @@ class House { ...@@ -26,8 +26,18 @@ class House {
return this._list.findIndex(it => it.id == item_id) > -1; return this._list.findIndex(it => it.id == item_id) > -1;
} }
setFurnitureItem(node, id, rect = null) { setFurnitureItem(node, id, rect = null) {
const item = this._list.find(li => li.id == id) const item = this._list.find(li => li.id == id);
pg.view.setNetImg(node, item.itemImage, true); // if (!item) {
// item = this._list.find(li => {
// return li.defaultId == id
// });;
// }
if (!item) {
return;
}
pg.view.setNetImg(node, item.itemImage, true).then(() => {
node.active = true;
});
if (rect) { if (rect) {
node.x = rect.x; node.x = rect.x;
node.y = rect.y; node.y = rect.y;
......
...@@ -24,7 +24,7 @@ class Shop { ...@@ -24,7 +24,7 @@ class Shop {
return li.type == type && ![20,21,22,23,24,25,26,27,28,29,30].includes(li.id); return li.type == type && ![20,21,22,23,24,25,26,27,28,29,30].includes(li.id);
}).map(li => { }).map(li => {
if (li.type == 2) { if (li.type == 2) {
return {...li, own: house.has(li.id)} return {...li, num: (house.has(li.id) ? 1 : 0)}
} }
return li; return li;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment