local WatchBattle_Controller = {} local EventSystem = require('Event/EventSystem') local private = {} local BULLET_ARR_CONST = DataSheetManager.ConstData:GetDataByID("BulletColor2").StringListValue local PLAYER_DEFAULT_IS_SHOW_BULLET = DataSheetManager.ConstData:GetDataByID("HeroMatch1v1Bullet2").BoolValue local WATCHER_DEFAULT_IS_SHOW_BULLET = DataSheetManager.ConstData:GetDataByID("HeroMatch1v1Bullet1").BoolValue WatchBattle_Controller.BulletColor = { White = BULLET_ARR_CONST[1], -- 白色 Green = BULLET_ARR_CONST[2], -- 绿色 Blue = BULLET_ARR_CONST[3], -- 蓝色 Purple = BULLET_ARR_CONST[4], -- 紫色 Orange = BULLET_ARR_CONST[5], -- 橙色 } function WatchBattle_Controller.OnStartup() -- 观战下是否显示弹幕 private.isShowBullet = nil -- 开启弹幕时隐藏名字版 private.isHideBulletName = false -- 弹幕颜色(默认白色) private.bulletColor = WatchBattle_Controller.BulletColor.White end --region ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ 观战基础设置 ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ function WatchBattle_Controller.GetIsShowBullet() if private.isShowBullet == nil then if BattleDataGetter.IsInLevelWatchBattle() or BattleDataGetter.CheckCurLevelType(LuaConst.LevelType.CrossHeroMatchTown) or BattleDataGetter.CheckCurLevelType(LuaConst.LevelType.CrossHeroMatchTown3V3) or BattleDataGetter.CheckCurLevelType(LuaConst.LevelType.CrossFairSoloTournamentTown) or BattleDataGetter.CheckCurLevelType(LuaConst.LevelType.SingleFairSoloTournamentTown) or BattleDataGetter.CheckCurLevelType(LuaConst.LevelType.TeamFairChampionshipTown) then private.isShowBullet = WATCHER_DEFAULT_IS_SHOW_BULLET else private.isShowBullet = PLAYER_DEFAULT_IS_SHOW_BULLET end end return private.isShowBullet end function WatchBattle_Controller.SetIsShowBullet(value) private.isShowBullet = value if value == true then CTL.BulletScreen.Show() else CTL.BulletScreen.Hide() end EventSystem.Dispatch(EventID.UI_UpdateSyncUnfairSoloWatch_ShowBullet, value) end function WatchBattle_Controller.GetIsHideBulletName() return private.isHideBulletName end function WatchBattle_Controller.SetIsHideBulletName(value) private.isHideBulletName = value end function WatchBattle_Controller.GetBulletColor() return private.bulletColor end function WatchBattle_Controller.SetBulletColor(value) private.bulletColor = value end --endregion↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑ --region----------观战弹幕操作 ------------- function WatchBattle_Controller.InitBullet() -- 1.5.000版本之后开启弹幕功能 if GameAppInfo.IsVersionGreaterThan15000() then MDL.BulletScreen.OpenBulletScreen() EventSystem.Regist(EventID.ChannelChat_ReceiveNewMsg, CTL.WatchBattle.OnReceivedBulletChannelMsg) end end function WatchBattle_Controller.ShutBullet() EventSystem.UnRegist(EventID.ChannelChat_ReceiveNewMsg, CTL.WatchBattle.OnReceivedBulletChannelMsg) MDL.BulletScreen.CloseBulletScreen() end local COLOR_STR_HASHTAG = "#%s" function WatchBattle_Controller.OnReceivedBulletChannelMsg(msgData) if (MDL.ChannelChat.IsBulletChannelByChannelId(msgData.targetId) and (BattleDataGetter.CheckCurLevelType(LuaConst.LevelType.SyncUnfairSolo) or BattleDataGetter.CheckCurLevelType(LuaConst.LevelType.SyncUnfairTeamPVP) or LevelManager.IsSceneQuizTown() or BattleDataGetter.CheckCurLevelType(LuaConst.LevelType.SyncFairSoloTournament) or BattleDataGetter.CheckCurLevelType(LuaConst.LevelType.SyncTeamFairChampionship))) or CTL.CustomRoom.IsInCustomRoomChannel(msgData.targetId) then if WatchBattle_Controller.GetIsShowBullet() or LevelManager.IsSceneQuizTown() then if msgData.isSelf then CTL.Tips.AddTipsMsg(Const_IDS.IDS_HeroMatch1v1_SendBulletSuccess) end CTL.BulletScreen.AddMsg({ chatMsgData = msgData, content = private.CreateBulletChannelText(msgData), fontColor = string.isNilOrEmpty(msgData.color) and nil or string.format(COLOR_STR_HASHTAG, msgData.color) }) end end end local COLON_FORMAT = "%s : %s" function private.CreateBulletChannelText(msgData) if not WatchBattle_Controller.GetIsHideBulletName() then return string.format(COLON_FORMAT, msgData.senderName .. CTL.CrossServer.GetServerShowStr(msgData.serId), msgData.content) else return msgData.content end end --endregion------------------------------ -- 切换玩家视角 function WatchBattle_Controller.SwitchPlayer() NotSyncBattleSetter.SwitchWatchPlayer() end return WatchBattle_Controller