SkinItem.ts 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. import gameScene from "../../gameScene";
  2. import hallScene from "../../hallScene";
  3. import { App } from "../../Manager/App";
  4. import DragonAnim from "../../Manager/DragonAnim";
  5. import SuperListItem from "../SuperScrollview/SuperListItem";
  6. import TipPanel from "../tipPanel/TipPanel";
  7. import TipPanelMediator from "../tipPanel/TipPanelMediator";
  8. const { ccclass, property } = cc._decorator;
  9. @ccclass
  10. export default class SkinItem extends SuperListItem {
  11. @property(cc.Label)
  12. nameLabel: cc.Label = null; // 皮肤名称label(暂时隐藏)
  13. @property(cc.Sprite)
  14. texture: cc.Sprite = null;// 皮肤图片
  15. @property(cc.Node)
  16. dressOnBtn: cc.Node = null;// 选择皮肤按钮
  17. @property(cc.Node)
  18. noDressOnBtn: cc.Node = null;// 不可选择皮肤按钮
  19. @property(cc.Node)
  20. newTips: cc.Node = null;
  21. private datas: any = null;
  22. public setData(data: any) {
  23. // this.nameLabel.string = data.name + "";
  24. this.datas = data;
  25. var self = this;
  26. App.Facade.loadTexture('hallScene/texture/' + data.path).then((res: any) => {
  27. self.texture.spriteFrame = res;
  28. });
  29. // let hasSkin = (App.DataManager.GetSkins.indexOf(data.name) != -1) ? true : false;
  30. let hasSkin = true;
  31. this.dressOnBtn.active = hasSkin;
  32. this.noDressOnBtn.active = !hasSkin;
  33. this.texture.node.color = (hasSkin) ? cc.Color.WHITE : new cc.Color(0, 0, 0, 150);
  34. this.newTips.active = (App.DataManager.NewSkinName == data.name) ? true : false;
  35. }
  36. /**
  37. * 点击穿戴按钮
  38. */
  39. public ClickDressOn() {
  40. if (this.datas.name == App.DataManager.DressingSkin) return;
  41. App.DataManager.DressingSkin = this.datas.name;
  42. App.LocalStorageUtil.setString(App.LocalStorageUtil.lst_dressOnSkin, App.DataManager.DressingSkin);
  43. App.Facade.popView(TipPanelMediator, TipPanel, "皮肤更换成功~", false);
  44. if (gameScene.instance && gameScene.instance.node) gameScene.instance.SetDeadColor();
  45. DragonAnim.getInstance().ChangeDragonSkin();
  46. }
  47. }