RewardView.ts 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. import ViewObject from "../../main/ViewObject";
  2. import CardItem from "../home/card/item/CardItem";
  3. import GoodItem from "./GoodItem";
  4. /**
  5. * 通用的奖励显示弹出界面
  6. */
  7. const { ccclass, property } = cc._decorator;
  8. @ccclass
  9. export default class RewardView extends ViewObject {
  10. @property(cc.Prefab)
  11. mGoodItem: cc.Prefab = null;
  12. @property(cc.Node)
  13. mContent: cc.Node = null;
  14. @property(cc.Node)
  15. mComm: cc.Node = null;//普通道具,装备,金币钻石
  16. @property(cc.Node)
  17. mGodCard: cc.Node = null;//神卡显示
  18. @property(CardItem)
  19. mCardItem: CardItem = null;
  20. @property(cc.Label)
  21. mTitle: cc.Label = null;//标题
  22. @property(cc.Label)
  23. mAbout: cc.Label = null;//说明
  24. /**
  25. * 额外的奖励显示
  26. */
  27. private addList: Array<any> = []
  28. /**
  29. *
  30. * @param prev 父界面
  31. */
  32. public show(prev?: ViewObject) {
  33. if (prev) {
  34. this.prev = prev;
  35. this.prev.__close();
  36. }
  37. this.main.viewManage.popView1(this.node);
  38. if (this.main && this.main.gameHttp) {
  39. this.main.gameHttp.pushEvent(this);
  40. }
  41. }
  42. //let list = ff.main.sManage.getRewards(reve);
  43. /**
  44. {
  45. type:3, ---0:金币,1:钻石,2:道具,3:装备,4:神卡
  46. icon:'icon/equip/'+equip.icon,
  47. count:element.count,
  48. id:element.id,
  49. pz:equip.pz,
  50. PI:element.PI,
  51. star:element.star
  52. _data:__Equip
  53. }
  54. * @param list
  55. */
  56. public init(list: Array<any>) {
  57. let count = 0
  58. for (let i = 0; i < list.length; i++) {
  59. const element = list[i];
  60. if (element.type <= 3) {
  61. let node = cc.instantiate(this.mGoodItem)
  62. node.parent = this.mContent
  63. let goodItem = node.getComponent(GoodItem)
  64. goodItem.initReward(this.main, element)
  65. if(element.name){
  66. goodItem.mContrast.node.active = true
  67. goodItem.mContrast.string = element.name
  68. }
  69. count++
  70. } else {
  71. this.addList.push(element)
  72. }
  73. }
  74. if (count <= 0) {
  75. this.exitDistroy()
  76. }else{
  77. this.mComm.active = true
  78. this.mGodCard.active = false
  79. }
  80. }
  81. /**
  82. * 退出销毁界面
  83. */
  84. public exitDistroy() {
  85. if (this.addList.length <= 0) {
  86. super.exitDistroy()
  87. } else {
  88. this.mComm.active = false
  89. this.mGodCard.active = true
  90. let rewardData = this.addList.shift()
  91. this.mCardItem.init(this.main,rewardData.data)
  92. }
  93. }
  94. public setCloseCallback(closeCallback:()=>void){
  95. this.closeCallback = closeCallback
  96. }
  97. }