CardInfoView.ts 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. import i18n from "../../../i18n/i18n";
  2. import { GameViewType } from "../../../main/ViewManage";
  3. import ViewObject from "../../../main/ViewObject";
  4. import RadarChart,{RadarChartData} from "../../../util/RadarChart";
  5. import FFCalAttr from "../../data/FFCalAttr";
  6. import CardStarView from "./CardStarView";
  7. import CardItem from "./item/CardItem";
  8. /**
  9. * 神卡说明
  10. */
  11. const { ccclass, property } = cc._decorator;
  12. @ccclass
  13. export default class CardInfoView extends ViewObject {
  14. @property(CardItem)
  15. mCardItem: CardItem = null;
  16. @property(RadarChart)
  17. radarChart: RadarChart = null;
  18. @property(cc.Label)
  19. mAttrLable: cc.Label = null;
  20. @property([cc.Label])
  21. mAttrValue: Array<cc.Label> = [];
  22. public cardItem:CardItem
  23. public onLoad(){
  24. this.flushRadarChart()
  25. }
  26. public exitDistroy(){
  27. super.exitDistroy()
  28. this.cardItem.flushStar()
  29. }
  30. public init(cardItem:CardItem){
  31. this.cardItem = cardItem
  32. }
  33. /**
  34. * 更新雷达图
  35. */
  36. public flushRadarChart(){
  37. this.mCardItem.init(this.main,this.cardItem.godCardAttr)
  38. let fAttr = FFCalAttr.getGodCardAttr(this.main,this.cardItem.godCardAttr)
  39. let v1 = fAttr.thunder
  40. let v2 = fAttr.earth
  41. let v3 = fAttr.fire
  42. let v4 = fAttr.water
  43. let v5 = fAttr.wind
  44. if(v1 > 100){
  45. v1 = 100
  46. }
  47. if(v2 > 100){
  48. v2 = 100
  49. }
  50. if(v3 > 100){
  51. v3 = 100
  52. }
  53. if(v4 > 100){
  54. v4 = 100
  55. }
  56. if(v5 > 100){
  57. v5 = 100
  58. }
  59. let attrData = [v1,v2,v3,v4,v5]
  60. let values = [v1/100,v2/100,v3/100,v4/100,v5/100]
  61. for (let i = 0; i < attrData.length; i++) {
  62. const element = attrData[i];
  63. this.mAttrValue[i].string = ''+element
  64. }
  65. let data:RadarChartData = {
  66. values:values
  67. }
  68. this.radarChart.draw(data)
  69. let job = ['','射手','法师','战士']
  70. let _godCard = this.cardItem._godCard
  71. let jobStr = job[_godCard.job]
  72. let lableStr = ''
  73. if(fAttr.atk > 0){
  74. lableStr += i18n.t(jobStr)+i18n.t('攻击')+'+'+fAttr.atk + '\n'
  75. }
  76. if(fAttr.def > 0){
  77. lableStr += i18n.t(jobStr)+i18n.t('防御')+'+'+fAttr.def + '\n'
  78. }
  79. if(fAttr.hp > 0){
  80. lableStr += i18n.t(jobStr)+i18n.t('气血')+'+'+fAttr.hp + '\n'
  81. }
  82. if(fAttr.sp > 0){
  83. lableStr += i18n.t(jobStr)+i18n.t('敏捷')+'+'+fAttr.sp + '\n'
  84. }
  85. lableStr += _godCard.about
  86. this.mAttrLable.string = lableStr
  87. }
  88. /**
  89. * 神像升星
  90. */
  91. public openidol_sx(){
  92. this.main.viewManage.loadFunc(GameViewType.god_card_star,(viewObject:ViewObject)=>{
  93. let cardStarView:CardStarView = viewObject as CardStarView
  94. cardStarView.init(this)
  95. viewObject.show(this);
  96. });
  97. }
  98. }