123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- import { GameViewType } from "../../../main/ViewManage";
- import ViewObject from "../../../main/ViewObject";
- import FFCalAttr from "../../data/FFCalAttr";
- import TapRole from "../TapRole";
- import RoleIconItem from "./RoleIconItem";
- import IconInfoView from "./IconInfoView";
- /**
- * 头像设置界面
- */
- const {ccclass, property} = cc._decorator;
- @ccclass
- export default class RoleIconView extends ViewObject {
- @property(cc.Node)
- mContent: cc.Node = null;
- @property(cc.Prefab)
- mFrameIcon: cc.Prefab = null;
- @property(cc.Label)
- mZdl: cc.Label = null;
- @property(IconInfoView)
- private iconInfoView:IconInfoView = null
- public tapRole:TapRole = null;
- onLoad(){
- this.iconInfoView.main = this.main
- this.iconInfoView.roleIconView = this
- this.iconInfoView.openType = 1
- this.init()
- }
- private init(){
- let roleIcons = this.main.sManage.getRoleIcon()
- let fip = undefined
- let iconId = this.main.player.role.icon
- for (let i = 0; i < roleIcons.length; i++) {
- const element = roleIcons[i];
- if(element.type == 1){
- let node = cc.instantiate(this.mFrameIcon)
- let frameIcon = node.getComponent(RoleIconItem)
- frameIcon.roleIcon = element
- frameIcon.flush(this.main)
- node.parent = this.mContent
- frameIcon.setCallback((fip:RoleIconItem)=>{
- this.openInfo(fip)
- })
- if(iconId == element.id){
- fip = frameIcon
- }
- }
- }
- if(!fip){
- fip = this.mContent.children[0].getComponent(RoleIconItem)
- }
- this.flush(fip)
- }
- public flush(fip:RoleIconItem){
- this.iconInfoView.init(this.main,fip)
- let data = {
- atk:0,
- def:0,
- hp:0,
- sp:0
- }
- let open = this.main.player.roleIcon.open
- for (let i = 0; i < open.length; i++) {
- const element = open[i];
- if(element < 200){
- let temp = this.main.sManage.getRoleIconById(element)
- data.atk += temp.atk
- data.def += temp.def
- data.hp += temp.hp
- data.sp += temp.sp
- }
- }
- let zdl = FFCalAttr.getZdl(data)
- this.mZdl.string = ''+zdl
- let nodes = this.mContent.children
- for (let i = 0; i < nodes.length; i++) {
- const node = nodes[i];
- let item = node.getComponent(RoleIconItem)
- if(item.roleIcon.id != this.main.player.role.icon){
- item.setCheck(false)
- }else{
- item.setCheck(true)
- }
- }
- }
- private openInfo(fip:RoleIconItem){
- this.flush(fip)
- fip.mCheck.active = true
- let nodes = fip.node.parent.children
- for (let i = 0; i < nodes.length; i++) {
- const element = nodes[i];
- let tmp = element.getComponent(RoleIconItem)
- if(tmp != fip){
- tmp.mCheck.active = false;
- }
- }
- }
- }
|