RoleTitleView.ts 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. import { GameViewType } from "../../../main/ViewManage";
  2. import ViewObject from "../../../main/ViewObject";
  3. import CMath from "../../../util/CMath";
  4. import FFCalAttr from "../../data/FFCalAttr";
  5. import RoleTitleItem from "./RoleTitleItem";
  6. import TitleInfoView from "./TitleInfoView";
  7. /**
  8. * 称号设置界面
  9. */
  10. const {ccclass, property} = cc._decorator;
  11. @ccclass
  12. export default class RoleTitleView extends ViewObject {
  13. @property(cc.Node)
  14. mContent: cc.Node = null;
  15. @property(cc.Prefab)
  16. mFrameIcon: cc.Prefab = null;
  17. @property(cc.Node)
  18. mContentHas: cc.Node = null;
  19. @property(TitleInfoView)
  20. mTitleInfoView: TitleInfoView = null;
  21. @property(cc.Label)
  22. mZdl: cc.Label = null;
  23. public init(){
  24. let roleIcons = this.main.sManage.getRoleIcon()
  25. for (let i = 0; i < roleIcons.length; i++) {
  26. const element = roleIcons[i];
  27. if(element.type == 3){
  28. let node = cc.instantiate(this.mFrameIcon)
  29. let frameIcon = node.getComponent(RoleTitleItem)
  30. frameIcon.roleIcon = element
  31. frameIcon.init()
  32. frameIcon.flushLock(this.main)
  33. node.parent = this.mContent
  34. frameIcon.setCallback((ftp:RoleTitleItem)=>{
  35. this.openInfo(ftp)
  36. })
  37. }
  38. }
  39. let tif = this.mContent.children[0].getComponent(RoleTitleItem)
  40. this.flush(tif)
  41. }
  42. public flush(tif:RoleTitleItem){
  43. this.mTitleInfoView.init(this.main,tif)
  44. let data = {
  45. atk:0,
  46. def:0,
  47. hp:0,
  48. sp:0
  49. }
  50. let open = this.main.player.roleIcon.open
  51. for (let i = 0; i < open.length; i++) {
  52. const element = open[i];
  53. if(element >= 400 && element < 400){
  54. let temp = this.main.sManage.getRoleIconById(element)
  55. data.atk += temp.atk
  56. data.def += temp.def
  57. data.hp += temp.hp
  58. data.sp += temp.sp
  59. }
  60. }
  61. let zdl = FFCalAttr.getZdl(data)
  62. this.mZdl.string = ''+zdl
  63. }
  64. public openInfo(tif:RoleTitleItem){
  65. this.mTitleInfoView.init(this.main,tif)
  66. }
  67. }