import GameModel from "../ts/core/GameModel"; import GameUtil from "../ts/core/GameUtil"; import DebateDao from "../ts/debateDao/DebateDao"; import { BattleType } from "../ts/game/battle/Battle"; import FGAlert from "../ts/gear_2.3.4/fgui/FGAlert"; let CPubFunction = require('./PubFunction'); cc.Class({ extends: cc.Component, properties: {}, onLoad() { }, start() { }, Close() { this.node.destroy(); }, PlayerFunUI_Init(info) { this.pInfo = info; cc.find('btnClose', this.node).getComponent(cc.Button).clickEvents.push(CPubFunction.CreateEventHandler(this.node, "PlayerFunUI", 'Close', 0)); cc.find('nodPlayerInfo/picPlayerAvater', this.node).getComponent(cc.Sprite).spriteFrame = GameModel.getRoleHead(info.resid); cc.find('nodPlayerInfo/picPlayerAvater/level', this.node).getComponent(cc.Label).string = info.level; cc.find('nodPlayerInfo/nodBianHao/labText', this.node).getComponent(cc.Label).string = info.roleid; cc.find('nodPlayerInfo/nodName/labText', this.node).color = GameUtil.getReliveColor(info.relive); cc.find('nodPlayerInfo/nodName/labText', this.node).getComponent(cc.Label).string = info.name; // cc.find('nodPlayerInfo/nodBangPai/labText', this.node).getComponent(cc.Label).string = strBangName; cc.find('btnChat', this.node).getComponent(cc.Button).clickEvents.push(CPubFunction.CreateEventHandler(this.node, "PlayerFunUI", 'OnPlayerFunction', 'btnChat')); cc.find('btnAddFriend', this.node).getComponent(cc.Button).clickEvents.push(CPubFunction.CreateEventHandler(this.node, "PlayerFunUI", 'OnPlayerFunction', 'btnAddFriend')); cc.find('btnFight', this.node).getComponent(cc.Button).clickEvents.push(CPubFunction.CreateEventHandler(this.node, "PlayerFunUI", 'OnPlayerFunction', 'btnFight')); cc.find('btnTeam', this.node).getComponent(cc.Button).clickEvents.push(CPubFunction.CreateEventHandler(this.node, "PlayerFunUI", 'OnPlayerFunction', 'btnTeam')); cc.find('btnInviteTeam', this.node).getComponent(cc.Button).clickEvents.push(CPubFunction.CreateEventHandler(this.node, "PlayerFunUI", 'OnPlayerFunction', 'btnInviteTeam')); if (GameModel.player.teamid > 0 && GameModel.player.teamid == info.teamid) { cc.find('btnFight', this.node).active = false; } cc.find('btnTeam', this.node).active = false; if (GameModel.player.teamid == 0 && info.teamid > 0) { cc.find('btnTeam', this.node).active = true; } cc.find('btnInviteTeam', this.node).active = false; if (GameModel.player.teamid > 0 && info.teamid == 0&&GameModel.player.isleader) { cc.find('btnInviteTeam', this.node).active = true; } if (GameModel.player.mapid == 4004) { cc.find('btnFight', this.node).active = false; cc.find('btnTeam', this.node).active = false; cc.find('btnInviteTeam', this.node).active = false; cc.find('btnChat', this.node).active = false; cc.find('btnAddFriend', this.node).active = false; if (DebateDao.Instance.stageType > 3) { var battleBtn = cc.find('btnBattle', this.node) battleBtn.getComponent(cc.Button).clickEvents.push(CPubFunction.CreateEventHandler(this.node, "PlayerFunUI", 'OnPlayerFunction', 'btnBattle')); battleBtn.active = true; } } }, PlayerFunUI_Init2(nResID, nLevel, nRoleID, nRelive, strName, strBangName) { this.pInfo = { resid: nResID, level: nLevel, relive: nLevel, name: strName }; cc.find('btnClose', this.node).getComponent(cc.Button).clickEvents.push(CPubFunction.CreateEventHandler(this.node, "PlayerFunUI", 'Close', 0)); cc.find('nodPlayerInfo/picPlayerAvater', this.node).getComponent(cc.Sprite).spriteFrame = GameModel.getRoleHead(nResID); cc.find('nodPlayerInfo/picPlayerAvater/level', this.node).getComponent(cc.Label).string = nLevel; cc.find('nodPlayerInfo/nodBianHao/labText', this.node).getComponent(cc.Label).string = nRoleID; cc.find('nodPlayerInfo/nodName/labText', this.node).color = GameUtil.getReliveColor(nRelive); cc.find('nodPlayerInfo/nodName/labText', this.node).getComponent(cc.Label).string = strName; // cc.find('nodPlayerInfo/nodBangPai/labText', this.node).getComponent(cc.Label).string = strBangName; cc.find('btnChat', this.node).getComponent(cc.Button).clickEvents.push(CPubFunction.CreateEventHandler(this.node, "PlayerFunUI", 'OnPlayerFunction', 'btnChat')); cc.find('btnAddFriend', this.node).getComponent(cc.Button).clickEvents.push(CPubFunction.CreateEventHandler(this.node, "PlayerFunUI", 'OnPlayerFunction', 'btnAddFriend')); cc.find('btnFight', this.node).getComponent(cc.Button).clickEvents.push(CPubFunction.CreateEventHandler(this.node, "PlayerFunUI", 'OnPlayerFunction', 'btnFight')); cc.find('btnExchange', this.node).getComponent(cc.Button).clickEvents.push(CPubFunction.CreateEventHandler(this.node, "PlayerFunUI", 'OnPlayerFunction', 'btnExchange')); cc.find('btnTeam', this.node).getComponent(cc.Button).clickEvents.push(CPubFunction.CreateEventHandler(this.node, "PlayerFunUI", 'OnPlayerFunction', 'btnTeam')); if (GameModel.player.teamid > 0 && GameModel.player.teamid == info.teamid) { cc.find('btnFight', this.node).active = false; cc.find('btnExchange', this.node).active = false; } cc.find('btnTeam', this.node).active = false; if (GameModel.player.teamid == 0 && info.teamid > 0) { cc.find('btnTeam', this.node).active = true; } }, OnPlayerFunction(stEvent, stParam) { if (stParam == 'btnChat') { } else if (stParam == 'btnAddFriend') { GameModel.send('c2s_add_friend', { roleid: this.pInfo.roleid }); } else if (stParam == 'btnFight') { let roleId = this.pInfo.roleid; FGAlert.show(`一定要和他拼個你死我活嗎?\n[color=#ff0000]野外決鬥每擊敗一個玩家,被抓捕後將失去30分鐘自由遊戲時間,決鬥死亡將會扣除2億經驗,是否繼續[/color]`, () => { FGAlert.hide(); }, () => { FGAlert.hide(); GameModel.send('c2s_pk', { troleid: roleId, type: BattleType.Force }); }); } else if (stParam == 'btnExchange') { cc.ll.net.send('c2s_exchange_views', { troleid: this.pInfo.roleid }); } else if (stParam == 'btnTeam') { GameModel.send('c2s_requst_team', { roleid: GameModel.player.roleid, teamid: this.pInfo.teamid }); } else if (stParam == 'btnInviteTeam') { GameModel.send('c2s_team_invite', { toroleid: this.pInfo.roleid, }); } else if (stParam == 'btnBattle') { let teamId = this.pInfo.teamid; GameModel.notice.addMsg(1, '是否發起決殺? ', () => { GameModel.send('c2s_sat_challenge', { rivalTeamId: teamId }); }, () => { }); } this.node.destroy(); }, });