DressUp.ts 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. // Learn TypeScript:
  2. // - https://docs.cocos.com/creator/2.4/manual/en/scripting/typescript.html
  3. // Learn Attribute:
  4. // - https://docs.cocos.com/creator/2.4/manual/en/scripting/reference/attributes.html
  5. // Learn life-cycle callbacks:
  6. // - https://docs.cocos.com/creator/2.4/manual/en/scripting/life-cycle-callbacks.html
  7. import EventName from "../EventName/EventName";
  8. import { ButtonLock } from "../GameLogic/Sofa";
  9. import HTTPS, { NetGet } from "../Template/HTTPS";
  10. import PopComponet from "../Template/PopComponet";
  11. import { CollectDetailsType } from "./CollectManger";
  12. const { ccclass, property } = cc._decorator;
  13. @ccclass
  14. export default class DressUp extends PopComponet {
  15. @property(cc.SpriteFrame)
  16. Dress_Sp: cc.SpriteFrame = null
  17. @property(cc.Sprite)
  18. image: cc.Sprite = null
  19. @property(cc.Node)
  20. Btn: cc.Node = null
  21. @property(cc.Label)
  22. Label: cc.Label = null
  23. @property(cc.Label)
  24. Name: cc.Label = null
  25. protected start(): void {
  26. let d = <CollectDetailsType>this.Options.Data.MyType
  27. this.image.spriteFrame = this.Options.Data.Sp
  28. this.Name.string = d.Name
  29. if (d.IsHold == 1) {
  30. //拥有
  31. this.Btn.active = true
  32. this.image.setMaterial(0, cc.MaterialVariant.createWithBuiltin(cc.Material.BUILTIN_NAME.SPRITE, null))
  33. this.Label.string = d.Description
  34. if (d.IsWear == 0) {
  35. this.Btn.getComponent(cc.Sprite).spriteFrame = this.Dress_Sp
  36. }
  37. } else {
  38. //未拥有
  39. this.Btn.active = false
  40. this.image.setMaterial(0, cc.MaterialVariant.createWithBuiltin(cc.Material.BUILTIN_NAME.GRAY_SPRITE, null))
  41. this.Label.string = d.Condition
  42. }
  43. }
  44. @ButtonLock(1, null)
  45. Click() {
  46. let d = <CollectDetailsType>this.Options.Data.MyType
  47. if (d.IsHold == 1) {
  48. HTTPS.Instance.get(NetGet.UserWearCollect + d.Id).then((resp) => {
  49. cc.systemEvent.emit(EventName.CollectSelect, d.Id)
  50. this.Surpclose()
  51. })
  52. }
  53. }
  54. }